Hi,
I used to use nltk.models.NgramModel for tri-gram modeling. I am trying to run old code with a new installation of nltk 3 and it seems that the module is not longer available. I have downloaded all models and packages through nltk.download() and I am still getting
"No module named model"
when I try
from nltk.model import NgramModel
any help?
thank you
Hey there! Yeah, they're currently not in the master branch -- there are some outstanding bugs that we would like to fix before including them again. These are the bugs: https://github.com/nltk/nltk/labels/model
If you're currently using the version from github, you can switch to the "model" branch, which includes the NgramModel code, though it's currently significantly behind the "develop" branch and hasn't picked up all the newest bug fixes.
Hope this helps!
thank you Alex
What's the current status of this bug?
I'll be pushing a regression/unit tested version of the NgramModel in the next couple of days.
I'm also interested in contributing.
Has this been solved? I still cannot import model
I still cannot import model in version nltk-3.2.2
Installed with:
pip3 install https://github.com/nltk/nltk/tarball/model
But I got a different error now:
ImportError: cannot import name 'NgramModel'
Please view the source code
I code a sample.
from nltk.model import MLENgramModel
from nltk.model import build_vocabulary
from nltk.model import count_ngrams
docs = [['a', 'b', 'c'], ['a', 'c', 'c']]
vocab = build_vocabulary(cutoff, *docs)
counter = count_ngrams(order, vocab, *docs)
model = MLENgramModel(counter)
nltk.model
is still not available. Odd.
@bjourne the reworked module should be importable as nltk.lm
. The API has changed, I recommend reading the docs for it:
>>> from nltk import lm
>>> help(lm)
This is not still solved?
It was resolved last year, Please see the nltk.lm documentation
Most helpful comment
I'll be pushing a regression/unit tested version of the NgramModel in the next couple of days.