C# 클래스 SpellChecker.Net.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); 
파일 보기 프로젝트 열기: synhershko/lucene.net 1 사용 예제들

공개 메소드들

메소드 설명
ClearIndex ( ) : void

Removes all terms from the spell check index.

Close ( ) : void
CreateSearcher ( Lucene.Net.Store.Directory dir ) : IndexSearcher

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

Dispose ( ) : void
Exist ( System word ) : bool

Check whether the word exists in the index.

GetStringDistance ( ) : StringDistance

Returns the StringDistance instance used by this SpellChecker instance.

IndexDictionary ( IDictionary dict ) : void

Indexes the data from the given IDictionary.

IndexDictionary ( IDictionary dict, int mergeFactor, int ramMB ) : void

Index a Dictionary

SetAccuracy ( float minScore ) : void

Set the accuracy 0 < min < 1; default 0.5

SetSpellIndex ( Lucene.Net.Store.Directory spellIndexDir ) : void

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.

SpellChecker ( Lucene.Net.Store.Directory spellIndex ) : System

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.

SpellChecker ( Lucene.Net.Store.Directory spellIndex, StringDistance sd ) : System

Use the given directory as a spell checker index. The directory is created if it doesn't exist yet.

SuggestSimilar ( System word, int num_sug ) : System.String[]

Suggest similar words

SuggestSimilar ( System word, int numSug, Lucene.Net.Index.IndexReader ir, System field, bool morePopular ) : System.String[]

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

setStringDistance ( StringDistance sd ) : void

Sets the StringDistance implementation for this SpellChecker instance.

보호된 메소드들

메소드 설명
Dispose ( bool disposeOfManagedResources ) : void

비공개 메소드들

메소드 설명
Add ( Lucene.Net.Search.BooleanQuery q, System k, System v ) : void

Add a clause to a boolean query.

Add ( Lucene.Net.Search.BooleanQuery q, System k, System v, float boost ) : void

Add a clause to a boolean query.

AddGram ( System text, Lucene.Net.Documents.Document doc, int ng1, int ng2 ) : void
CreateDocument ( System text, int ng1, int ng2 ) : Lucene.Net.Documents.Document
EnsureOpen ( ) : void
FormGrams ( System text, int ng ) : System.String[]

Form all ngrams for a given word.

GetMax ( int l ) : int
GetMin ( int l ) : int
IsClosed ( ) : bool

Returns true if and only if the SpellChecker is closed, otherwise false.

ObtainSearcher ( ) : IndexSearcher
ReleaseSearcher ( IndexSearcher aSearcher ) : void
SwapSearcher ( Lucene.Net.Store.Directory dir ) : void

메소드 상세

ClearIndex() 공개 메소드

Removes all terms from the spell check index.
public ClearIndex ( ) : void
리턴 void

Close() 공개 메소드

public Close ( ) : void
리턴 void

CreateSearcher() 공개 메소드

Creates a new read-only IndexSearcher (for testing purposes)
public CreateSearcher ( Lucene.Net.Store.Directory dir ) : IndexSearcher
dir Lucene.Net.Store.Directory dir the directory used to open the searcher
리턴 Lucene.Net.Search.IndexSearcher

Dispose() 공개 메소드

public Dispose ( ) : void
리턴 void

Dispose() 보호된 메소드

protected Dispose ( bool disposeOfManagedResources ) : void
disposeOfManagedResources bool
리턴 void

Exist() 공개 메소드

Check whether the word exists in the index.
public Exist ( System word ) : bool
word System String ///
리턴 bool

GetStringDistance() 공개 메소드

Returns the StringDistance instance used by this SpellChecker instance.
public GetStringDistance ( ) : StringDistance
리턴 StringDistance

IndexDictionary() 공개 메소드

Indexes the data from the given IDictionary.
public IndexDictionary ( IDictionary dict ) : void
dict IDictionary dict the dictionary to index
리턴 void

IndexDictionary() 공개 메소드

Index a Dictionary
public IndexDictionary ( IDictionary dict, int mergeFactor, int ramMB ) : void
dict IDictionary the dictionary to index
mergeFactor int mergeFactor to use when indexing
ramMB int the max amount or memory in MB to use
리턴 void

SetAccuracy() 공개 메소드

Set the accuracy 0 < min < 1; default 0.5
public SetAccuracy ( float minScore ) : void
minScore float
리턴 void

SetSpellIndex() 공개 메소드

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.
public SetSpellIndex ( Lucene.Net.Store.Directory spellIndexDir ) : void
spellIndexDir Lucene.Net.Store.Directory spellIndexDir the spell directory to use
리턴 void

SpellChecker() 공개 메소드

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.
public SpellChecker ( Lucene.Net.Store.Directory spellIndex ) : System
spellIndex Lucene.Net.Store.Directory the spell index directory
리턴 System

SpellChecker() 공개 메소드

Use the given directory as a spell checker index. The directory is created if it doesn't exist yet.
public SpellChecker ( Lucene.Net.Store.Directory spellIndex, StringDistance sd ) : System
spellIndex Lucene.Net.Store.Directory the spell index directory
sd StringDistance the measurement to use
리턴 System

SuggestSimilar() 공개 메소드

Suggest similar words
public SuggestSimilar ( System word, int num_sug ) : System.String[]
word System String the word you want a spell check done on ///
num_sug int int the number of suggest words ///
리턴 System.String[]

SuggestSimilar() 공개 메소드

Suggest similar words (restricted or not to a field of a user index)
public SuggestSimilar ( System word, int numSug, Lucene.Net.Index.IndexReader ir, System field, bool morePopular ) : System.String[]
word System String the word you want a spell check done on ///
numSug int int the number of suggest words ///
ir Lucene.Net.Index.IndexReader the indexReader of the user index (can be null see field param) ///
field System 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 bool boolean return only the suggest words that are more frequent than the searched word /// (only if restricted mode = (indexReader!=null and field!=null) ///
리턴 System.String[]

setStringDistance() 공개 메소드

Sets the StringDistance implementation for this SpellChecker instance.
public setStringDistance ( StringDistance sd ) : void
sd StringDistance the implementation for this /// instance.
리턴 void