How to instruct StandardAnalyzer in Lucene to not to remove stop words?

半世苍凉 提交于 2019-12-21 00:14:09

问题


Simple question : How to make Lucene's StandardAnalyzer not to remove stop words when analyzing my sentence ?


回答1:


The answer is version-dependent. For Lucene 3.0.3 (current), you need to construct the StandardAnalyzer with an empty set of stop words, using something like this:

Analyzer ana = new StandardAnalyzer(LUCENE_30, Collections.emptySet());



回答2:


Update: the answer is version-dependent. For Lucene 4.0, use:

Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_40, CharArraySet.EMPTY_SET);

Note that the StandardAnalyzer is not in the lucene-core jar, but in lucene-analyzers-common-4.0.0.jar




回答3:


For Lucene 6.0.0, use

StandardAnalyzer analyzer = StandardAnalyzer(CharArraySet.EMPTY_SET);


来源:https://stackoverflow.com/questions/5102796/how-to-instruct-standardanalyzer-in-lucene-to-not-to-remove-stop-words

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!