AnandOCF
AnandOCF

Reputation: 416

Get text of Annotations

I am working on Information extraction in GATE embeded.I have tried the following code to get the text from the Annotations:

AnnotationSet annotationSet = doc.getAnnotations().get("Person");  
DocumentContent   personStr = annotationSet .getContent();

But the get.Content is unable to work in the annotation type. So how can we get the text which is annotated. Thanks in advance

Upvotes: 1

Views: 328

Answers (2)

ashingel
ashingel

Reputation: 494

I think that gate.Utils.stringFor(doc, personAnnotation) is what you are looking for. Where personAnnotation is a single annotation from your annotationSet.

Upvotes: 1

dedek
dedek

Reputation: 8311

@ashingel 's answer is correct, just adding code snippet, how to use it:

AnnotationSet annotationSet = doc.getAnnotations().get("Person");  
for (Annotation annotation : annotationSet) {
    String personStr = gate.Utils.stringFor(doc, annotation);
    System.out.println(personStr);
}

Upvotes: 1

Related Questions