class documentation
class Lidstone(LanguageModel): (source)
Known subclasses: nltk.lm.Laplace
Constructor: Lidstone(gamma, *args, **kwargs)
Provides Lidstone-smoothed scores.
In addition to initialization arguments from BaseNgramModel also requires a number by which to increase the counts, gamma.
Method | __init__ |
Creates new LanguageModel. |
Method | unmasked |
Add-one smoothing: Lidstone or Laplace. |
Instance Variable | gamma |
Undocumented |
Inherited from 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.__init__
overridden in
nltk.lm.Laplace
Creates new LanguageModel.
of creating a new one when training.
:type vocabulary: nltk.lm.Vocabulary
or None
:param counter: If provided, use this object to count ngrams.
:type vocabulary: nltk.lm.NgramCounter
or None
:param ngrams_fn: If given, defines how sentences in training text are turned to ngram
sequences.
Parameters | |
gamma | Undocumented |
*args | Undocumented |
ngrams | Undocumented |
pad | If given, defines how senteces in training text are padded. |
vocabulary | If provided, this vocabulary will be used instead |
**kwargs | Undocumented |
overrides
nltk.lm.api.LanguageModel.unmasked_score
Add-one smoothing: Lidstone or Laplace.
To see what kind, look at gamma
attribute on the class.