Documentation
¶
Index ¶
- Constants
- func Distance(a, b string, algorithm edlib.Algorithm) (int, error)
- type Suggestion
- type Suggestions
- type SymSpell
- func (s *SymSpell) CommitStaged(staging *staging.Stage[string])
- func (s *SymSpell) CreateDictionary(corpus io.Reader) bool
- func (s *SymSpell) CreateDictionaryFile(corpus string) bool
- func (s *SymSpell) CreateEntry(word string, count int, stage *staging.Stage[string]) (bool, error)
- func (s *SymSpell) DeleteInSuggestionPrefix(del string, delLen int, suggestion string, suggestionLen int) bool
- func (s *SymSpell) Edits(word string, editDistance int, deleteWords mapset.Set[string]) mapset.Set[string]
- func (s *SymSpell) EditsPrefix(word string) mapset.Set[string]
- func (s *SymSpell) EntryCount() int
- func (s *SymSpell) LoadBigramDictionary(corpus io.Reader) bool
- func (s *SymSpell) LoadBigramDictionaryFile(corpus string) bool
- func (s *SymSpell) LoadDictionary(corpus io.Reader) bool
- func (s *SymSpell) LoadDictionaryFile(corpus string) bool
- func (s *SymSpell) Lookup(input string, verbosity verb.Verbosity, maxEditDistance int, ...) (Suggestions, error)
- func (s *SymSpell) LookupCompound(input string) *Suggestions
- func (s *SymSpell) LookupCompoundWithEditDistance(input string, editDistance int) *Suggestions
- func (s *SymSpell) LookupDefault(input string, verbosity verb.Verbosity) (Suggestions, error)
- func (s *SymSpell) LookupEditDistance(input string, verbosity verb.Verbosity, maxEditDistance int) (Suggestions, error)
- func (s *SymSpell) ParseWords(text string) []string
- func (s *SymSpell) PurgeBelowThresholdWords()
- func (s *SymSpell) WordCount() int
Constants ¶
const (
N = 1024908267229
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Suggestion ¶
type Suggestion struct { Term string // Term is the suggested correctly spelled word Distance int // Distance between searched for word and suggestion in terms of edits Frequency int // Frequency of suggestion in the dictionary (a measure of how common the word is) }
Suggestion contains a spelling suggestion
func NewSuggestion ¶
func NewSuggestion(term string, dist, freq int) *Suggestion
NewSuggestion creates a new instance of a Suggestion
func (*Suggestion) GetHashCode ¶
func (s *Suggestion) GetHashCode() int
GetHashCode does something, need to figure out what exactly
func (*Suggestion) Less ¶
func (s *Suggestion) Less(other *Suggestion) bool
Less returns true if other is less. False if equal or greater than
func (*Suggestion) ShallowCopy ¶
func (s *Suggestion) ShallowCopy() *Suggestion
ShallowCopy creates a copy of the suggestion
func (*Suggestion) String ¶
func (s *Suggestion) String() string
String implements the stringer interface
type Suggestions ¶
type Suggestions []*Suggestion
Suggestions exists to implement the sort interface
func NewSuggestions ¶
func NewSuggestions() Suggestions
NewSuggestions returns an empty Suggestions set
func (Suggestions) Len ¶
func (s Suggestions) Len() int
Len returns the length of the Suggestions array
func (Suggestions) Less ¶
func (s Suggestions) Less(i, j int) bool
Less compares two Suggestion items and returns true if the first is less than the second, false for equal or greater
func (Suggestions) Swap ¶
func (s Suggestions) Swap(i, j int)
Swap the positions of two Suggestion in the array
type SymSpell ¶
type SymSpell struct { Verbosity verb.Verbosity MaxEditDistance int PrefixLength int CountThreshold int InitialCapacity int CompactLevel int CompactMask uint MaxWordLength int DistanceAlgorithm edlib.Algorithm // Dictionary that contains a mapping of lists of suggested correction words to the hashCodes // of the original words and the deletes derived from them. Collisions of hashCodes is tolerated, // because suggestions are ultimately verified via an edit distance function. // A list of suggestions might have a single suggestion, or multiple suggestions. Deletes map[int][]string // Dictionary of unique correct spelling words, and the frequency count for each word. Words map[string]int // Dictionary of unique words that are below the count threshold for being considered correct spellings. BelowThresholdWords map[string]int BigRams map[string]int BigRamCountMin int }
func NewSymSpell ¶
func NewSymSpellDefault ¶
func (*SymSpell) CreateDictionaryFile ¶
func (*SymSpell) CreateEntry ¶
func (*SymSpell) DeleteInSuggestionPrefix ¶
func (s *SymSpell) DeleteInSuggestionPrefix(del string, delLen int, suggestion string, suggestionLen int) bool
DeleteInSuggestionPrefix checks whether all delete chars are present in the suggestion prefix in correct order, otherwise this is just a hash collision
func (*SymSpell) Edits ¶
func (s *SymSpell) Edits(word string, editDistance int, deleteWords mapset.Set[string]) mapset.Set[string]
Edits creates a set of inexpensive and language independent edits only deletes, no transposes, replacements, or inserts replaces and inserts are expensive and language dependent (Chinese has 70,000 Unicode Han characters)
func (*SymSpell) EntryCount ¶
func (*SymSpell) LoadBigramDictionary ¶
func (*SymSpell) LoadBigramDictionaryFile ¶
func (*SymSpell) LoadDictionaryFile ¶
func (*SymSpell) LookupCompound ¶
func (s *SymSpell) LookupCompound(input string) *Suggestions
LookupCompound supports compound aware automatic spelling correction of multi-word input strings with three cases: 1. mistakenly inserted space into a correct word led to two incorrect terms 2. mistakenly omitted space between two correct words led to one incorrect combined term 3. multiple independent input terms with/without spelling errors
func (*SymSpell) LookupCompoundWithEditDistance ¶
func (s *SymSpell) LookupCompoundWithEditDistance(input string, editDistance int) *Suggestions
func (*SymSpell) LookupDefault ¶
func (*SymSpell) LookupEditDistance ¶
func (*SymSpell) ParseWords ¶
ParseWords creates a non-unique wordlist from sample text language independent (e.g. works with Chinese characters)
func (*SymSpell) PurgeBelowThresholdWords ¶
func (s *SymSpell) PurgeBelowThresholdWords()