public static void annotateChunkTokens ( CoreMap chunk , Class tokenChunkKey , Class tokenLabelKey ) { List < CoreLabel > chunkTokens = chunk . get ( CoreAnnotations . TokensAnnotation . class ) ; if ( tokenLabelKey != null ) { String text = chunk . get ( CoreAnnotations . TextAnnotation . class ) ; for ( CoreLabel t : chunkTokens ) { t . set ( tokenLabelKey , text ) ; } } if ( tokenChunkKey != null ) { for ( CoreLabel t : chunkTokens ) { t . set ( tokenChunkKey , chunk ) ; } } }
Annotates tokens in chunk