小编bod*_*man的帖子

Lucene SpellCheck 不索引 2 个字母的单词

我正在使用 Lucene 进行拼写检查操作。但它不索引 2 个字母的单词。这似乎是 Lucene 拼写检查的常见问题。

这是我的索引方法:

    String fileName = "words.txt";

    Dictionary dictionary = null;
    try {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(fileName)), "UTF-8"));
        dictionary = new PlainTextDictionary(bufferedReader);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } 

    SpellChecker spell = null;
    try {
        Directory directory = FSDirectory.open(spellCheckerPath);
        spell = new SpellChecker(directory);
        spell .setAccuracy(0.5f);
    } catch (IOException e) {
        e.printStackTrace();
    }

    IndexWriterConfig indexWriterConfig = new IndexWriterConfig(Version.LUCENE_4_10_2, new StandardAnalyzer());
    indexWriterConfig.setOpenMode(OpenMode.CREATE_OR_APPEND);
    try {
        spell.indexDictionary(dictionary, indexWriterConfig, true); …
Run Code Online (Sandbox Code Playgroud)

java lucene spell-checking

10
推荐指数
0
解决办法
303
查看次数

标签 统计

java ×1

lucene ×1

spell-checking ×1