Python NLTK NGrams Error
Question: 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.


Answer: Are you sure you're calling `NgramModel` with the right arguments? Looking at
the [source for the current version of
NLTK](https://github.com/nltk/nltk/blob/master/nltk/model/ngram.py),
`NgramModel` looks like this:

    
    
    def __init__(self, n, train, pad_left=True, pad_right=False,
                     estimator=None, *estimator_args, **estimator_kwargs): 
    

Which doesn't seem to match up to how you're calling the function. What is
`estimator` in your code? Because you're currently passing `estimator` as the
`pad_left` argument.

