Search code examples
gatetransducer

Remove unwanted annotation label using JAPE in GATE developer


I wanted a JAPE which on execute will return Annotation list which only sounds meaning to my requirement. Like I do not want SpaceToken, Sentence, Token, Lookup etc. implicit in my Annotation. As this Jape will be in last of Application sequence and it does not require any thing to match in LHS( as far my understanding, CMIIW ), is there any way we can have only RHS code)

Phase: filteAnnot
Input: token 
Options: control = appelt

Rule: filteAnnot
Priority: 50
-->
:label{
 [My Logical Stuff of removing annotations]
}

Solution

  • First of all, you probably don't need to delete the annotations. Usually when you're embedding GATE you'll call a pipeline and then delete the document anyways.

    If you need to clear the default Annotation Set you can run an "Annotation Set Transfer PR" to move your valuable annotations to a different AS and then "Document Reset PR" to clear the default AS. Or if you don't have that many annotation types, just use "Document Reset PR" and add the types to its "annotationTypes" parameter.

    You can also write a groovy script PR to remove annotations:

    inputAS.findAll{
      it.type != "MyAnnotation"
    }.each{ ann ->
      outputAS.remove(ann); // probably removeAll would be simpler
    }