简体   繁体   English

在 python 中存储 crf 标记器

[英]store crf Tagger in python

crf_tagger = CRFTagger()
crf_tagger.train(train_sents,'/tmp/crf_tagger.model')
#Store CRFT.
from pickle import dump
output = open('crfTagger.pkl', 'wb')
dump(crf_tagger, output, -1)
output.close()

When I ran the part above, then got:当我运行上面的部分时,得到:

TypeError: self.c_tagger cannot be converted to a Python object for pickling TypeError: self.c_tagger 不能转换为 Python object 用于酸洗

It was fine if I use another model如果我使用另一个 model 就好了

Pickle cannot dump Python objects. Pickle 无法转储 Python 对象。 Use dill instead of pickle: https://pypi.org/project/dill/ .使用莳萝代替泡菜: https://pypi.org/project/dill/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM