Skip to content

Commit

Permalink
Add reference to entropy implementation used (#3229)
Browse files Browse the repository at this point in the history
* Add reference to entropy implementation used

Making it more clear that the entropy implementation in NLTK is the one based on the Shannon-McMillan-Breiman theorem, as used and referenced by Jurafsky and Jordan Boyd-Graber.

* Consistently use full names

Co-authored-by: Ilia Kurenkov <ilia.kurenkov@gmail.com>

* Consistency with other docstrings in the module

Co-authored-by: Ilia Kurenkov <ilia.kurenkov@gmail.com>

---------

Co-authored-by: Ilia Kurenkov <ilia.kurenkov@gmail.com>
  • Loading branch information
mbauwens and iliakur committed Jan 29, 2024
1 parent 00de04b commit f2a92bd
Showing 1 changed file with 3 additions and 0 deletions.
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,
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

0 comments on commit f2a92bd

Please sign in to comment.