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) Probabilities(str string) (map[string]float64, string)
- 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 ¶ added in v0.3.0
func (c *Classifier) ClassifyString(doc string) (string, error)
ClassifyString provides convenience classification for strings
func (*Classifier) Probabilities ¶ added in v0.5.0
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) Train ¶
func (c *Classifier) Train(r io.Reader, category string) error
Train provides supervisory training to the classifier
func (*Classifier) TrainString ¶ added in v0.3.0
func (c *Classifier) TrainString(doc string, category string) error
TrainString provides supervisory training to the classifier
type Option ¶ added in v0.4.0
type Option func(c *Classifier) error
Option provides a functional setting for the Classifier
func Tokenizer ¶ added in v0.4.0
func Tokenizer(t classifier.Tokenizer) Option
Tokenizer overrides the classifier's default Tokenizer