nltk.KneserNeyProbDist

class nltk.KneserNeyProbDist(freqdist, bins=None, discount=0.75)[source]

Kneser-Ney estimate of a probability distribution. This is a version of back-off that counts how likely an n-gram is provided the n-1-gram had been seen in training. Extends the ProbDistI interface, requires a trigram FreqDist instance to train on. Optionally, a different from default discount value can be specified. The default discount is set to 0.75.

Methods

__init__(freqdist[, bins, discount])
param freqdist:The trigram frequency distribution upon which to base
discount() Return the value by which counts are discounted.
generate() Return a randomly selected sample from this probability distribution.
logprob(sample) Return the base 2 logarithm of the probability for a given sample.
max()
prob(trigram)
samples()
set_discount(discount) Set the value by which counts are discounted to the value of discount.
unicode_repr() Return a string representation of this ProbDist

Attributes

SUM_TO_ONE