Implementating the classifier

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 ...

Get Go Machine Learning Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.