/**
  * Rename annotation
  *
  * @param outputAS output annotation set
  * @param oldType old annotation name
  * @param newType new annotation name
  */
 private void renameAnnotations(AnnotationSet outputAS, String oldType, String newType) {
   AnnotationSet tmpAnatomyAS = outputAS.get(oldType);
   for (Annotation tmpAnn : tmpAnatomyAS) {
     Long startOffset = tmpAnn.getStartNode().getOffset();
     Long endOffset = tmpAnn.getEndNode().getOffset();
     AnnotationSet existingAS = outputAS.getCovering(newType, startOffset, endOffset);
     // If we've already got an annotation of the same name in the same place, don't add a new one
     // just delete the old one
     if (existingAS.isEmpty()) {
       FeatureMap tmpFm = tmpAnn.getFeatures();
       FeatureMap fm = Factory.newFeatureMap();
       fm.putAll(tmpFm);
       try {
         outputAS.add(startOffset, endOffset, newType, fm);
         outputAS.remove(tmpAnn);
       } catch (InvalidOffsetException ie) {
         // shouldn't happen
       }
     } else {
       outputAS.remove(tmpAnn);
     }
   }
 }
  public void doit(
      gate.Document doc,
      Map<String, AnnotationSet> bindings,
      gate.AnnotationSet annotations,
      gate.AnnotationSet inputAS,
      gate.AnnotationSet outputAS,
      gate.creole.ontology.Ontology ontology)
      throws JapeException {
    // your RHS Java code will be embedded here ...
    String category = (String) doc.getFeatures().get("category");
    Annotation mention = tagAnnots.iterator().next();
    String pName = (String) mention.getFeatures().get("class");

    OntoManager om = OntoManager.getInstance();
    ProductClass catClass = om.getProductClass(category);
    ProductClass pClass = om.getProductClass(pName);
    boolean sameCat =
        pClass
            .getOntClass()
            .hasSuperClass(catClass.getOntClass()); // TODO: refactor to used direct method
    if (!sameCat) {
      outputAS.remove(mention);
    }
  }