Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
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.Comparator;
Expand All @@ -24,6 +23,7 @@
import java.util.Map;
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;
Expand All @@ -44,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.
Expand All @@ -55,7 +57,12 @@
*
* Mappings: <br />
* If a annotation key is specified with <b>node_key:key</b>, 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. <br />
* If root edges should be display, this can be achieved by setting <b>root_label</b> to the edge label
* value that identifies root edges. This, of course, requires these edges to exist.<br />
* If the label for root edges is actually contained in a node annotation, the key for the node annotation
* needs to be provided <i>additionally</i> by setting <b>root_label_node_key</b> to the respective qualified
* annotation name.
*
* @author Thomas Krause {@literal <krauseto@hu-berlin.de>}
* @author Benjamin Weißenfels{@literal <b.pixeldrama@gmail.com>}
Expand All @@ -77,6 +84,16 @@
* 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";

Check warning on line 91 in src/main/java/org/corpus_tools/annis/gui/visualizers/iframe/dependency/VakyarthaDependencyTree.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this final field static too.

See more on https://sonarcloud.io/project/issues?id=korpling_ANNIS&issues=AaG8FebsTyWH8afV1vCm&open=AaG8FebsTyWH8afV1vCm&pullRequest=921

Check warning on line 91 in src/main/java/org/corpus_tools/annis/gui/visualizers/iframe/dependency/VakyarthaDependencyTree.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "MAPPING_ROOT_LABEL" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=korpling_ANNIS&issues=AaG8FebsTyWH8afV1vCl&open=AaG8FebsTyWH8afV1vCl&pullRequest=921
/**
* 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<String, String> mappings;

Expand Down Expand Up @@ -142,11 +159,10 @@
}
}


Map<SNode, Integer> node2Int = new HashMap<SNode, Integer>();
int count = 0;
for (SNode tok : selectedNodes) {
node2Int.put(tok, count++);
node2Int.put(tok, count++);
}


Expand Down Expand Up @@ -180,6 +196,8 @@
println("tokens=new Object();", writer);

count = 0;
String nodeRootQname = mappings.get(MAPPING_ROOT_LABEL_NODE_KEY);

for (SNode node : selectedNodes) {
JSONObject vakyarthaObject = new JSONObject();

Expand All @@ -199,6 +217,12 @@

JSONObject govs = new JSONObject();
List<SRelation<SNode, SNode>> 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();

Check warning on line 222 in src/main/java/org/corpus_tools/annis/gui/visualizers/iframe/dependency/VakyarthaDependencyTree.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=korpling_ANNIS&issues=AaHKG8BUzms-rf9Kr_S8&open=AaHKG8BUzms-rf9Kr_S8&pullRequest=921
if ((node_label != null) && (node_label.equals(mappings.get(MAPPING_ROOT_LABEL)))) {
govs.put("root", node_label);
}

for (SRelation<? extends SNode, ? extends SNode> e : sEdges) {
if (e instanceof SPointingRelation) {
Expand All @@ -225,8 +249,11 @@

String label = sRelation.getAnnotations().stream().findFirst()
.map(SAnnotation::getValue_STEXT).orElse("");

if (sRelation.getSource() != null && node2Int.containsKey(source)) {

if ((nodeRootQname == 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);
}
}
Expand Down
Loading