From 9ecaa2d5f97aa79f4f908e16312f425e8a27d04a Mon Sep 17 00:00:00 2001 From: Thomas Krause Date: Wed, 7 Oct 2026 17:50:32 +0200 Subject: [PATCH 1/2] Explicitly sort output token in RST visualizer Fixes: #913 --- CHANGELOG.md | 2 ++ .../annis/gui/visualizers/component/rst/RSTImpl.java | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29afb9df52..7c816ec11a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ ANNIS is a frontend to the graphANNIS webservice, which has its [own changelog]( - Document names containing an umlaut or other special characters were shown percent encoded in the match list ([#837](https://github.com/korpling/ANNIS/issues/837)). +- RST segments did not sort their token theirself, but relied on external mechanisms to + already get sorted tokens. Changed to explicitly sort the output. (#913) ## [4.15.3] - 2026-06-25 diff --git a/src/main/java/org/corpus_tools/annis/gui/visualizers/component/rst/RSTImpl.java b/src/main/java/org/corpus_tools/annis/gui/visualizers/component/rst/RSTImpl.java index 8eb1602c5b..9d664aba97 100644 --- a/src/main/java/org/corpus_tools/annis/gui/visualizers/component/rst/RSTImpl.java +++ b/src/main/java/org/corpus_tools/annis/gui/visualizers/component/rst/RSTImpl.java @@ -262,6 +262,7 @@ private boolean isSecondarySignalNode(SNode sNode) { private String transformSaltToJSON(VisualizerInput visInput) { graph = visInput.getSResult().getDocumentGraph(); + List rootSNodes = graph.getRoots(); List rstRoots = new ArrayList(); @@ -376,7 +377,7 @@ private JSONObject createJsonEntry(SNode currNode) { JSONObject data = new JSONObject(); StringBuilder sb = new StringBuilder(); // use a hash set so we don't get any duplicate entries - LinkedHashSet token = new LinkedHashSet<>(); + HashSet tokenSet = new HashSet<>(); List> edges; if (currNode instanceof SStructure) { @@ -386,11 +387,12 @@ private JSONObject createJsonEntry(SNode currNode) { // get all tokens directly dominated tokens and build a string for (SRelation sedge : edges) { if (sedge.getTarget() instanceof SToken) { - token.add((SToken) sedge.getTarget()); + tokenSet.add((SToken) sedge.getTarget()); } } - // build strings + // build strings from sorted token + List token = graph.getSortedTokenByText(new ArrayList<>(tokenSet)); Iterator tokIterator = token.iterator(); while (tokIterator.hasNext()) { SToken tok = tokIterator.next(); @@ -441,7 +443,7 @@ private JSONObject createJsonEntry(SNode currNode) { // since we have found some tokens, it must be a sentence in RST. - if (token.size() > 0) { + if (!tokenSet.isEmpty()) { data.put("sentence", sb.toString()); } From 3798a995459a1582007c5bb777f3eaa12eb0eb61 Mon Sep 17 00:00:00 2001 From: Thomas Krause Date: Wed, 7 Oct 2026 17:57:34 +0200 Subject: [PATCH 2/2] Remove unused import --- .../annis/gui/visualizers/component/rst/RSTImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/corpus_tools/annis/gui/visualizers/component/rst/RSTImpl.java b/src/main/java/org/corpus_tools/annis/gui/visualizers/component/rst/RSTImpl.java index 9d664aba97..837abcac78 100644 --- a/src/main/java/org/corpus_tools/annis/gui/visualizers/component/rst/RSTImpl.java +++ b/src/main/java/org/corpus_tools/annis/gui/visualizers/component/rst/RSTImpl.java @@ -22,7 +22,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set;