Lucene.Net
3.0.3
Lucene.Net is a .NET port of the Java Lucene Indexing Library
|
Inherits IDisposable.
Public Member Functions | |
SpellChecker (Directory spellIndex, StringDistance sd) | |
Use the given directory as a spell checker index. The directory is created if it doesn't exist yet. | |
SpellChecker (Directory spellIndex) | |
Use the given directory as a spell checker index with a LevenshteinDistance as the default StringDistance. The directory is created if it doesn't exist yet. | |
virtual void | SetSpellIndex (Directory spellIndexDir) |
Use a different index as the spell checker index or re-open the existing index if spellIndex is the same value as given in the constructor. | |
void | setStringDistance (StringDistance sd) |
Sets the StringDistance implementation for this SpellChecker instance. | |
StringDistance | GetStringDistance () |
Returns the StringDistance instance used by this SpellChecker instance. | |
virtual void | SetAccuracy (float minScore) |
Set the accuracy 0 < min < 1; default 0.5 | |
virtual System.String[] | SuggestSimilar (System.String word, int num_sug) |
Suggest similar words | |
virtual System.String[] | SuggestSimilar (System.String word, int numSug, IndexReader ir, System.String field, bool morePopular) |
Suggest similar words (restricted or not to a field of a user index) | |
virtual void | ClearIndex () |
Removes all terms from the spell check index. | |
virtual bool | Exist (System.String word) |
Check whether the word exists in the index. | |
virtual void | IndexDictionary (IDictionary dict, int mergeFactor, int ramMB) |
Index a Dictionary | |
void | IndexDictionary (IDictionary dict) |
Indexes the data from the given IDictionary. | |
void | Close () |
virtual IndexSearcher | CreateSearcher (Directory dir) |
Creates a new read-only IndexSearcher (for testing purposes) | |
void | Dispose () |
Public Attributes | |
const System.String | F_WORD = "word" |
Field name for each word in the ngram index. | |
Protected Member Functions | |
void | Dispose (bool disposeOfManagedResources) |
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);
<author> Nicolas Maisonneuve </author> <version> 1.0 </version>
Definition at line 62 of file SpellChecker.cs.
SpellChecker.Net.Search.Spell.SpellChecker.SpellChecker | ( | Directory | spellIndex, |
StringDistance | sd | ||
) |
Use the given directory as a spell checker index. The directory is created if it doesn't exist yet.
spellIndex | the spell index directory |
sd | the StringDistance measurement to use |
Definition at line 102 of file SpellChecker.cs.
SpellChecker.Net.Search.Spell.SpellChecker.SpellChecker | ( | Directory | spellIndex | ) |
Use the given directory as a spell checker index with a LevenshteinDistance as the default StringDistance. The directory is created if it doesn't exist yet.
spellIndex | the spell index directory |
Definition at line 114 of file SpellChecker.cs.
|
virtual |
Removes all terms from the spell check index.
Definition at line 357 of file SpellChecker.cs.
void SpellChecker.Net.Search.Spell.SpellChecker.Close | ( | ) |
Definition at line 533 of file SpellChecker.cs.
|
virtual |
Creates a new read-only IndexSearcher (for testing purposes)
dir | dir the directory used to open the searcher |
Definition at line 577 of file SpellChecker.cs.
void SpellChecker.Net.Search.Spell.SpellChecker.Dispose | ( | ) |
Definition at line 599 of file SpellChecker.cs.
|
protected |
Definition at line 605 of file SpellChecker.cs.
|
virtual |
Check whether the word exists in the index.
word | String |
<throws> IOException </throws>
Definition at line 376 of file SpellChecker.cs.
StringDistance SpellChecker.Net.Search.Spell.SpellChecker.GetStringDistance | ( | ) |
Returns the StringDistance instance used by this SpellChecker instance.
Definition at line 162 of file SpellChecker.cs.
|
virtual |
Index a Dictionary
dict | the dictionary to index |
mergeFactor | mergeFactor to use when indexing |
ramMB | the max amount or memory in MB to use |
<throws> IOException </throws> <throws>AlreadyClosedException if the Spellchecker is already closed</throws>
Definition at line 397 of file SpellChecker.cs.
void SpellChecker.Net.Search.Spell.SpellChecker.IndexDictionary | ( | IDictionary | dict | ) |
Indexes the data from the given IDictionary.
dict | dict the dictionary to index |
Definition at line 441 of file SpellChecker.cs.
|
virtual |
Set the accuracy 0 < min < 1; default 0.5
Definition at line 169 of file SpellChecker.cs.
|
virtual |
Use a different index as the spell checker index or re-open the existing index if spellIndex
is the same value as given in the constructor.
spellIndexDir | spellIndexDir the spell directory to use |
<throws>AlreadyClosedException if the Spellchecker is already closed</throws> <throws>IOException if spellchecker can not open the directory</throws>
Definition at line 126 of file SpellChecker.cs.
void SpellChecker.Net.Search.Spell.SpellChecker.setStringDistance | ( | StringDistance | sd | ) |
Sets the StringDistance implementation for this SpellChecker instance.
sd | the StringDistance implementation for this SpellChecker instance. |
Definition at line 149 of file SpellChecker.cs.
|
virtual |
Suggest similar words
word | String the word you want a spell check done on |
num_sug | int the number of suggest words |
<throws> IOException </throws>
Definition at line 182 of file SpellChecker.cs.
|
virtual |
Suggest similar words (restricted or not to a field of a user index)
word | String the word you want a spell check done on |
numSug | int the number of suggest words |
ir | 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) |
<throws> IOException </throws>
Definition at line 206 of file SpellChecker.cs.
const System.String SpellChecker.Net.Search.Spell.SpellChecker.F_WORD = "word" |
Field name for each word in the ngram index.
Definition at line 65 of file SpellChecker.cs.