我正在尝试使用Stanford Core NLP的Stemmer类(https://github.com/stanfordnlp/CoreNLP/blob/master/src/edu/stanford/nlp/process/Stemmer.java)进行干预。
我试图从另一个类调用stemmer方法(我编辑了一点),如下所示,请注意term
是一个字符串:
String stemmedterm=CoreNLPKeyPhraseStemmer.keystemming(term);
CoreNLPKeyPhraseStemmer的keystemming
方法中的主要工作是通过以下行完成的:
String s1= s.stem(token.word());
但是,我的问题是token
的类型必须是Word
ieedu.stanford.nlp.ling.Word(https://nlp.stanford.edu/nlp/javadoc/javanlp/index.html?edu/stanford/nlp/ling/Word.html),而我在从其他类调用keystemming
时提供String。有没有办法将提供的String转换为Word
?
阅读Word
类的代码,它似乎支持String
的构造函数所以我相信你只需要做
Word(token.stem())
获取词干标记的单词对象。