问题描述
我正在一个 Java 应用程序中处理一些英文文本,我需要对它们进行词干处理.例如,从文本amenities/amenity"我需要得到amenit".
I'm processing some English texts in a Java application, and I need to stem them. For example, from the text "amenities/amenity" I need to get "amenit".
函数如下:
String stemTerm(String term){
...
}
我找到了 Lucene Analyzer,但它看起来太复杂了,无法满足我的需要.http://lucene.apache.org/java/2_2_0/api/org/apache/lucene/analysis/PorterStemFilter.html
I've found the Lucene Analyzer, but it looks way too complicated for what I need. http://lucene.apache.org/java/2_2_0/api/org/apache/lucene/analysis/PorterStemFilter.html
有没有办法在不构建分析器的情况下使用它来词干?我不了解所有 Analyzer 业务...
Is there a way to use it to stem words without building an Analyzer? I don't understand all the Analyzer business...
编辑:我实际上需要词干提取+词形还原.Lucene 可以做到这一点吗?
EDIT: I actually need a stemming + lemmatization. Can Lucene do this?
推荐答案
import org.apache.lucene.analysis.PorterStemmer;
...
String stemTerm (String term) {
PorterStemmer stemmer = new PorterStemmer();
return stemmer.stem(term);
}
参见这里 了解更多详情.如果您只想使用词干提取,那么您应该使用 this 而不是 Lucene.
See here for more details. If stemming is all you want to do, then you should use this instead of Lucene.
您应该在将 term 传递给 stem() 之前将其小写.
You should lowercase term before passing it to stem().
这篇关于使用 Lucene 提取英语单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)