lucene スペル チェッカー (コア lucene とスペル チェッカーの両方でバージョン 3.6) の文字セットの設定についてサポートが必要です。私の辞書 ("D:\dictionary.txt") には、英語とロシア語の両方の単語が含まれています。私のコードは英語のテキストでうまく機能します。たとえば、単語「hello」の正しいスペルが返されます。ただし、ロシア語では機能しません。たとえば、ロシア語の単語のスペルを間違えると、コンパイラは例外 (スレッド "main" java.lang.ArrayIndexOutOfBoundsException: 0 の例外) を発生させ、ロシア語の単語の候補を見つけることができません。
これが私のコードです:
RAMDirectory spellCheckerDir = new RAMDirectory();
SpellChecker spellChecker = new SpellChecker(spellCheckerDir);
StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_36);
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_36, analyzer);
InputStreamReader isr = new InputStreamReader(new FileInputStream(new File("D:\\dictionary.txt")), "UTF-8");
PlainTextDictionary dictionary = new PlainTextDictionary(isr);
spellChecker.indexDictionary(dictionary, config, true);
suggestions = spellChecker.suggestSimilar("hwllo", 1); // word 'hello' is misspeled like 'hwllo'