private static String annotatateContent ( JCas jcas , Object contentObj , int start ) { LOG . trace ( "annotate: " + reflectionToString ( contentObj ) ) ; int end = start ; StringBuilder internalSb = new StringBuilder ( ) ; if ( contentObj instanceof String ) { String c = ( String ) contentObj ; internalSb . append ( c ) ; end += c . length ( ) ; } else if ( contentObj instanceof Cons ) { Cons cons = ( Cons ) contentObj ; for ( Object o : cons . getContent ( ) ) { String parse = annotatateContent ( jcas , o , end ) ; end += parse . length ( ) ; internalSb . append ( parse ) ; } BioEntityMention entity = new BioEntityMention ( jcas , start , end ) ; entity . setSpecificType ( cons . getSem ( ) ) ; entity . setComponentId ( GeniaCorpusCollectionReader . COMPONENT_ID ) ; entity . setTextualRepresentation ( cons . getLex ( ) ) ; entity . addToIndexes ( ) ; } return internalSb . toString ( ) ; }
Recursive since annotations can overlap