Here, we imagine an alternative design of Class:
type Class stringconst ( Ham Class = "Ham" Spam Class = "Spam")
With this change, we will have to update the definition of Classifier:
type Classifier struct { corpus *corpus.Corpus tfidfs map[Class]*tfidf.TFIDF totals map[Class]float64 ready bool sync.Mutex}
Consider now the steps required to get the totals of class Ham:
- The string has to be hashed
- The hash will be used to look up the bucket where the data for totals is stored
- An indirection is made to the bucket and the data is retrieved and returned to the user
Consider now the steps required to get the totals of class Ham if the class design was the original:
- Since Ham is a number, we can directly compute the ...