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?