如何在语言建模中对bigram模型使用“Interpolated Absolute Discounting”?

问题描述 投票:0回答:1

我想比较一个bigram模型的两种平滑方法:

  • 添加一个平滑
  • 插值绝对折扣

对于第一种方法,我找到了一些代码。

def calculate_bigram_probabilty(self, previous_word, word):
    bigram_word_probability_numerator = self.bigram_frequencies.get((previous_word, word), 0)
    bigram_word_probability_denominator = self.unigram_frequencies.get(previous_word, 0)
    if self.smoothing:
        bigram_word_probability_numerator += 1
        bigram_word_probability_denominator += self.unique__bigram_words
    return 0.0 if bigram_word_probability_numerator == 0 or bigram_word_probability_denominator == 0 else float(
        bigram_word_probability_numerator) / float(bigram_word_probability_denominator)

但是,除了'KneserNeyProbDist'的一些引用之外,我没有找到第二种方法。但是,这是三卦!

如何更改上面的代码来计算它?必须从开发集中估计此方法的参数。

nltk smoothing
1个回答
2
投票

在这个答案中,我只是澄清了一些我刚刚发现的关于你的问题的事情,但我无法提供编码解决方案。

所以Modified Kneser–Ney smoothing现在已知并且似乎是最好的解决方案,只需在运行代码中翻译公式旁边的描述仍然是一步。在原始链接文档中显示的文本(屏幕截图上方)下方仍然有一些解释可能有助于理解原始描述。

© www.soinside.com 2019 - 2024. All rights reserved.