stanford-nlp - 字符串与斯坦福 NLP Word 之间的转换
问题描述
我正在尝试使用斯坦福核心 NLP 的 Stemmer 类(https://github.com/stanfordnlp/CoreNLP/blob/master/src/edu/stanford/nlp/process/Stemmer.java)进行词干提取。
我正在尝试从另一个类中调用词干分析器方法(我对其进行了一些编辑),如下所示,请注意这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
从其他类调用时提供字符串。有没有办法将提供的字符串转换为Word
?
解决方案
阅读Word
类的代码,它似乎支持String
它的构造函数,所以我相信你只需要做
Word(token.stem())
获取词干标记的单词对象。
推荐阅读
- r - 使用 dplyr 将未来日期替换为 NA
- bash - 使用 SFTP 获取动态日期文件?
- php - 如何检查特定 ID 是否存在于另一个表中?
- jmeter - 在 jmeter 中设置整个请求 url
- c# - Identity Manager SignOutAsync 会话在服务器端仍然有效
- android - 将 Firebase 与 Kotlin 协程一起使用
- algorithm - 填充网格的最小矩形区域数
- javascript - $(window).width() 和滚动的问题
- javascript - 根据重叠的部分切换汉堡菜单背景
- bash - Telnet smtp 命令 bash 2.05 脚本问题