Documentation
¶
Index ¶
- Variables
- type Classifier
- func (c *Classifier) Classify(r io.Reader) (string, error)
- func (c *Classifier) ClassifyString(doc string) (string, error)
- func (c *Classifier) LoadCatCount(filename string) error
- func (c *Classifier) LoadFeat2cat(filename string) error
- func (c *Classifier) Probabilities(str string) (map[string]float64, string)
- func (c *Classifier) SaveCatCount(filename string) error
- func (c *Classifier) SaveFeat2cat(filename string) error
- func (c *Classifier) Train(r io.Reader, category string) error
- func (c *Classifier) TrainString(doc string, category string) error
- type Option
Constants ¶
This section is empty.
Variables ¶
var ErrNotClassified = errors.New("unable to classify document")
ErrNotClassified indicates that a document could not be classified
Functions ¶
This section is empty.
Types ¶
type Classifier ¶
type Classifier struct {
// contains filtered or unexported fields
}
Classifier implements a naive bayes classifier
func New ¶
func New(opts ...Option) *Classifier
New initializes a new naive Classifier using the standard tokenizer
func (*Classifier) Classify ¶
func (c *Classifier) Classify(r io.Reader) (string, error)
Classify attempts to classify a document. If the document cannot be classified (eg. because the classifier has not been trained), an error is returned.
func (*Classifier) ClassifyString ¶
func (c *Classifier) ClassifyString(doc string) (string, error)
ClassifyString provides convenience classification for strings
func (*Classifier) LoadCatCount ¶
func (c *Classifier) LoadCatCount(filename string) error
func (*Classifier) LoadFeat2cat ¶
func (c *Classifier) LoadFeat2cat(filename string) error
func (*Classifier) Probabilities ¶
func (c *Classifier) Probabilities(str string) (map[string]float64, string)
Probabilities runs the provided string through the model and returns the potential probability for each classification
func (*Classifier) SaveCatCount ¶
func (c *Classifier) SaveCatCount(filename string) error
func (*Classifier) SaveFeat2cat ¶
func (c *Classifier) SaveFeat2cat(filename string) error
func (*Classifier) Train ¶
func (c *Classifier) Train(r io.Reader, category string) error
Train provides supervisory training to the classifier
func (*Classifier) TrainString ¶
func (c *Classifier) TrainString(doc string, category string) error
TrainString provides supervisory training to the classifier
type Option ¶
type Option func(c *Classifier) error
Option provides a functional setting for the Classifier
func Tokenizer ¶
func Tokenizer(t classifier.Tokenizer) Option
Tokenizer overrides the classifier's default Tokenizer