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..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; @@ -262,6 +261,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 +376,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 +386,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 +442,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()); }