ce74e449dc9526e19596b1c4a9c510bbb35812cc,nltk/lm/smoothing.py,KneserNey,alpha_gamma,#KneserNey#Any#Any#,51

Before Change



    def alpha_gamma(self, word, context):
        prefix_counts = self.counts[context]
        return self.alpha(word, prefix_counts), self.gamma(prefix_counts)

    def alpha(self, word, prefix_counts):
        return max(prefix_counts[word] - self.discount, 0.0) / prefix_counts.N()

After Change


        prefix_total_ngrams = prefix_counts.N()
        alpha = max(prefix_counts[word] - self.discount, 0.0) / prefix_total_ngrams
        gamma = self.discount * _count_non_zero_vals(prefix_counts) / prefix_total_ngrams
        return alpha, gamma
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 3

Instances


Project Name: nltk/nltk
Commit Name: ce74e449dc9526e19596b1c4a9c510bbb35812cc
Time: 2019-08-11
Author: ilia.kurenkov@gmail.com
File Name: nltk/lm/smoothing.py
Class Name: KneserNey
Method Name: alpha_gamma


Project Name: scipy/scipy
Commit Name: ae151484780b389b5c7b4530c9ac1ef4bb659e23
Time: 2020-01-13
Author: rlucas7@users.noreply.github.com
File Name: scipy/special/_basic.py
Class Name:
Method Name: factorial


Project Name: SheffieldML/GPy
Commit Name: c7ac1ed9d89d5dbea6b2d42f3755c6e0cef9878e
Time: 2013-06-04
Author: ibinbei@gmail.com
File Name: GPy/core/priors.py
Class Name:
Method Name: gamma_from_EV


Project Name: nltk/nltk
Commit Name: 2759b03d85983fedd29b646380c713c3f4ccff66
Time: 2018-08-16
Author: ilia.kurenkov@gmail.com
File Name: nltk/lm/smoothing.py
Class Name: WittenBell
Method Name: alpha