ctakes-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Finan, Sean" <Sean.Fi...@childrens.harvard.edu>
Subject RE: Delete an OntologyConcept from a JCas using an Annotator
Date Thu, 07 Apr 2016 23:34:12 GMT
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.


-----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

    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);

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?


View raw message