String和Stanford NLP Word之间的转换

问题描述 投票:1回答:1

我正在尝试使用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

stanford-nlp stemming
1个回答
1
投票

阅读Word类的代码,它似乎支持String的构造函数所以我相信你只需要做

Word(token.stem())

获取词干标记的单词对象。

© www.soinside.com 2019 - 2024. All rights reserved.