Documentation
¶
Index ¶
- func CaseVariations(word string, style WordCase) []string
- func RemovePath(s string) string
- func RemoveURL(s string) string
- type Affix
- type AffixType
- type DictConfig
- type Diff
- type GoSpell
- func (s *GoSpell) AddWordList(r io.Reader) ([]string, error)
- func (s *GoSpell) AddWordListFile(name string) ([]string, error)
- func (s *GoSpell) AddWordRaw(word string) bool
- func (s *GoSpell) InputConversion(raw []byte) string
- func (s *GoSpell) Spell(word string) bool
- func (s *GoSpell) Split(text string) []string
- type Rule
- type Splitter
- type WordCase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaseVariations ¶
CaseVariations returns If AllUpper or First-Letter-Only is upcased: add the all upper case version If AllLower, add the original, the title and upcase forms If Mixed, return the original, and the all upcase form
func RemovePath ¶
RemovePath attempts to strip away embedded file system paths, e.g.
/foo/bar or /static/myimg.png TODO: windows style
Types ¶
type DictConfig ¶
type DictConfig struct { Flag string TryChars string WordChars string NoSuggestFlag rune IconvReplacements []string Replacements [][2]string AffixMap map[rune]Affix CamelCase int CompoundMin int CompoundOnly string CompoundRule []string // contains filtered or unexported fields }
DictConfig is a partial representation of a Hunspell AFF (Affix) file.
func NewDictConfig ¶
func NewDictConfig(file io.Reader) (*DictConfig, error)
NewDictConfig reads an Hunspell AFF file
type GoSpell ¶
type GoSpell struct { Config DictConfig Dict map[string]struct{} // likely will contain some value later // contains filtered or unexported fields }
GoSpell is main struct
func NewGoSpell ¶
NewGoSpell from AFF and DIC Hunspell filenames
func NewGoSpellReader ¶
NewGoSpellReader creates a speller from io.Readers for Hunspell files
func (*GoSpell) AddWordList ¶
AddWordList adds basic word lists, just one word per line
Assumed to be in UTF-8
TODO: hunspell compatible with "*" prefix for forbidden words and affix support returns list of duplicated words and/or error
func (*GoSpell) AddWordListFile ¶
AddWordListFile reads in a word list file
func (*GoSpell) AddWordRaw ¶
AddWordRaw adds a single word to the internal dictionary without modifications returns true if added return false is already exists
func (*GoSpell) InputConversion ¶
InputConversion does any character substitution before checking
This is based on the ICONV stanza
type Rule ¶
type Rule struct { Strip string AffixText string // suffix or prefix text to add Pattern string // original matching pattern from AFF file // contains filtered or unexported fields }
Rule is a Affix rule
type Splitter ¶
type Splitter struct {
// contains filtered or unexported fields
}
Splitter splits a text into words Highly likely this implementation will change so we are encapsulating.
func NewSplitter ¶
NewSplitter creates a new splitter. The input is a string in UTF-8 encoding. Each rune in the string will be considered to be a valid word character. Runes that are NOT here are deemed a word boundary Current implementation uses https://golang.org/pkg/strings/#FieldsFunc