class documentation
Class for providing MLE ngram model scores.
Inherits initialization from BaseNgramModel.
Method | unmasked |
Returns the MLE score for a word given a context. |
Inherited from LanguageModel
:
Method | __init__ |
Creates new LanguageModel. |
Method | context |
Helper method for retrieving counts for a given context. |
Method | entropy |
Calculate cross-entropy of model for given evaluation text. |
Method | fit |
Trains the model on a text. |
Method | generate |
Generate words from the model. |
Method | logscore |
Evaluate the log score of this word in this context. |
Method | perplexity |
Calculates the perplexity of the given text. |
Method | score |
Masks out of vocab (OOV) words and computes their model score. |
Instance Variable | counts |
Undocumented |
Instance Variable | order |
Undocumented |
Instance Variable | vocab |
Undocumented |
overrides
nltk.lm.api.LanguageModel.unmasked_score
Returns the MLE score for a word given a context.
Args: - word is expected to be a string - context is expected to be something reasonably convertible to a tuple