Java Lucene建议拼写检查器类中的类似方法始终返回null
我有Java Lucene建议拼写检查器类中的类似方法始终返回null,java,lucene,Java,Lucene,我有test1.txt文件和下一个内容: aaa 因此,我试图通过使用拼写检查器类来查找符号: File dir = new File("/home/iurii/TestFolder/"); Directory directory = FSDirectory.open(dir); SpellChecker spellChecker = new SpellChecker(directory); Dictionary dictionar
test1.txt
文件和下一个内容:
aaa
因此,我试图通过使用拼写检查器类来查找符号:
File dir = new File("/home/iurii/TestFolder/");
Directory directory = FSDirectory.open(dir);
SpellChecker spellChecker = new SpellChecker(directory);
Dictionary dictionary = new PlainTextDictionary(new File("/home/iurii/TestFolder/test1.txt"));
IndexWriterConfig config = new IndexWriterConfig(Version.LATEST, new StandardAnalyzer());
spellChecker.indexDictionary(dictionary, config, false);
String[] results = spellChecker.suggestSimilar("a", 2);
这里的主要问题是数组结果总是空的。我的代码有什么问题?
提前谢谢。这里是胡乱猜测……可能是因为a
和aaa
之间的Levenstein距离太大?如果您尝试一个更接近aaa
的单词,比如aab
,会发生什么?当我放置aab
时,它工作正常。但我仍然不清楚,请您解释一下为什么这不起作用:拼写检查。suggestSimular(“aaa”,1)
?因为您要求它建议类似的术语。它不会返回与建议相同的术语。谢谢,请您写一个答案,我将此问题标记为已解决。这里是胡乱猜测…可能是因为a
和aaa
之间的Levenstein距离太大了?如果您尝试一个更接近aaa
的单词,比如aab
,会发生什么?当我放置aab
时,它工作正常。但我仍然不清楚,请您解释一下为什么这不起作用:拼写检查。suggestSimular(“aaa”,1)
?因为您要求它建议类似的术语。它不会返回与建议相同的术语。谢谢,请您写一个答案,我将此问题标记为已解决。