spell

package
v0.9.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2020 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package spell provides functions for spell check and correction

Index

Constants

This section is empty.

Variables

View Source
var Ignore []string

Functions

func Asset added in v0.9.11

func Asset(name string) ([]byte, error)

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 added in v0.9.11

func AssetDir(name string) ([]string, error)

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 added in v0.9.11

func AssetInfo(name string) (os.FileInfo, error)

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 added in v0.9.11

func AssetNames() []string

AssetNames returns the names of the assets. nolint: deadcode

func CheckWord

func CheckWord(w string) (suggests []string, known bool, err error)

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 Complete

func Complete(s string) (result []string, err error)

Complete finds possible completions based on the prefix s

func DoIgnore

func DoIgnore(word string) bool

DoIgnore returns true if the word is found in the Ignore list

func IgnoreWord

func IgnoreWord(word string)

IgnoreWord adds the word to the Ignore list

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

func Load

func Load(path string) error

Load loads the saved model stored in json format

func LoadDefault added in v0.9.11

func LoadDefault() error

LoadDefault loads the default spelling file. Todo: need different languages obviously!

func MustAsset added in v0.9.11

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables. nolint: deadcode

func RestoreAsset added in v0.9.11

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets added in v0.9.11

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

func Save

func Save(filename string) error

Save saves the spelling model which includes the data and parameters

func Train

func Train(file os.File, new bool) (err error)

Types

type Edit added in v0.9.11

type Edit struct {
	NewText string `desc:"spelling correction text after special edits if needed"`
}

func CorrectText

func CorrectText(old string, new string) (ed Edit)

CorrectText replaces the old unknown word with the new word chosen from the list of corrections delta is the change in cursor position (cp).

type EditFunc

type EditFunc func(data interface{}, new string, old string) Edit

EditFunc is passed the current word and the selected correction for text editing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL