nltk calc perplexity of bigram/trigram

822 views Asked by At

I train bgram,trigram:

bgram = bigrams(sentences)
trigram = trigrams(sentences)

And want to calculate perplexity:

p = bgram.perplexity

But get an error:

AttributeError: 'generator' object has no attribute 'perplexity'

How perplexity should be calculated?

0

There are 0 answers