How to suggest only single words but index phrases

痴心易碎 提交于 2019-12-11 18:53:38

问题


I am having troubles right now. I am using ShingleAnalyzerWrapper to index phrases. But I need the SpellChecker to suggest me only single words.

How can i index phrases but search for both phrases and single words with SpellChecker?

Please, give some advice.


回答1:


Use this constructor, for your ShingleAnalyzerWrapper

ShingleAnalyzerWrapper(Analyzer defaultAnalyzer, 
                       int minShingleSize, 
                       int maxShingleSize, 
                       String tokenSeparator, 
                       boolean outputUnigrams, 
                       boolean outputUnigramsIfNoShingles)

passing true as the fifth argument (outputUnigrams). This will index all single tokens regardless of what you minShingleSize is. If your current minShingleSize is 2, you could just lower that to 1 to achieve the same result.



来源:https://stackoverflow.com/questions/13731115/how-to-suggest-only-single-words-but-index-phrases

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