gospell: github.com/client9/gospell Index | Files | Directories

package gospell

import "github.com/client9/gospell"


Package Files

aff.go case.go file.go gospell.go notwords.go words.go

func CaseVariations Uses

func CaseVariations(word string, style WordCase) []string

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 Uses

func RemovePath(s string) string

RemovePath attempts to strip away embedded file system paths, e.g.

/foo/bar or /static/myimg.png

TODO: windows style

func RemoveURL Uses

func RemoveURL(s string) string

RemoveURL attempts to strip away obvious URLs

type Affix Uses

type Affix struct {
    Type         AffixType // either PFX or SFX
    CrossProduct bool
    Rules        []Rule

Affix is a rule for affix (adding prefixes or suffixes)

func (Affix) Expand Uses

func (a Affix) Expand(word string, out []string) []string

Expand provides all variations of a given word based on this affix rule

type AffixType Uses

type AffixType int

AffixType is either an affix prefix or suffix

const (
    Prefix AffixType = iota

specific Affix types

type DictConfig Uses

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 Uses

func NewDictConfig(file io.Reader) (*DictConfig, error)

NewDictConfig reads an Hunspell AFF file

func (DictConfig) Expand Uses

func (a DictConfig) Expand(wordAffix string, out []string) ([]string, error)

Expand expands a word/affix using dictionary/affix rules

This also supports CompoundRule flags

type Diff Uses

type Diff struct {
    Filename string
    Path     string
    Original string
    Line     string
    LineNum  int

Diff represent a unknown word in a file

func SpellFile Uses

func SpellFile(gs *GoSpell, ext plaintext.Extractor, raw []byte) []Diff

SpellFile is attempts to spell-check a file. This interface is not very good so expect changes.

type GoSpell Uses

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 Uses

func NewGoSpell(affFile, dicFile string) (*GoSpell, error)

NewGoSpell from AFF and DIC Hunspell filenames

func NewGoSpellReader Uses

func NewGoSpellReader(aff, dic io.Reader) (*GoSpell, error)

NewGoSpellReader creates a speller from io.Readers for Hunspell files

func (*GoSpell) AddWordList Uses

func (s *GoSpell) AddWordList(r io.Reader) ([]string, error)

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 Uses

func (s *GoSpell) AddWordListFile(name string) ([]string, error)

AddWordListFile reads in a word list file

func (*GoSpell) AddWordRaw Uses

func (s *GoSpell) AddWordRaw(word string) bool

AddWordRaw adds a single word to the internal dictionary without modifications returns true if added return false is already exists

func (*GoSpell) InputConversion Uses

func (s *GoSpell) InputConversion(raw []byte) string

InputConversion does any character substitution before checking

This is based on the ICONV stanza

func (*GoSpell) Spell Uses

func (s *GoSpell) Spell(word string) bool

Spell checks to see if a given word is in the internal dictionaries TODO: add multiple dictionaries

func (*GoSpell) Split Uses

func (s *GoSpell) Split(text string) []string

Split a text into Words

type Rule Uses

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 Uses

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 Uses

func NewSplitter(chars string) *Splitter

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

func (*Splitter) Split Uses

func (s *Splitter) Split(in string) []string

Split is the function to split an input into a `[]string`

type WordCase Uses

type WordCase int

WordCase is an enum of various word casing styles

const (
    AllLower WordCase = iota

Various WordCase types.. likely to be not correct

func CaseStyle Uses

func CaseStyle(word string) WordCase

CaseStyle returns what case style a word is in



Package gospell imports 11 packages (graph). Updated 2018-10-09. Refresh now. Tools for package owners.