Is there a way to process an already POS-tagged text using Stanford CoreNLP?
For example, I have the sentence in this format
They_PRP are_VBP hunting_VBG dogs_NNS ._.
and I'd like to annotate with lemma, ner, parse, etc. by forcing the given POS annotation.
Update. I tried this code, but it's not working.
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
String sentText = "They_PRP are_VBP hunting_VBG dogs_NNS ._.";
List<CoreLabel> sentence = new ArrayList<>();
String[] parts = sentText.split("\\s");
for (String p : parts) {
String[] split = p.split("_");
CoreLabel clToken = new CoreLabel();
clToken.setValue(split[0]);
clToken.setWord(split[0]);
clToken.setOriginalText(split[0]);
clToken.set(CoreAnnotations.PartOfSpeechAnnotation.class, split[1]);
sentence.add(clToken);
}
Annotation s = new Annotation(sentText);
s.set(CoreAnnotations.TokensAnnotation.class, sentence);
Annotation document = new Annotation(s);
pipeline.annotate(document);