naive

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL