Documentation
¶
Index ¶
- Variables
- type CheckCmd
- type CheckResult
- type Dict
- func (d *Dict) CheckSentence(sentence string) SentenceCorrectionSet
- func (d *Dict) CheckWord(word string) *CheckResult
- func (d *Dict) Destroy()
- func (d *Dict) Known(word string) int
- func (d *Dict) PushQueue(cmd DictCmd)
- func (d *Dict) TrainFile(filename string) (error, chan bool)
- func (d *Dict) TrainReader(r io.Reader) chan bool
- type DictCmd
- type SentenceCorrection
- type SentenceCorrectionSet
- type TrainCmd
Constants ¶
This section is empty.
Variables ¶
var DefaultAlphabet = strings.Split("abcdefghijklmnopqrstuvwxyz", "")
var DefaultDelimiters = " _=.?!,\n\"'"
Functions ¶
This section is empty.
Types ¶
type CheckCmd ¶
type CheckCmd struct {
Word string
Alphabet []string
Result chan *CheckResult
}
func (*CheckCmd) GetBestMatch ¶
GetBestMatch() will take a set of variants and return the one with the highest score per the dict.Known() function
func (*CheckCmd) Run ¶
Run() is the logic that will be executed by the Dict worker thread. This should not be called directly. It will determine if the provided word is in the dictionary, and, if it isn't, it will generate a set of variants using Variants(), and will send the best result down cmd.Result in the form of a CheckResult
type CheckResult ¶
type Dict ¶
Dict is the central struct for this library. It maintains the worker goroutines, and contains the internal data. All member functions of dict are thread safe.
func NewDict ¶
func NewDict() *Dict
NewDict() will create and initialize a new Dictionary, and start the worker goroutine
func (*Dict) CheckSentence ¶
func (d *Dict) CheckSentence(sentence string) SentenceCorrectionSet
func (*Dict) CheckWord ¶
func (d *Dict) CheckWord(word string) *CheckResult
CheckWord() is a primitive used to determine if a single word is spelled correctly
func (*Dict) Destroy ¶
func (d *Dict) Destroy()
Destroy() will terminate all worker goroutines. Once you release all references to the object, the internal data will clean up, too.
func (*Dict) Known ¶
Known() will return an integer value for whether the word exists in the dictionary. 0 means that the word was not found.
func (*Dict) PushQueue ¶
PushQueue() will push a DictCmd task into the command queue. This is not a guarantee that it will be executed now or next, but that it will be executed eventually
type DictCmd ¶
type DictCmd interface {
Run(d *Dict)
}
DictCmd is an interface that all internal commands intending on modifying internal Dict data must fulfill. This is to ensure multithread safety
type SentenceCorrection ¶
type SentenceCorrection struct {
BeginAt int
EndAt int
Result *CheckResult
}
func (*SentenceCorrection) Apply ¶
func (sc *SentenceCorrection) Apply(s string) string
type SentenceCorrectionSet ¶
type SentenceCorrectionSet []SentenceCorrection
func (SentenceCorrectionSet) ApplyAll ¶
func (scs SentenceCorrectionSet) ApplyAll(s string) string