2

I have a GATE document with a string like that:

The running back Ezekiel Elliott sprinted and rumbled etc.

I want to annotate this whole string with a text annotation. I'm looking for a JAPE rule but really don't know how to annotate the whole document using the start and end of the string like that: enter image description here

  • It's also possible to do it by creating a new GATE PR and using this JAVA code: `AnnotationSet inputAs = document.getAnnotations(inputASName); AnnotationSet outputAs = document.getAnnotations(outputASName); long startOffset = inputAs.firstNode().getOffset(); long endOffset = inputAs.lastNode().getOffset(); try { outputAs.add(startOffset,endOffset,"Tweet", features); } catch (InvalidOffsetException e) { // TODO Auto-generated catch block e.printStackTrace(); }` – Chester Mc Allister Jan 15 '15 at 15:35
  • But if you use `long startOffset = inputAs.firstNode().getOffset(); long endOffset = inputAs.lastNode().getOffset();` then the output would be dependent on the content of `inputAs`. It will **not annotate the whole document** but the whole `inputAs` only. And it fails for `NullPointerException` when the `inputAs` is empty. – dedek Mar 16 '15 at 07:40

2 Answers2

3

I do not recommend using JAPE for this task, because there are no input annotations to start with. But you can do it easily with Groovy scripting PR

outputAS.add(0L, doc.content.size(), "Text", gate.Utils.featureMap())
dedek
  • 7,981
  • 3
  • 38
  • 68
1

You can use doc.getFeatures().put() method to add new features to a document. For example, below lines of code give a field category and score for the document.

doc.getFeatures().put("category","fiction");
doc.getFeatures().put("score",13);

Refer to this slide set. It tells us how to use JAPE to use document features.

https://gate.ac.uk/sale/talks/gate-course-may11/track-3/module-10-advanced-ie/module-10-advanced-ie.pdf

pnv
  • 1,437
  • 3
  • 23
  • 52
  • 1
    This is not the answer of my question. This response provides new features for the document but what I need is to add annotation to the document. – Chester Mc Allister Feb 17 '15 at 20:36