private void annotate ( Parse parse , JCas cas , Constituent parent ) throws SecurityException , IllegalArgumentException , ClassNotFoundException , NoSuchMethodException , InstantiationException , IllegalAccessException , InvocationTargetException { Constituent cons = null ; Span span = parse . getSpan ( ) ; String label = parse . getType ( ) ; String labelCat ; String [ ] funCatlabels = null ; if ( ! label . equals ( ParserME . TOK_NODE ) ) { int start = offsetMap . getMapping ( span . getStart ( ) ) ; int end = offsetMap . getMapping ( span . getEnd ( ) ) ; if ( fun == true && label . contains ( "-" ) ) { funCatlabels = label . split ( "-" ) ; labelCat = funCatlabels [ 0 ] ; } else labelCat = label ; String casLabel = mapTable . get ( labelCat ) ; // if there is mapping between OpenNLP Parser constituent label and // CAS label if ( casLabel != null ) { cons = ( Constituent ) AnnotationTools . getAnnotationByClassName ( cas , tagSet ) ; cons . setBegin ( start ) ; cons . setEnd ( end ) ; cons . setComponentId ( COMPONENT_ID ) ; cons . setCat ( casLabel ) ; Class c = cons . getClass ( ) ; makeFunAnnotations ( cons , funCatlabels ) ; if ( parent != null ) cons . setParent ( parent ) ; cons . addToIndexes ( ) ; } Parse [ ] children = parse . getChildren ( ) ; for ( int i = 0 ; i < children . length ; i ++ ) { annotate ( children [ i ] , cas , cons ) ; } } }
provide annotations from Parse result to CAS object