Search in sources :

Example 11 with Node

use of gate.Node in project gate-core by GateNLP.

the class AnnotationSetImpl method inDocumentOrder.

/**
 * Return a list of annotations sorted by increasing start offset, i.e. in the order
 * they appear in the document. If more than one annotation starts at a specific offset
 * the order of these annotations is unspecified.
 *
 * @return a list of annotations ordered by increasing start offset. If a positional
 * index does not exist, it is created.
 */
@Override
public List<Annotation> inDocumentOrder() {
    if (annotsByStartNode == null)
        indexByStartOffset();
    Collection<Node> values = nodesByOffset.values();
    List<Annotation> result = new ArrayList<Annotation>();
    for (Node nodeObj : values) {
        Collection<Annotation> anns = getAnnotsByStartNode(nodeObj.getId());
        if (anns != null) {
            result.addAll(anns);
        }
    }
    return result;
}
Also used : Node(gate.Node) ArrayList(java.util.ArrayList) Annotation(gate.Annotation)

Aggregations

Node (gate.Node)11 Annotation (gate.Annotation)10 ArrayList (java.util.ArrayList)6 AnnotationSet (gate.AnnotationSet)2 FeatureMap (gate.FeatureMap)1 RelationSet (gate.relations.RelationSet)1 InvalidOffsetException (gate.util.InvalidOffsetException)1 RBTreeMap (gate.util.RBTreeMap)1 IOException (java.io.IOException)1 ObjectInputStream (java.io.ObjectInputStream)1 AbstractSet (java.util.AbstractSet)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1