use of annis.model.Annotation in project ANNIS by korpling.
the class AnnisResultImpl method getTokenList.
public List<AnnisToken> getTokenList() {
List<AnnisToken> result = new ArrayList<AnnisToken>();
for (AnnisNode node : graph.getTokens()) {
AnnisTokenImpl annisToken = new AnnisTokenImpl(node.getId(), node.getSpannedText(), node.getLeft(), node.getRight(), node.getTokenIndex(), node.getCorpus());
for (Annotation annotation : node.getNodeAnnotations()) {
annisToken.put(annotation.getQualifiedName(), annotation.getValue());
}
result.add(annisToken);
}
return result;
}
use of annis.model.Annotation 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.Annotation 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.Annotation in project ANNIS by korpling.
the class DotGraphVisualizer method writeEdge.
private void writeEdge(Edge edge) {
// from -> to
w("\t");
w("" + (edge.getSource() == null ? "null" : edge.getSource().getId()));
w(" -> ");
w("" + (edge.getDestination() == null ? "null" : edge.getDestination().getId()));
// attributes
w(" [");
if (edge.getEdgeType() == Edge.EdgeType.POINTING_RELATION) {
w(" style=dashed color=green ");
} else if (edge.getEdgeType() == Edge.EdgeType.COVERAGE) {
w(" style=dotted color=orange ");
}
// label
w("label=\"");
w(edge.getNamespace());
w(".");
w(edge.getName());
w("\\n");
Iterator<Annotation> itAnno = edge.getAnnotations().iterator();
while (itAnno.hasNext()) {
Annotation anno = itAnno.next();
w(anno.getQualifiedName());
w("=");
w(anno.getValue());
if (itAnno.hasNext()) {
w("\\n");
}
}
w("\"");
w("];\n");
}
use of annis.model.Annotation in project ANNIS by korpling.
the class DotGraphVisualizer method appendNodeAnnotations.
private void appendNodeAnnotations(AnnisNode node) {
for (Annotation anno : node.getNodeAnnotations()) {
if (displayAllNamespaces || requiredNodeNS.equals(anno.getNamespace())) {
w("\\n");
w(anno.getQualifiedName());
w("=");
w(anno.getValue().replace("\"", "\\\""));
}
}
}
Aggregations