ctakes-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tomasz Oliwa <ol...@uchicago.edu>
Subject Delete an OntologyConcept from a JCas using an Annotator
Date Thu, 07 Apr 2016 22:15:48 GMT
How can I delete an OntologyConcept from a JCas using an Annotator? 

As an example, the following process method from an Annotator loops over all IdentifiedAnnotations,
and is supposed to simply remove all OntologyConcepts. However, it does not remove anything
from the CAS. I can still see all OntologyConcepts in the CAS Visual Debugger after running
it.

    public void process(JCas aJCas) throws AnalysisEngineProcessException {
        JFSIndexRepository indexes = aJCas.getJFSIndexRepository();
        Iterator neItr = indexes.getAnnotationIndex(IdentifiedAnnotation.type).iterator();
        while (neItr.hasNext()) {
            IdentifiedAnnotation neAnnot = (IdentifiedAnnotation) neItr.next();
            FSArray ocArr = neAnnot.getOntologyConceptArr();
            if (ocArr != null) {
                for (int i = 0; i < ocArr.size(); i++) {
                    OntologyConcept oc = (OntologyConcept) ocArr.get(i);
                    oc.removeFromIndexes(aJCas);
                    aJCas.removeFsFromIndexes(oc);
                }
            }            
        }
    }

If I change the code above to do neAnnot.removeFromIndexes(aJCas); to remove the whole IdentifiedAnnotation,
this works and the annotation is removed and not displayed in the CAS Visual Debugger. 

But how can I remove OntologyConcepts? 

Am I missing an API call? Does the API have a problem here?

Regards,
Tomasz
Mime
View raw message