Documentation
¶
Overview ¶
Package spell is a pure-Go, high-performance spell checker based on Hunspell-compatible dictionaries.
Index ¶
- Constants
- func Expand(word, flags string) ([]string, error)
- func ExpandWith(path, word, flags string) ([]string, error)
- func Similarity(a, b string) float64
- type Checker
- func (m *Checker) AddWordListFile(name string) error
- func (m *Checker) Convert(s string) string
- func (m *Checker) Dict(i int) map[string]struct{}
- func (m *Checker) Ignored() []string
- func (m *Checker) Rank(word string) []Suggestion
- func (m *Checker) Recase(word string) (string, bool)
- func (m *Checker) Spell(word string) bool
- func (m *Checker) Suggest(word string) []string
- type CheckerOption
- type Options
- type Suggestion
Constants ¶
const ( Prefix affixType = iota Suffix )
specific Affix types
Variables ¶
This section is empty.
Functions ¶
func Expand ¶ added in v3.25.0
Expand returns the words that word with the given affix flags, such as `failover` and `S`, generates under Vale's default affix file.
func ExpandWith ¶ added in v3.25.0
ExpandWith is Expand under the `.aff` file at path.
func Similarity ¶ added in v3.22.0
Similarity is the closeness of two spellings, from 0 to 1, as the suggester measures it.
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker is a spell-checker based on multiple dictionaries.
func NewChecker ¶
func NewChecker(options ...CheckerOption) (*Checker, error)
NewChecker creates a spell checker from multiple Hunspell-compatible dictionaries.
func (*Checker) AddWordListFile ¶
AddWordListFile reads in a word list file
func (*Checker) Ignored ¶ added in v3.22.0
Ignored names the `.aff` directives the loaded dictionaries use that the checker does not implement, sorted.
func (*Checker) Rank ¶ added in v3.22.0
func (m *Checker) Rank(word string) []Suggestion
Rank returns the closest spellings of word across the dictionaries, best first, at most six.
func (*Checker) Recase ¶ added in v3.25.0
Recase returns the spelling a dictionary has for word in another case, when there is exactly one: GitHub for github.
type CheckerOption ¶
type CheckerOption func(opts *Options)
A CheckerOption is a setting that changes the checker-creation process.
func UsingDictionary ¶
func UsingDictionary(name string) CheckerOption
UsingDictionary loads the given Hunspell-compatible dictionary.
func UsingDictionaryByPath ¶
func UsingDictionaryByPath(dic, aff string) CheckerOption
UsingDictionaryByPath loads the given Hunspell-compatible dictionary using the given local paths.
func WithDefault ¶
func WithDefault(load bool) CheckerOption
WithDefault specifies if Vale's default dictionary should be loaded.
func WithDefaultPath ¶
func WithDefaultPath(path string) CheckerOption
WithDefaultPath specifies a path from which all dictionaries should be loaded.
func WithPath ¶
func WithPath(path string) CheckerOption
WithPath specifies the location of Hunspell-compatible dictionaries.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options controls the checker-creation process:
type Suggestion ¶ added in v3.22.0
A Suggestion is a candidate spelling and how close it is to the word, on the scale Similarity uses.