def _calc_unigram_scores(self) -> List[float]:
unigram_scores = []
for ts in self.tss:
unigram_score = 0.0
for t in ts:
n = float(self.n_total_words)
x = float(self.word_freq.get(t, self.word_freq['<unk/>']))
unigram_score += math.log(x / n)
unigram_scores.append(unigram_score)
return unigram_scores
评论列表
文章目录