1

I'm trying to extract the individual text values of an annotation set which are generated by the default ANNIE processing resources.

When i iterate through the annotation set each entry only gives the start and end position which the annotation references but does not give a .value() method. Is there an easy way to get the value or do i need to use a FileWriter or some equivalent to extract the value directly from the Corpus I'm processing using the start and end positions of the annotation?

annotTypesRequired.add("Location");

Set<Annotation> organization = new HashSet<Annotation>(
                defaultAnnotSet.get(annotTypesRequired));
cdugga
  • 3,849
  • 17
  • 81
  • 127
  • Something like: `gate.AnnotationSet entityAS = (gate.AnnotationSet)bindings.get("entity"); gate.Annotation entityAnn = (gate.Annotation)entityAS.iterator().next(); gate.FeatureMap features = Factory.newFeatureMap(); features.put("type", entityAnn.getType());outputAS.add(entityAnn.getStartNode(), entityAnn.getEndNode(), "Entity“, features);` – Benjamin Gruenbaum Feb 08 '14 at 15:32

1 Answers1

6

If by "the value" you mean the text that the annotation covers, you can access that using

gate.Utils.stringFor(document, annotation)

For this you obviously need a reference to the gate.Document that the annotation belongs to, as well as the Annotation object itself - annotations do not routinely store their covered string directly, they just store offsets that point into the document's content.

Ian Roberts
  • 120,891
  • 16
  • 170
  • 183
  • 1
    The method `gate.Utils.stringFor` has been very useful to me in order to access to the _meta-property_ `@string` of a Lookup annotation. – enzom83 Jun 15 '16 at 13:04