In the earlier parts of the chapter, we sketched out a dummy Classifier type that does nothing. Let's make it do something now:
type Classifier struct {
corpus *corpus.Corpus
tfidfs [MAXCLASS]*tfidf.TFIDF
totals [MAXCLASS]float64
ready bool
sync.Mutex
}
Here, there are introductions to a few things. Let's walk them through one by one:
- We'll start with the corpus.Corpus type.
- This is a type imported from the corpus package, which is a subpackage of the NLP library for Go, lingo.
- To install lingo, simply run go get -u github.com/chewxy/lingo/....
- To use the corpus package, simply import it like so: import "github.com/chewxy/lingo/corpus".
Bear in mind that in the near future, the package will change to github.com/go-nlp/lingo. If you are reading this after January 2019, use the new address.
A corpus.Corpus object simply...