You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Cheng <zh...@gmail.com> on 2014/09/29 18:51:11 UTC

Lucene suggester can't suggest similar phrase

Hi,

I am using Lucene 4.10 suggester which I thought can return similar phrase.
But it turned out the different way.

My code is as follow:

public static void main(String[] args) throws IOException {

String path = "c:/data/suggest/dic.txt";

Dictionary dic;

dic = new FileDictionary(new FileInputStream(path));

InputIterator it = dic.getEntryIterator();

Analyzer analyzer = ERAnalyzer.getInstance().getAnalyzer();

FuzzySuggester suggester = new FuzzySuggester(analyzer);

suggester.build(it);

CharSequence cs = "雅诗兰黛";

List<LookupResult> results = suggester.lookup(cs, false, 1);

System.out.println(results.get(0).key);

}

The dictionary contains only one line:

雅诗兰黛 50

When cs is exactly "雅诗兰黛", I get the result. But when cs is "雅思兰黛", which
is only one word different from the target, I get nothing back.

I tried FuzzySuggester as well as AnalyzingSuggester. The result is the
same.

Did I miss something here?

Thanks!