ctakes-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tomasz Oliwa <ol...@uchicago.edu>
Subject RE: Delete an OntologyConcept from a JCas using an Annotator
Date Fri, 08 Apr 2016 18:37:05 GMT
Sean,

This does the trick, thanks.

Regards,
Tomasz

________________________________________
From: Finan, Sean [Sean.Finan@childrens.harvard.edu]
Sent: Thursday, April 07, 2016 6:34 PM
To: dev@ctakes.apache.org
Subject: RE: Delete an OntologyConcept from a JCas using an Annotator

Hi Tomasz,

Just in case nobody has a better answer: I think that you might need to may a new array at
size n-1 , then copy all ontology concepts that you do want, then set the annotation's ontology
concept array to be the new one.

Sean

-----Original Message-----
From: Tomasz Oliwa [mailto:oliwa@uchicago.edu]
Sent: Thursday, April 07, 2016 6:16 PM
To: dev@ctakes.apache.org
Subject: Delete an OntologyConcept from a JCas using an Annotator

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