Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
SpellChecker.Net.Search.Spell.SpellChecker Class Reference

More...

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)
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
spellIndexthe spell index directory
sdthe 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.

Parameters
spellIndexthe spell index directory

Definition at line 114 of file SpellChecker.cs.

Member Function Documentation

virtual void SpellChecker.Net.Search.Spell.SpellChecker.ClearIndex ( )
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 IndexSearcher SpellChecker.Net.Search.Spell.SpellChecker.CreateSearcher ( Directory  dir)
virtual

Creates a new read-only IndexSearcher (for testing purposes)

Parameters
dirdir the directory used to open the searcher
Returns
a new read-only IndexSearcher. (throws IOException f there is a low-level IO error)

Definition at line 577 of file SpellChecker.cs.

void SpellChecker.Net.Search.Spell.SpellChecker.Dispose ( )

Definition at line 599 of file SpellChecker.cs.

void SpellChecker.Net.Search.Spell.SpellChecker.Dispose ( bool  disposeOfManagedResources)
protected

Definition at line 605 of file SpellChecker.cs.

virtual bool SpellChecker.Net.Search.Spell.SpellChecker.Exist ( System.String  word)
virtual

Check whether the word exists in the index.

Parameters
wordString

<throws> IOException </throws>

Returns
true iff the word exists in the index

Definition at line 376 of file SpellChecker.cs.

StringDistance SpellChecker.Net.Search.Spell.SpellChecker.GetStringDistance ( )

Returns the StringDistance instance used by this SpellChecker instance.

Returns
Returns the StringDistance instance used by this SpellChecker instance.

Definition at line 162 of file SpellChecker.cs.

virtual void SpellChecker.Net.Search.Spell.SpellChecker.IndexDictionary ( IDictionary  dict,
int  mergeFactor,
int  ramMB 
)
virtual

Index a Dictionary

Parameters
dictthe dictionary to index
mergeFactormergeFactor to use when indexing
ramMBthe 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.

Parameters
dictdict the dictionary to index

Definition at line 441 of file SpellChecker.cs.

virtual void SpellChecker.Net.Search.Spell.SpellChecker.SetAccuracy ( float  minScore)
virtual

Set the accuracy 0 < min < 1; default 0.5

Definition at line 169 of file SpellChecker.cs.

virtual void SpellChecker.Net.Search.Spell.SpellChecker.SetSpellIndex ( Directory  spellIndexDir)
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.

Parameters
spellIndexDirspellIndexDir 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.

Parameters
sdthe StringDistance implementation for this SpellChecker instance.

Definition at line 149 of file SpellChecker.cs.

virtual System.String [] SpellChecker.Net.Search.Spell.SpellChecker.SuggestSimilar ( System.String  word,
int  num_sug 
)
virtual

Suggest similar words

Parameters
wordString the word you want a spell check done on
num_sugint the number of suggest words

<throws> IOException </throws>

Returns
String[]

Definition at line 182 of file SpellChecker.cs.

virtual System.String [] SpellChecker.Net.Search.Spell.SpellChecker.SuggestSimilar ( System.String  word,
int  numSug,
IndexReader  ir,
System.String  field,
bool  morePopular 
)
virtual

Suggest similar words (restricted or not to a field of a user index)

Parameters
wordString the word you want a spell check done on
numSugint the number of suggest words
irthe indexReader of the user index (can be null see field param)
fieldString the field of the user index: if field is not null, the suggested words are restricted to the words present in this field.
morePopularboolean 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>

Returns
String[] the sorted list of the suggest words with this 2 criteria: first criteria: the edit distance, second criteria (only if restricted mode): the popularity of the suggest words in the field of the user index

Definition at line 206 of file SpellChecker.cs.

Member Data Documentation

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.


The documentation for this class was generated from the following file: