|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.apache.lucene.search.spell.SpellChecker
Spell Checker class (Main class)
(initially inspired by the David Spencer code).
Example Usage:
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);
| Field Summary | |
static java.lang.String |
F_WORD
Field name for each word in the ngram index. |
| Constructor Summary | |
SpellChecker(Directory gramIndex)
|
|
| Method Summary | |
void |
clearIndex()
|
boolean |
exist(java.lang.String word)
Check whether the word exists in the index. |
protected void |
finalize()
|
void |
indexDictionary(Dictionary dict)
Index a Dictionary |
void |
setAccuraty(float min)
Set the accuracy 0 < min < 1; default 0.5 |
void |
setSpellIndex(Directory spellindex)
|
java.lang.String[] |
suggestSimilar(java.lang.String word,
int num_sug)
Suggest similar words |
java.lang.String[] |
suggestSimilar(java.lang.String word,
int num_sug,
IndexReader ir,
java.lang.String field,
boolean morePopular)
Suggest similar words (restricted or not to a field of a user index) |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String F_WORD
| Constructor Detail |
public SpellChecker(Directory gramIndex)
| Method Detail |
public void setSpellIndex(Directory spellindex)
public void setAccuraty(float min)
public java.lang.String[] suggestSimilar(java.lang.String word,
int num_sug)
throws java.io.IOException
word - String the word you want a spell check done onnum_sug - int the number of suggest words
java.io.IOException
public java.lang.String[] suggestSimilar(java.lang.String word,
int num_sug,
IndexReader ir,
java.lang.String field,
boolean morePopular)
throws java.io.IOException
word - String the word you want a spell check done onnum_sug - int the number of suggest wordsir - the indexReader of the user index (can be null see field param)field - String the field of the user index: if field is not null, the suggested
words are restricted to the words present in this field.morePopular - boolean return only the suggest words that are more frequent than the searched word
(only if restricted mode = (indexReader!=null and field!=null)
java.io.IOException
public void clearIndex()
throws java.io.IOException
java.io.IOException
public boolean exist(java.lang.String word)
throws java.io.IOException
word - String
java.io.IOException
public void indexDictionary(Dictionary dict)
throws java.io.IOException
dict - the dictionary to index
java.io.IOException
protected void finalize()
throws java.lang.Throwable
java.lang.Throwable
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||