Python nltk.tag.hmm 上的 HMM 标注器 _pickle.PicklingError 属性查找估计器失败
Python HMM tagger _pickle.PicklingError attribute lookup estimator on nltk.tag.hmm failed
我正在尝试在 PTB 语料库上评估 Python HMM 标注器,然后输出到文件。
train_data = treebank.tagged_sents()[:3523]
test_data = treebank.tagged_sents()[3523:]
hmm_pos_tagger = hmm.HiddenMarkovModelTagger.train(train_data)
print('HMM = %0.5f' % hmm_pos_tagger.evaluate(test_data))
output = open('tagger_hmm.pickle', 'wb', -1)
pickle.dump(hmm_pos_tagger, output)
output.close()
这是以下输出:
HMM = 0.89920
...
line 56, in <module>
pickle.dump(hmm_pos_tagger, output)
_pickle.PicklingError: Can't pickle <function HiddenMarkovModelTagger._train.<locals>.estimator at 0x05A59300>: attribute lookup estimator on nltk.tag.hmm failed
我已经试过 TnT & Brill tagger 但没有错误。我做错了什么?
我试着用莳萝代替泡菜,结果很管用。
我正在尝试在 PTB 语料库上评估 Python HMM 标注器,然后输出到文件。
train_data = treebank.tagged_sents()[:3523]
test_data = treebank.tagged_sents()[3523:]
hmm_pos_tagger = hmm.HiddenMarkovModelTagger.train(train_data)
print('HMM = %0.5f' % hmm_pos_tagger.evaluate(test_data))
output = open('tagger_hmm.pickle', 'wb', -1)
pickle.dump(hmm_pos_tagger, output)
output.close()
这是以下输出:
HMM = 0.89920
...
line 56, in <module>
pickle.dump(hmm_pos_tagger, output)
_pickle.PicklingError: Can't pickle <function HiddenMarkovModelTagger._train.<locals>.estimator at 0x05A59300>: attribute lookup estimator on nltk.tag.hmm failed
我已经试过 TnT & Brill tagger 但没有错误。我做错了什么?
我试着用莳萝代替泡菜,结果很管用。