A processing interface for assigning a probability to the next
word.
|
|
__init__(self,
n,
train,
estimator=None)
Creates an ngram language model to capture patterns in n consecutive
words of training text. |
source code
|
|
|
|
prob(self,
word,
context)
Evaluate the probability of this word in this context. |
source code
|
|
|
|
|
|
|
|
|
|
logprob(self,
word,
context)
Evaluate the (negative) log probability of this word in this context. |
source code
|
|
|
|
|
|
|
generate(self,
num_words,
context=())
Generate random text based on the language model. |
source code
|
|
|
|
|
|
|
entropy(self,
text)
Evaluate the total entropy of a text with respect to the model. |
source code
|
|
|
|
|
|
|
|
|
|
|