"Did you mean?" feature in Lucene.net

user40907 picture user40907 · Dec 7, 2008 · Viewed 15.2k times · Source

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

Thanks!

Answer

itsadok picture itsadok · Jan 29, 2009

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);