Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reference to entropy implementation used #3229

Merged
merged 9 commits into from
Jan 29, 2024
3 changes: 3 additions & 0 deletions nltk/lm/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ def context_counts(self, context):
def entropy(self, text_ngrams):
"""Calculate cross-entropy of model for given evaluation text.

This implementation is based on the Shannon-McMillan-Breiman theorem,
mbauwens marked this conversation as resolved.
Show resolved Hide resolved
as used and referenced by Dan Jurafsky and Jordan Boyd-Graber.

:param Iterable(tuple(str)) text_ngrams: A sequence of ngram tuples.
:rtype: float

Expand Down