I'm running a code to get the perplexity, number of ngrams from a text corpus. While doing it, I got a weird error saying:
C:\Users\Rosenkrantz\Documents\NetBeansProjects\JavaApplication2>python ai7.py
C:\Users\Rosenkrantz\Documents\NetBeansProjects\JavaApplication2>python ai7.py
47510
203044
308837
Traceback (most recent call last):
File "ai7.py", line 95, in <module>
tt=NgramModel(1, tText, estimator)
File "C:\Python27\lib\site-packages\nltk\model\ngram.py", line 81, in __init__
assert(isinstance(pad_left, bool))
AssertionError
The Code I am Running to get this is:
f_in = open("science.txt", 'r');
ln = f_in.read()
words = nltk.word_tokenize(ln)
tText = Text(words)
tt=NgramModel(1, tText, estimator)
tt1=NgramModel(2, tText1, estimator)
tt2=NgramModel(3, tText2, estimator)
All the imports seem to be proper.