I have started learning NLTK
and I am following a tutorial from here, where they find conditional probability using bigrams like this.
import nltk
from nltk.corpus import brown
cfreq_brown_2gram = nltk.ConditionalFreqDist(nltk.bigrams(brown.words()))
However I want to find conditional probability using trigrams. When I try to change nltk.bigrams
to nltk.trigrams
I get the following error.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "home/env/local/lib/python2.7/site-packages/nltk/probability.py", line 1705, in __init__
for (cond, sample) in cond_samples:
ValueError: too many values to unpack (expected 2)
How can I calculate the conditional probability using trigrams?