在这个问题之后,我正在尝试使用 stanford corenlp 进行词形还原 。我的环境是:-
- Java 1.7
- 日食 3.4.0
- StandfordCoreNLP 3.4.1 版(从这里下载)。
我的代码片段是:-
//...........lemmatization starts........................
Properties props = new Properties();
props.put("annotators", "tokenize, ssplit, pos, lemma");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props, false);
String text = "painting";
Annotation document = pipeline.process(text);
List<edu.stanford.nlp.util.CoreMap> sentences = document.get(SentencesAnnotation.class);
for(edu.stanford.nlp.util.CoreMap sentence: sentences)
{
for(CoreLabel token: sentence.get(TokensAnnotation.class))
{
String word = token.get(TextAnnotation.class);
String lemma = token.get(LemmaAnnotation.class);
System.out.println("lemmatized version :" + lemma);
}
}
//...........lemmatization ends.........................
我得到的输出是: -
lemmatized version :painting
我期望的地方
lemmatized version :paint
请赐教。