你好,
我正在尝试使用nltk.hmm
模块中的train_unsupervised
方法,但是,它引发了以下TypeError:
TypeError: Can't instantiate abstract class RandomProbDist with abstract methods max
这是我正在使用的代码:
import nltk
trainer = nltk.hmm.HiddenMarkovModelTrainer()
tagger = trainer.train_unsupervised([
('a', ''),
('b', ''),
('c', '')
])
这是完整的错误:
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版本3.2.5; 在Python 2.7.10和Python 2.7.14上进行了测试。
我是不是在做一些愚蠢的错误?
非常感谢你。
使用python 3.6.2和NLTK 3.2.5也会发生这种情况
我正在跟踪问题1873。 我遇到了错误
TypeError:无法使用抽象方法max实例化抽象类RandomProbDist
NLTK版本3.2.4。 我看到致力于解决此问题的提交是3.2.5版,因此我下载了该文件,但仍然遇到相同的错误。 有什么想法吗?
git repo中的更新尚未反映在nltk pip软件包中。 我建议在提交中提取更新并使用它。
最有用的评论
使用python 3.6.2和NLTK 3.2.5也会发生这种情况