Search code examples
javanlpgate

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


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"?


Solution

  • 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: