From d00126c4d42a7143d247a2efbf8976e4078cceb4 Mon Sep 17 00:00:00 2001 From: Martin Klotz Date: Sun, 8 Nov 2026 17:47:29 +0100 Subject: [PATCH 1/4] allow to define a root label that highlights roots --- .../dependency/VakyarthaDependencyTree.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/corpus_tools/annis/gui/visualizers/iframe/dependency/VakyarthaDependencyTree.java b/src/main/java/org/corpus_tools/annis/gui/visualizers/iframe/dependency/VakyarthaDependencyTree.java index 9c68fe0871..e49c56746a 100644 --- a/src/main/java/org/corpus_tools/annis/gui/visualizers/iframe/dependency/VakyarthaDependencyTree.java +++ b/src/main/java/org/corpus_tools/annis/gui/visualizers/iframe/dependency/VakyarthaDependencyTree.java @@ -17,11 +17,13 @@ import com.google.common.collect.Range; import java.io.IOException; import java.io.Writer; +import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.TreeSet; import org.apache.commons.lang3.StringUtils; @@ -31,7 +33,9 @@ import org.corpus_tools.annis.gui.visualizers.iframe.WriterVisualizer; import org.corpus_tools.salt.SALT_TYPE; import org.corpus_tools.salt.common.SDocumentGraph; +import org.corpus_tools.salt.common.SOrderRelation; import org.corpus_tools.salt.common.SPointingRelation; +import org.corpus_tools.salt.common.SSpan; import org.corpus_tools.salt.common.STextualDS; import org.corpus_tools.salt.common.SToken; import org.corpus_tools.salt.core.SAnnotation; @@ -77,6 +81,11 @@ public class VakyarthaDependencyTree extends WriterVisualizer { // NO_UCD (unuse * the token level. */ private final String MAPPING_NODE_KEY = "node_key"; + /** + * If this mapping is set to a string value, any edge holding an edge label with said value + * will be considered a root edge and displayed as such. + * */ + private final String MAPPING_ROOT_LABEL = "root_label"; private Map mappings; @@ -142,11 +151,10 @@ public void printHTMLOutput(VisualizerInput input, Writer writer, TreeSet } } - Map node2Int = new HashMap(); int count = 0; for (SNode tok : selectedNodes) { - node2Int.put(tok, count++); + node2Int.put(tok, count++); } @@ -180,6 +188,7 @@ public void printHTMLOutput(VisualizerInput input, Writer writer, TreeSet println("tokens=new Object();", writer); count = 0; + for (SNode node : selectedNodes) { JSONObject vakyarthaObject = new JSONObject(); @@ -226,7 +235,10 @@ public void printHTMLOutput(VisualizerInput input, Writer writer, TreeSet String label = sRelation.getAnnotations().stream().findFirst() .map(SAnnotation::getValue_STEXT).orElse(""); - if (sRelation.getSource() != null && node2Int.containsKey(source)) { + if (label != null && label.equals(mappings.get(MAPPING_ROOT_LABEL))) { + govs.put("root", label); + } + else if (sRelation.getSource() != null && node2Int.containsKey(source)) { govs.put(String.valueOf(node2Int.get(source)), label); } } From 647a3ff8992f3f0de88368709aba948db801c53d Mon Sep 17 00:00:00 2001 From: Martin Klotz Date: Sun, 8 Nov 2026 17:48:53 +0100 Subject: [PATCH 2/4] update --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c90c6ee36..dab401a22c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ ANNIS is a frontend to the graphANNIS webservice, which has its [own changelog]( ## [Unreleased] +### Added + +- Visualizer `arch_dependency` allows to highlight roots with explicit edges by setting a label value that identifies such edges. + The value is set with mapping `root_label`. + ## [4.16.0] - 2026-10-09 ### Added From e1ae0973943d16d4046a279fc9eab9de59c4bd80 Mon Sep 17 00:00:00 2001 From: Martin Klotz Date: Tue, 10 Nov 2026 15:22:05 +0100 Subject: [PATCH 3/4] reorganised imports --- .../iframe/dependency/VakyarthaDependencyTree.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/corpus_tools/annis/gui/visualizers/iframe/dependency/VakyarthaDependencyTree.java b/src/main/java/org/corpus_tools/annis/gui/visualizers/iframe/dependency/VakyarthaDependencyTree.java index e49c56746a..f238ef7352 100644 --- a/src/main/java/org/corpus_tools/annis/gui/visualizers/iframe/dependency/VakyarthaDependencyTree.java +++ b/src/main/java/org/corpus_tools/annis/gui/visualizers/iframe/dependency/VakyarthaDependencyTree.java @@ -14,18 +14,16 @@ package org.corpus_tools.annis.gui.visualizers.iframe.dependency; -import com.google.common.collect.Range; import java.io.IOException; import java.io.Writer; -import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.TreeSet; + import org.apache.commons.lang3.StringUtils; import org.corpus_tools.annis.gui.Helper; import org.corpus_tools.annis.gui.MatchedNodeColors; @@ -33,9 +31,7 @@ import org.corpus_tools.annis.gui.visualizers.iframe.WriterVisualizer; import org.corpus_tools.salt.SALT_TYPE; import org.corpus_tools.salt.common.SDocumentGraph; -import org.corpus_tools.salt.common.SOrderRelation; import org.corpus_tools.salt.common.SPointingRelation; -import org.corpus_tools.salt.common.SSpan; import org.corpus_tools.salt.common.STextualDS; import org.corpus_tools.salt.common.SToken; import org.corpus_tools.salt.core.SAnnotation; @@ -48,6 +44,8 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; +import com.google.common.collect.Range; + /** * Provides a dependence visualization based on vakyartha visualization, which was developed by Kim * Gerdes. From 05548ee24537077010d21aff7b44d23d6310a970 Mon Sep 17 00:00:00 2001 From: Martin Klotz Date: Wed, 11 Nov 2026 11:11:28 +0100 Subject: [PATCH 4/4] add option to identify roots via target node labels #920 --- .../dependency/VakyarthaDependencyTree.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/corpus_tools/annis/gui/visualizers/iframe/dependency/VakyarthaDependencyTree.java b/src/main/java/org/corpus_tools/annis/gui/visualizers/iframe/dependency/VakyarthaDependencyTree.java index f238ef7352..5b7b492116 100644 --- a/src/main/java/org/corpus_tools/annis/gui/visualizers/iframe/dependency/VakyarthaDependencyTree.java +++ b/src/main/java/org/corpus_tools/annis/gui/visualizers/iframe/dependency/VakyarthaDependencyTree.java @@ -57,7 +57,12 @@ * * Mappings:
* If a annotation key is specified with node_key:key, all nodes which carry this annotation - * are searched for pointing relations and instead of the token span the annotation value is used. + * are searched for pointing relations and instead of the token span the annotation value is used.
+ * If root edges should be display, this can be achieved by setting root_label to the edge label + * value that identifies root edges. This, of course, requires these edges to exist.
+ * If the label for root edges is actually contained in a node annotation, the key for the node annotation + * needs to be provided additionally by setting root_label_node_key to the respective qualified + * annotation name. * * @author Thomas Krause {@literal } * @author Benjamin Weißenfels{@literal } @@ -84,6 +89,11 @@ public class VakyarthaDependencyTree extends WriterVisualizer { // NO_UCD (unuse * will be considered a root edge and displayed as such. * */ private final String MAPPING_ROOT_LABEL = "root_label"; + /** + * If this is set to an annotation qname, the root label will be looked for on target nodes + * rather than edges. This only works when root_label is set. + */ + private static final String MAPPING_ROOT_LABEL_NODE_KEY = "root_label_node_key"; private Map mappings; @@ -186,6 +196,7 @@ public void printHTMLOutput(VisualizerInput input, Writer writer, TreeSet println("tokens=new Object();", writer); count = 0; + String nodeRootQname = mappings.get(MAPPING_ROOT_LABEL_NODE_KEY); for (SNode node : selectedNodes) { JSONObject vakyarthaObject = new JSONObject(); @@ -206,6 +217,12 @@ public void printHTMLOutput(VisualizerInput input, Writer writer, TreeSet JSONObject govs = new JSONObject(); List> sEdges = node.getGraph().getInRelations(node.getId()); + + // if root edges are determined by node labels, this needs to be checked here + String node_label = nodeRootQname == null? null : node.getAnnotation(nodeRootQname).getValue_STEXT(); + if ((node_label != null) && (node_label.equals(mappings.get(MAPPING_ROOT_LABEL)))) { + govs.put("root", node_label); + } for (SRelation e : sEdges) { if (e instanceof SPointingRelation) { @@ -232,8 +249,8 @@ public void printHTMLOutput(VisualizerInput input, Writer writer, TreeSet String label = sRelation.getAnnotations().stream().findFirst() .map(SAnnotation::getValue_STEXT).orElse(""); - - if (label != null && label.equals(mappings.get(MAPPING_ROOT_LABEL))) { + + if ((nodeRootQname == null) && (label.equals(mappings.get(MAPPING_ROOT_LABEL)))) { govs.put("root", label); } else if (sRelation.getSource() != null && node2Int.containsKey(source)) {