“Did you mean?” feature in Lucene.net

后端 未结 4 2220
野的像风
野的像风 2020-11-30 22:07

Can someone please let me know how do I implement \"Did you mean\" feature in Lucene.net?

Thanks!

4条回答
  •  北海茫月
    2020-11-30 22:48

    You should look into the SpellChecker module in the contrib dir. It's a port of Java lucene's SpellChecker module, so its documentation should be helpful.

    (From the javadocs:)

    Example Usage:

      import org.apache.lucene.search.spell.SpellChecker;
    
      SpellChecker spellchecker = new SpellChecker(spellIndexDirectory);
      // To index a field of a user index:
      spellchecker.indexDictionary(new LuceneDictionary(my_lucene_reader, a_field));
      // To index a file containing words:
      spellchecker.indexDictionary(new PlainTextDictionary(new File("myfile.txt")));
      String[] suggestions = spellchecker.suggestSimilar("misspelt", 5);
    

提交回复
热议问题