Documentation ¶
Overview ¶
Eventually this should be removed. Currently it gives backwards compatability to old versions that did not store the query count, which is now used for autocomplete.
Index ¶
- Constants
- func Edits1(word string) []string
- func Levenshtein(a, b *string) int
- func SampleEnglish() []string
- type Autos
- type Counts
- type Method
- type Model
- func (model *Model) Autocomplete(input string) ([]string, error)
- func (model *Model) CheckKnown(input string, correct string) bool
- func (model *Model) EditsMulti(term string, depth int) []string
- func (model *Model) Init() *Model
- func (model *Model) Potentials(input string, exhaustive bool) map[string]*Potential
- func (model *Model) Save(filename string) error
- func (model *Model) SaveLight(filename string) error
- func (model *Model) SetCount(term string, count int, suggest bool)
- func (model *Model) SetDepth(val int)
- func (model *Model) SetDivergenceThreshold(val int)
- func (model *Model) SetThreshold(val int)
- func (model *Model) SetUseAutocomplete(val bool)
- func (model *Model) SpellCheck(input string) string
- func (model *Model) SpellCheckSuggestions(input string, n int) []string
- func (model *Model) Suggestions(input string, exhaustive bool) []string
- func (model *Model) Train(terms []string)
- func (model *Model) TrainQuery(term string)
- func (model *Model) TrainWord(term string)
- func (model *Model) WriteTo(w io.Writer) (int64, error)
- type OldModel
- type Pair
- type Potential
Constants ¶
const ( SpellDepthDefault = 2 SpellThresholdDefault = 5 SuffDivergenceThresholdDefault = 100 )
const ( MethodIsWord Method = 0 MethodSuggestMapsToInput = 1 MethodInputDeleteMapsToDict = 2 MethodInputDeleteMapsToSuggest = 3 )
Variables ¶
This section is empty.
Functions ¶
func Levenshtein ¶
Calculate the Levenshtein distance between two strings
func SampleEnglish ¶
func SampleEnglish() []string
Types ¶
type Model ¶
type Model struct { Data map[string]*Counts `json:"data"` Maxcount int `json:"maxcount"` Suggest map[string][]string `json:"suggest"` Depth int `json:"depth"` Threshold int `json:"threshold"` UseAutocomplete bool `json:"autocomplete"` SuffDivergence int `json:"-"` SuffDivergenceThreshold int `json:"suff_threshold"` SuffixArr *suffixarray.Index `json:"-"` SuffixArrConcat string `json:"-"` sync.RWMutex }
func FromReader ¶
FromReader loads a model from a Reader
func (*Model) Autocomplete ¶
For a given string, autocomplete using the suffix array model
func (*Model) CheckKnown ¶
Test an input, if we get it wrong, look at why it is wrong. This function returns a bool indicating if the guess was correct as well as the term it is suggesting. Typically this function would be used for testing, not for production
func (*Model) EditsMulti ¶
Edits at any depth for a given term. The depth of the model is used
func (*Model) Potentials ¶
Return the raw potential terms so they can be ranked externally to this package
func (*Model) SaveLight ¶
Save a spelling model to disk, but discard all entries less than the threshold number of occurences Much smaller and all that is used when generated as a once off, but not useful for incremental usage
func (*Model) SetCount ¶
Manually set the count of a word. Optionally trigger the creation of suggestion keys for the term. This function lets you build a model from an existing dictionary with word popularity counts without needing to run "TrainWord" repeatedly
func (*Model) SetDepth ¶
Change the default depth value of the model. This sets how many character differences are indexed. The default is 2.
func (*Model) SetDivergenceThreshold ¶
Optionally set the suffix array divergence threshold. This is the number of query training steps between rebuilds of the suffix array. A low number will be more accurate but will use resources and create more garbage.
func (*Model) SetThreshold ¶
Change the default threshold of the model. This is how many times a term must be seen before suggestions are created for it
func (*Model) SetUseAutocomplete ¶
Optionally disabled suffixarray based autocomplete support
func (*Model) SpellCheck ¶
Return the most likely correction for the input term
func (*Model) SpellCheckSuggestions ¶
Return the most likely corrections in order from best to worst
func (*Model) Suggestions ¶
For a given input string, suggests potential replacements
func (*Model) TrainQuery ¶
Train using a search query term. This builds a second popularity index of terms used to search, as opposed to generally occurring in corpus text