Utility Methods

Here are some Utility methods for working with Documents and Annotations

API

Access start and end offsets of Document, AnnotationSet, Annotations

anAnnotationSet.start();

anAnnotation.end();

Access the string covered by Annotation(s)

Document.stringFor(anAnnotation);

Document.stringFor(anAnnotationSet);

The Length of an Annotation

public int length();
//e.g.
anAnnotation.length();

public long lengthLong();

Turn maps into FeatureMaps

def params = [sourceUrl:http://gate.ac.uk’, encoding:’UTF-8’].toFeatureMap()

Convert AnnotationSet to a list of ordered annotations.

For predictable iteration

Interesting Access

// get all tokens in the set.
anAnnotationSet["Token"]

// get all annotions at the offsets
anAnnotationSet[8..15];

adocumentContent[4..13];