Is it possible to retrieve the entire list of named AnnotationSets in GATE?

136 Views Asked by At

is it possible to retrieve the entire list of an Annotation Set in GATE? This line of code returns all the items of a GATE document that belong to the AnnotationSet called "EMail";

AnnotationSet annSet = doc.getAnnotations().get("EMail");

Now, how can I know all of the Annotations' Set names instead of the only "EMail"?

2

There are 2 best solutions below

0
dedek On BEST ANSWER

Isn't this the answer to your question:

AnnotationSet annSet = doc.getAnnotations();

I think you mix two different terms: annotation set and annotation type. Be careful about these two...

There are several methods of gate.Document and gate.AnnotationSet that can be used:

  • gate.Document.getAnnotations()
    ... all annotations from the default (without name) annotation set.
  • gate.Document.getAnnotations(String setName)
    ... all annotations from named annotation set with name setName.
  • gate.AnnotationSet.get(String anntoationType)
    ... select only annotations with given anntoationType.
  • gate.Document.getAnnotationSetNames()
    ... get all the names of named annotation sets in a document
  • gate.AnnotationSet.getAllTypes()
    ... get set of all annotation type names of annotations present in given annotation set.

See more details in javadoc:

0
AdamF On
Document doc;
// create/manipulate the document...

Set<String> names = doc.getAnnotationSetNames();
Map<String, AnnotationSet> namedAnnSets = doc.getNamedAnnotationSets();

// The default AS always exists
AnnotationSet defaultAS = doc.getAnnotations();

Note that a GATE document always has a default (unnamed) annotation set, which is not included in the set of names or map of named sets.