func (t *TFIDF) TermFrequency(word string, document []string) float64 {
	words := make(map[string]int)
	for i := range document {
		words[document[i]]++
	}
	var maxFreq int
	for i := range words {
		if words[i] > maxFreq {
			maxFreq = words[i]
		}
	}
	return 0.5 * (1 + float64(words[word])/float64(maxFreq))
}
TermFrequency returns the term frequency
of a word within a corpus defined by the
trained NaiveBayes model

Look at the TFIDF docs to see more about how
this is calculated
package text
import (
	"math"
	"sort"
	"golang.org/x/text/transform"
)
type TFIDF NaiveBayes
type Frequency struct {
	Word      string  `json:"word"`
	Frequency float64 `json:"frequency,omitempty"`
	TFIDF     float64 `json:"tfidf_score,omitempty"`
}
type Frequencies []Frequency
func (f Frequencies) Len() int {
	return len(f)
}
func (f Frequencies) Less(i, j int) bool {
	return f[i].TFIDF < f[j].TFIDF
}
func (f Frequencies) Swap(i, j int) {
	f[i], f[j] = f[j], f[i]
}
func (t *TFIDF) TFIDF(word string, sentence string) float64 {
	sentence, _, _ = transform.String(t.sanitize, sentence)
	document := t.Tokenizer.Tokenize(sentence)
	return t.TermFrequency(word, document) * t.InverseDocumentFrequency(word)
}
func (t *TFIDF) MostImportantWords(sentence string, n int) Frequencies {
	sentence, _, _ = transform.String(t.sanitize, sentence)
	document := t.Tokenizer.Tokenize(sentence)
	freq := TermFrequencies(document)
	for i := range freq {
		freq[i].TFIDF = freq[i].Frequency * t.InverseDocumentFrequency(freq[i].Word)
		freq[i].Frequency = float64(0.0)
	}
	sort.Sort(sort.Reverse(freq))
	if n > len(freq) {
		return freq
	}
	return freq[:n]
}