Alex Rivera | Logout

"Did you mean?" feature in Lucene.net

Asked 2008-12-07T21:22:01.303
28

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

Thanks!

Edit
Report

1 Answer

35

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);
answered 2009-01-29T08:25:43.827

Your Answer