Search in sources :

Example 31 with Annotation

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;
}
Also used : AnnisToken(annis.service.ifaces.AnnisToken) ArrayList(java.util.ArrayList) AnnisNode(annis.model.AnnisNode) Annotation(annis.model.Annotation)

Example 32 with Annotation

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");
}
Also used : AnnisNode(annis.model.AnnisNode) MatchedNodeColors(annis.libgui.MatchedNodeColors) Annotation(annis.model.Annotation)

Example 33 with Annotation

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);
        }
    }
}
Also used : AnnisNode(annis.model.AnnisNode) Annotation(annis.model.Annotation)

Example 34 with Annotation

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");
}
Also used : Annotation(annis.model.Annotation)

Example 35 with Annotation

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("\"", "\\\""));
        }
    }
}
Also used : Annotation(annis.model.Annotation)

Aggregations

Annotation (annis.model.Annotation)43 ArrayList (java.util.ArrayList)13 LinkedList (java.util.LinkedList)12 HashMap (java.util.HashMap)11 AnnisNode (annis.model.AnnisNode)10 AnnotatedSpan (annis.dao.objects.AnnotatedSpan)6 Test (org.junit.Test)6 AnnotatedMatch (annis.dao.objects.AnnotatedMatch)5 List (java.util.List)5 Map (java.util.Map)5 TreeMap (java.util.TreeMap)5 SAnnotation (org.corpus_tools.salt.core.SAnnotation)5 AnnisResult (annis.service.ifaces.AnnisResult)4 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)4 WebResource (com.sun.jersey.api.client.WebResource)4 Array (java.sql.Array)4 SNode (org.corpus_tools.salt.core.SNode)4 ClientHandlerException (com.sun.jersey.api.client.ClientHandlerException)3 SToken (org.corpus_tools.salt.common.SToken)3 AnnotationGraph (annis.model.AnnotationGraph)2