Nltk: HiddenMarkovModelTrainer train_unsupervised - TypeError

Created on 14 Oct 2017  ·  3Comments  ·  Source: nltk/nltk

Hello,

I'm trying to use the train_unsupervised method from the nltk.hmm module, however, it's throwing the following TypeError:
TypeError: Can't instantiate abstract class RandomProbDist with abstract methods max

Here is the code I'm using:

import nltk

trainer = nltk.hmm.HiddenMarkovModelTrainer()
tagger = trainer.train_unsupervised([
    ('a', ''),
    ('b', ''),
    ('c', '')
])

Here's the full error:
Traceback (most recent call last): File "test.py", line 10, in <module> ('c', '') File "/Library/Python/2.7/site-packages/nltk/tag/hmm.py", line 932, in train_unsupervised priors = RandomProbDist(self._states) TypeError: Can't instantiate abstract class RandomProbDist with abstract methods max

NLTK version 3.2.5; tested on Python 2.7.10 and Python 2.7.14.

Am I doing something silly wrong?

Thank you very much.

bug language-model tagger

Most helpful comment

This also happens using python 3.6.2 with NLTK 3.2.5

All 3 comments

This also happens using python 3.6.2 with NLTK 3.2.5

I am following up on issue #1873. I was getting the error
TypeError: Can't instantiate abstract class RandomProbDist with abstract methods max

with NLTK version 3.2.4. I saw the commit to fix this issue was in version 3.2.5 so I downloaded that but I still get the same error. Any ideas why?

The updates in the git repo aren't yet reflected in the nltk pip package. I would suggest pulling the updates in the commits and working with it.

Was this page helpful?
0 / 5 - 0 ratings