Documentation ¶
Index ¶
- Constants
- Variables
- func GetEdits(term string, usedWeight float64, maxWeight float64) map[string]float64
- func GetMultiEdits(term string, usedWeight float64, maxWeight float64) map[string]float64
- func GetTrackingEdits(term string, usedAffectedChange OperationAffectedChange, maxWeight float64) map[string]*OperationAffectedChange
- func GetTrackingMultiEdits(term string, usedAffectedChange OperationAffectedChange, maxWeight float64) map[string]*OperationAffectedChange
- type DistanceMeasurer
- type EditAction
- type EditVariance
- type EditorialPrescription
- type LearnProgressor
- type Learner
- type LearningTerm
- type Misspell
- type MisspellParser
- type Model
- func (model *Model) AddTerm(term string, count float64) bool
- func (model *Model) GetRawSuggestions(input string, calcEditorialPrescription bool) map[string]Suggestion
- func (model *Model) GetSuggestions(input string, scoreModel ScoreModel, calcEditorialPrescription bool) []Suggestion
- func (model *Model) HasTerm(term string) bool
- func (model *Model) InitMeasurers()
- func (model *Model) TrainTerms(terms []string)
- func (model *Model) TrainText(text []byte)
- type OperationAffectedChange
- type OperationWeight
- type ScoreModel
- type Scorer
- type Suggestion
Constants ¶
View Source
const ( DefaultMinSpanningLen = 3.0 DefaultIndexSplitLen = 5 DefaultMinTermLen = 4 DefaultMinTermCount = 10 )
Variables ¶
View Source
var CheckOperationWeight = append([]OperationWeight{{ 0, 0.8, []int{1}, }}, OperationWeights...)
View Source
var OperationWeights = []OperationWeight{ { 1, 0.8, []int{0, -1}, }, { 2, 1.1, []int{0}, }, { 3, 1.9, []int{0}, }, }
Functions ¶
func GetMultiEdits ¶
func GetTrackingEdits ¶
func GetTrackingEdits(term string, usedAffectedChange OperationAffectedChange, maxWeight float64) map[string]*OperationAffectedChange
func GetTrackingMultiEdits ¶
func GetTrackingMultiEdits(term string, usedAffectedChange OperationAffectedChange, maxWeight float64) map[string]*OperationAffectedChange
Types ¶
type DistanceMeasurer ¶
type DistanceMeasurer struct {
// contains filtered or unexported fields
}
func NewDistanceMeasurer ¶
func NewDistanceMeasurer() *DistanceMeasurer
func (*DistanceMeasurer) Distance ¶
func (measurer *DistanceMeasurer) Distance(a, b string, calcEditorialPrescription bool) (distance int, editorialPrescription *EditorialPrescription)
type EditAction ¶
type EditAction uint32
const ( Insert EditAction = 0 Delete EditAction = 1 Replace EditAction = 2 Match EditAction = 3 Transposition EditAction = 4 Duplicate EditAction = 5 MissDouble EditAction = 6 Triplet EditAction = 7 )
type EditVariance ¶
type EditVariance struct { MinTermLen int PossibleEdits [][]EditAction }
type EditorialPrescription ¶
type EditorialPrescription struct { Froms []rune Tos []rune Actions []EditAction }
func (*EditorialPrescription) Dump ¶
func (prescription *EditorialPrescription) Dump()
type LearnProgressor ¶
type LearnProgressor interface {
LearnProgress() string
}
type Learner ¶
type Learner interface {
Learn(learningData []*LearningTerm) ScoreModel
}
type LearningTerm ¶
type LearningTerm struct { Term string Misspell string Suggestions []Suggestion }
type MisspellParser ¶
type MisspellParser struct { }
func NewMisspellParser ¶
func NewMisspellParser() *MisspellParser
func (*MisspellParser) Parse ¶
func (parser *MisspellParser) Parse(reader io.Reader) ([]Misspell, error)
func (*MisspellParser) ParseFromFile ¶
func (parser *MisspellParser) ParseFromFile(fileName string) ([]Misspell, error)
type Model ¶
type Model struct { Terms []string TermsDict map[string]int Index map[string][][]int IndexTail map[string]map[string]bool Affects [][][]int // inputlen -> edit len -> term lens KnownAffects []bool Depth int IndexSplitLen int TermsCounts []float64 TotalTerms float64 // contains filtered or unexported fields }
*
Model represents misspell corrector structure
func (*Model) GetRawSuggestions ¶
func (model *Model) GetRawSuggestions(input string, calcEditorialPrescription bool) map[string]Suggestion
*
Calculate raw unsorted suggestions
func (*Model) GetSuggestions ¶
func (model *Model) GetSuggestions(input string, scoreModel ScoreModel, calcEditorialPrescription bool) []Suggestion
*
Return suggestions sorted by given scorer
func (*Model) InitMeasurers ¶
func (model *Model) InitMeasurers()
type OperationAffectedChange ¶
type OperationWeight ¶
type ScoreModel ¶
type ScoreModel interface { Score(a *Suggestion) float64 Compare(a *Suggestion, b *Suggestion) float64 }
type Scorer ¶
type Scorer interface { GetDifference(prescription *EditorialPrescription) float64 Learn(learningData []LearningTerm) }
type Suggestion ¶
type Suggestion struct { Term string Distance int Score float64 Count float64 Prescription *EditorialPrescription }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.