Documentation
¶
Overview ¶
Package spellcheck provides a fully offline spell- and grammar-checking engine. Every language pack — its dictionary and grammar rules — is embedded into the binary, so no text ever leaves the process.
Dictionaries under dict/ are word-frequency lists derived from the OpenSubtitles corpus (hermitdave/FrequencyWords, MIT-licensed). The frequency counts double as a ranking signal for spelling suggestions.
Adding a language: drop a "<code>.txt" frequency list under dict/, add a newXxx() constructor returning a *Language, and register it in init().
Index ¶
Constants ¶
const ( TypeSpelling = "spelling" TypeGrammar = "grammar" TypePunctuation = "punctuation" TypeStyle = "style" )
Issue types reported to callers.
const DefaultLanguage = "en"
DefaultLanguage is used when a request omits or names an unknown language.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dictionary ¶
type Dictionary struct {
// contains filtered or unexported fields
}
Dictionary is a lazily-loaded word→frequency map. It backs two operations: membership testing (is a token a real word?) and ranking candidate corrections by how common the word is. Words are stored lowercased.
type Issue ¶
type Issue struct {
Offset int
Length int
Text string
Type string
Rule string
Message string
Replacements []string
}
Issue is a single detected problem in the input text. Offsets and lengths are expressed in runes so the frontend can map them onto the original string.
type Language ¶
Language is a self-contained pack: a dictionary, a spelling corrector built on it, and an ordered set of grammar rules.
type LanguageInfo ¶
LanguageInfo is the public description of an available language.
func Languages ¶
func Languages() []LanguageInfo
Languages lists the available languages in registration order.