简体   繁体   中英

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

It was fine if I use another model

Pickle cannot dump Python objects. Use dill instead of pickle: https://pypi.org/project/dill/ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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