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 NewGoSpell(affFile, dicFile string) (*GoSpell, error)
- func NewGoSpellDB(dbFile string, config *gorm.Config) (*GoSpell, error)
- func NewGoSpellDBForce(affFile, dicFile, dbFile string, config *gorm.Config) (*GoSpell, error)
- func NewGoSpellDBReader(db *gorm.DB) (*GoSpell, error)
- func NewGoSpellReader(aff, dic io.Reader, db *gorm.DB, lang string) (*GoSpell, error)
- 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) GetSuggestions(word string) []string
- func (s *GoSpell) InputConversion(raw []byte) string
- func (s *GoSpell) Spell(word string) bool
- func (s *GoSpell) SpellWithSuggestions(word string) (suggestions []string)
- func (s *GoSpell) Split(text string) []string
- type Preferences
- type Rule
- type Splitter
- type WordCase
- type WordForm
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 `json:"flag,omitempty"` TryChars string `json:"try_chars,omitempty"` WordChars string `json:"word_chars,omitempty"` NoSuggestFlag rune `json:"no_suggest_flag,omitempty"` IconvReplacements []string `json:"iconv_replacements,omitempty"` Replacements [][2]string `json:"replacements,omitempty"` AffixMap map[rune]Affix `json:"affix_map,omitempty"` CamelCase int `json:"camel_case,omitempty"` CompoundMin int `json:"compound_min,omitempty"` CompoundOnly string `json:"compound_only,omitempty"` CompoundRule []string `json:"compound_rule,omitempty"` CompoundMap map[rune][]string `json:"compound_map,omitempty"` }
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 DB *gorm.DB // contains filtered or unexported fields }
GoSpell is main struct
func NewGoSpell ¶
NewGoSpell создает новый GoSpell из файлов AFF, DIC Hunspell
func NewGoSpellDB ¶ added in v1.3.0
NewGoSpellDB создает GoSpell с использованием указанной в пути базы данных
func NewGoSpellDBForce ¶ added in v1.4.0
NewGoSpellDBForce создает из файлов AFF, DIC Hunspell и складывает всё в базу данных, указанную в dbFile
func NewGoSpellDBReader ¶ added in v1.4.0
NewGoSpellDBReader создает GoSpell с использованием указанной базы данных
func NewGoSpellReader ¶
NewGoSpellReader создает GoSpell из файлов Huspell, переданных, как io.Reader Если db передано не как nil, собирается таблица словоформ,
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) GetSuggestions ¶ added in v1.4.0
GetSuggestions - Поиск возможных подстановок
func (*GoSpell) InputConversion ¶
InputConversion does any character substitution before checking
This is based on the ICONV stanza
func (*GoSpell) Spell ¶
Spell checks to see if a given word is in the internal dictionaries TODO: add multiple dictionaries
func (*GoSpell) SpellWithSuggestions ¶ added in v1.4.0
SpellWithSuggestions — проверка слова и получение для него возможных замен
type Preferences ¶ added in v1.4.0
Preferences - настройки, хранящиеся в базе данных
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