Search in sources :

Example 21 with AnnisNode

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

Example 22 with AnnisNode

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

Example 23 with AnnisNode

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

Example 24 with AnnisNode

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("}");
}
Also used : AnnisNode(annis.model.AnnisNode) Edge(annis.model.Edge) LinkedList(java.util.LinkedList)

Example 25 with AnnisNode

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;
}
Also used : AnnotationGraph(annis.model.AnnotationGraph) DirectedGraph(edu.uci.ics.jung.graph.DirectedGraph) ArrayList(java.util.ArrayList) AnnisNode(annis.model.AnnisNode) LinkedList(java.util.LinkedList) Comparator(java.util.Comparator)

Aggregations

AnnisNode (annis.model.AnnisNode)38 Annotation (annis.model.Annotation)10 Edge (annis.model.Edge)9 LinkedList (java.util.LinkedList)8 HashMap (java.util.HashMap)7 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 Map (java.util.Map)5 AnnotationGraph (annis.model.AnnotationGraph)4 AnnisResult (annis.service.ifaces.AnnisResult)4 DetectHoles (annis.visualizers.iframe.partitur.DetectHoles)2 DocumentNameMapRow (annis.dao.DocumentNameMapRow)1 MatchedNodeColors (annis.libgui.MatchedNodeColors)1 RelannisEdgeFeature (annis.model.RelannisEdgeFeature)1 RelannisNodeFeature (annis.model.RelannisNodeFeature)1 AnnisToken (annis.service.ifaces.AnnisToken)1 Match (annis.service.objects.Match)1 MatchGroup (annis.service.objects.MatchGroup)1 ArrayCorpusPathExtractor (annis.sqlgen.ArrayCorpusPathExtractor)1 CorpusPathExtractor (annis.sqlgen.CorpusPathExtractor)1