use of annis.model.AnnisNode in project ANNIS by korpling.
the class ProielDependecyTree method writeNode.
private void writeNode(AnnisNode n, String word) {
String shape = "box";
String id = "" + n.getId();
String fillcolor = "#ffffff";
String fontcolor = "black";
String style = "filled";
String label = "";
// get pos annotation
String posAnno = "";
for (Annotation anno : n.getNodeAnnotations()) {
if ("tiger".equals(anno.getNamespace()) && "pos".equals(anno.getName()) && anno.getValue() != null) {
posAnno = anno.getValue();
}
}
if (isEmptyNode(word)) {
if (isRootNode(n)) {
shape = "circle";
} else {
if (posAnno.length() > 0) {
// decide which pos to use
switch(posAnno.charAt(0)) {
case 'V':
shape = "circle";
label = posAnno;
break;
case 'C':
shape = "diamond";
label = posAnno;
break;
case 'P':
shape = "hexagon";
label = posAnno;
break;
default:
shape = "circle";
label = posAnno;
break;
}
}
}
} else {
// is coordinator?
if ("C-".equals(posAnno)) {
shape = "diamond";
}
label = word;
}
// check coloring
String matchColorAsString = input.getMarkableExactMap().get(Long.toString(n.getId()));
if (matchColorAsString == null) {
// check if there mighte be a matching token that is directly belonging to
// this "fake" token node
AnnisNode token = getCorrespondingRealToken(n);
if (token != null) {
matchColorAsString = input.getMarkableExactMap().get(Long.toString(token.getId()));
}
}
if (matchColorAsString != null) {
MatchedNodeColors matchColor = MatchedNodeColors.valueOf(matchColorAsString);
fillcolor = matchColor.getHTMLColor();
}
// write out the node
w(id);
w(" [");
wAtt("fontcolor", fontcolor);
wAtt("shape", shape);
wAtt("fillcolor", fillcolor);
wAtt("style", style);
wAtt("label", label);
w("];\n");
}
use of annis.model.AnnisNode in project ANNIS by korpling.
the class ProielRegularDependencyTree method writeAllRealToken.
private void writeAllRealToken() {
// Token are in a subgraph
w(" {\n \trank=max;\n");
for (AnnisNode n : input.getResult().getGraph().getTokens()) {
realToken.add(n);
writeToken(n);
}
writeInvisibleTokenEdges(realToken);
w(" }\n");
}
use of annis.model.AnnisNode in project ANNIS by korpling.
the class ProielRegularDependencyTree method writeEdge.
private void writeEdge(Edge e) {
AnnisNode srcNode = e.getSource();
AnnisNode destNode = e.getDestination();
if (e.getName() == null || srcNode == null || destNode == null) {
return;
} else {
String srcId = "" + srcNode.getId();
String destId = "" + destNode.getId();
// get the edge annotation
StringBuilder sbAnno = new StringBuilder();
boolean first = true;
for (Annotation anno : e.getAnnotations()) {
if (!first) {
sbAnno.append("\\n");
}
first = false;
sbAnno.append(anno.getValue());
}
String style = "solid";
if ("secedge".equals(e.getName())) {
style = "dashed";
}
String edgeString = srcId + " -> " + destId + "[shape=none, label=\"" + sbAnno.toString() + "\" style=\"" + style + "\"];\n";
if (!alreadyWrittenEdge.contains(edgeString)) {
w(edgeString);
alreadyWrittenEdge.add(edgeString);
}
}
}
use of annis.model.AnnisNode in project ANNIS by korpling.
the class DotGraphVisualizer method internalCreateDot.
private void internalCreateDot() {
w("digraph G {\n");
w("\tnode [shape=box];\n");
// node definitions
List<AnnisNode> token = new LinkedList<AnnisNode>();
for (AnnisNode n : input.getResult().getGraph().getNodes()) {
if (n.isToken()) {
token.add(n);
} else {
if (testNode(n)) {
writeNode(n);
}
}
}
// Token are in a subgraph
w("\t{\n" + "\trank=max;\n");
for (AnnisNode tok : token) {
w("\t");
writeNode(tok);
}
writeInvisibleTokenEdges(token);
w("\t}\n");
for (Edge e : input.getResult().getGraph().getEdges()) {
if (e != null && testEdge(e)) {
writeEdge(e);
}
}
w("}");
}
use of annis.model.AnnisNode in project ANNIS by korpling.
the class AnnisGraphTools method getSyntaxGraphs.
public List<DirectedGraph<AnnisNode, Edge>> getSyntaxGraphs() {
AnnotationGraph ag = input.getResult().getGraph();
String namespace = input.getMappings().getProperty("node_ns", input.getNamespace());
String terminalName = input.getMappings().getProperty(TigerTreeVisualizer.TERMINAL_NAME_KEY);
String terminalNamespace = input.getMappings().getProperty(TigerTreeVisualizer.TERMINAL_NS_KEY);
List<DirectedGraph<AnnisNode, Edge>> resultGraphs = new ArrayList<>();
List<AnnisNode> rootNodes = new LinkedList<>();
for (AnnisNode n : ag.getNodes()) {
if (isRootNode(n, namespace)) {
rootNodes.add(n);
}
}
// sort root nodes according to their left-most covered token
HorizontalOrientation orientation = detectLayoutDirection(ag);
if (orientation == HorizontalOrientation.LEFT_TO_RIGHT) {
Collections.sort(rootNodes, new Comparator<AnnisNode>() {
@Override
public int compare(AnnisNode o1, AnnisNode o2) {
return Long.compare(o1.getLeftToken(), o2.getLeftToken());
}
});
} else if (orientation == HorizontalOrientation.RIGHT_TO_LEFT) {
Collections.sort(rootNodes, new Comparator<AnnisNode>() {
@Override
public int compare(AnnisNode o1, AnnisNode o2) {
return Long.compare(o2.getLeftToken(), o1.getLeftToken());
}
});
}
for (AnnisNode r : rootNodes) {
resultGraphs.add(extractGraph(ag, r, terminalNamespace, terminalName));
}
return resultGraphs;
}
Aggregations