Documentation ¶
Overview ¶
Package spell provides functions for spell check and correction. It wraps https://github.com/sajari/fuzzy as the core spelling engine.
A single globally-usable spelling dictionary is managed.
Index ¶
- Constants
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func CheckIgnore(word string) bool
- func CheckLexLine(src []rune, tags lex.Line) lex.Line
- func CheckWord(word string) ([]string, bool)
- func Complete(s string) []string
- func IgnoreWord(word string)
- func Initialized() bool
- func LearnWord(word string)
- func ModTime(path string) (time.Time, error)
- func MustAsset(name string) []byte
- func Open(path string) error
- func OpenAsset(fname string) error
- func OpenCheck() error
- func OpenDefault() error
- func ResetLearnTime()
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func Save(filename string) error
- func SaveIfLearn() error
- func Train(file os.File, new bool) (err error)
Constants ¶
const SaveAfterLearnIntervalSecs = 20
SaveAfterLearnIntervalSecs is number of seconds since file has been opened / saved above which model is saved after learning.
Variables ¶
var (
Ignore = map[string]struct{}{}
)
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetNames ¶
func AssetNames() []string
AssetNames returns the names of the assets. nolint: deadcode
func CheckIgnore ¶ added in v0.9.14
CheckIgnore returns true if the word is found in the Ignore list
func CheckLexLine ¶ added in v0.9.14
CheckLexLine returns the Lex regions for any words that are misspelled within given line of text with existing Lex tags -- automatically excludes any Code token regions (see token.IsCode). Token is set to token.TextSpellErr on returned Lex's
func CheckWord ¶
CheckWord checks a single word and returns suggestions if word is unknown Programs should call gi.CheckWord - all program calls should be done through that single API
func Initialized ¶
func Initialized() bool
Initialized returns true if the model has been loaded or created anew
func LearnWord ¶
func LearnWord(word string)
LearnWord adds a single word to the corpus: this is deterministic and we set the threshold to 1 to make it learn it immediately.
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables. nolint: deadcode
func OpenCheck ¶ added in v0.9.14
func OpenCheck() error
OpenCheck checks if the current file has been modified since last open time and re-opens it if so -- call this prior to checking.
func OpenDefault ¶ added in v0.9.14
func OpenDefault() error
OpenDefault loads the default spelling file. TODO: need different languages obviously!
func ResetLearnTime ¶ added in v0.9.14
func ResetLearnTime()
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
func Save ¶
Save saves the spelling model which includes the data and parameters note: this will overwrite any existing file -- be sure to have opened the current file before making any changes.
func SaveIfLearn ¶ added in v0.9.14
func SaveIfLearn() error
SaveIfLearn saves the spelling model to file path that was used in last Open command, if learning has occurred since last save / open. If no changes also checks if file has been modified and opens it if so.
Types ¶
This section is empty.