public Pair < CoreMap , GrammaticalStructure > parseForCoref ( String sentence ) { List < CoreLabel > tokens = stanfordTokenize ( sentence ) ; Tree tree = parser . parse ( tokens ) ; GrammaticalStructure gs = tagDependencies ( tree , true ) ; tagPOS ( tokens ) ; tagLemma ( tokens ) ; tagNamedEntity ( tokens ) ; CoreMap result = new ArrayCoreMap ( ) ; result . set ( CoreAnnotations . TokensAnnotation . class , tokens ) ; result . set ( TreeCoreAnnotations . TreeAnnotation . class , tree ) ; GrammaticalStructure . Extras extras = GrammaticalStructure . Extras . NONE ; SemanticGraph deps = SemanticGraphFactory . generateCollapsedDependencies ( gs , extras ) ; SemanticGraph uncollapsedDeps = SemanticGraphFactory . generateUncollapsedDependencies ( gs , extras ) ; SemanticGraph ccDeps = SemanticGraphFactory . generateCCProcessedDependencies ( gs , extras ) ; result . set ( SemanticGraphCoreAnnotations . CollapsedDependenciesAnnotation . class , deps ) ; result . set ( SemanticGraphCoreAnnotations . BasicDependenciesAnnotation . class , uncollapsedDeps ) ; result . set ( SemanticGraphCoreAnnotations . CollapsedCCProcessedDependenciesAnnotation . class , ccDeps ) ; return new ImmutablePair <> ( result , gs ) ; }
This is for coref using .