Documentation
¶
Index ¶
- type Model
- func (model *Model) Dump(f io.Writer)
- func (model *Model) Entropy(text string) (entropy float64)
- func (model *Model) LogProb(key string) (logProb float64)
- func (model *Model) Predict(text string) (prediction *Prediction)
- func (model *Model) Train(f io.Reader) (exampleCount int)
- func (model *Model) TrainWithMultiplier(f io.Reader) (exampleCount int)
- func (model *Model) Update(line string)
- func (model *Model) UpdateWithMultiplier(line string, multiplier uint64)
- type NGramCounter
- type Prediction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model struct { Size int Counter *NGramCounter }
Model contains a max size and a map from its to character models
func (*Model) LogProb ¶
LogProb returns the best matching log probability for a key given a set of models
func (*Model) Predict ¶
func (model *Model) Predict(text string) (prediction *Prediction)
Predict returns a prediction for a string
func (*Model) Train ¶
Train trains a set of ngram models from a file. Models must be initialized. returns the number of example lines used
func (*Model) TrainWithMultiplier ¶
TrainWithMultiplier trains a set of ngram models from a file. Models must be initialized. returns the number of example lines used. format is token <tab> count
func (*Model) UpdateWithMultiplier ¶
UpdateWithMultiplier for Models send string to each counter with multiplier
type NGramCounter ¶
NGramCounter contains counts and totals for Ngrams of a particular size
func NewNGramCounter ¶
func NewNGramCounter(maxNGramSize int) (counter *NGramCounter)
NewNGramCounter returns a new ngram counter
func (*NGramCounter) Count ¶
func (counter *NGramCounter) Count(key string, ifNotFound uint64) (count uint64)
Count returns the number of ngrams in a particular counter. returns default if not found
func (*NGramCounter) Update ¶
func (counter *NGramCounter) Update(line string)
Update updates the counter for a newly seen string
func (*NGramCounter) UpdateWithMultiplier ¶
func (counter *NGramCounter) UpdateWithMultiplier(line string, multiplier uint64)
UpdateWithMultiplier updates the counter for a string, using a multiplier