Closed kiran-surya closed 9 years ago
NerTagger has load api. Is there anyway to dump the NerTagger object (as trained model will not be changed )? This is required if we do not want to load tagger object for every test example that comes online.
I'm using save api. But, I'm getting following error:
Traceback (most recent call last):
File "bin/dl-ner.py", line 390, in
Save function is used for serializing NerTagger object. How to deserialize it ? Pickle is not working.
Try Tagger.load(file).
You mean NerTagger.load(file) ?? want to avoid this for every test example.
Once you have loaded the tagger, you can call it many times with new sentences. If you want a service to which you can send sentences for tagging, you need top wrap it in a web service. I do it using Tornado.
I'm using flask. I want to call tagger for every sentence, but i want to load tagger only once. I get sentences online. I tried to serialize tagger, but none of pickle, jsonpickle, dill are working. In the following code: with open(args.model) as file: tagger = NerTagger.load(file) reader = ConllReader() for sent in reader: sent = [x[args.formField] for x in sent] # extract form ConllWriter.write(tagger.tag(sent))
I want to call load only for the first time. In subsequent calls to dl-ner, tagger object should be deserialized and used. But tagger object deserialization using dill/pickle/jsonpickle is not working. Do you have any idea ?
It looks right. Create a new reader for reading the next sentences. You can peruse the tagger object as many times you want the method tagger.tag().
But how to save the tagger object for subsequent calls ?? My problem is tagger object is not getting serialized
You don't need to serialize it. It is already in memory.
Actually, i'm calling dl-ner from web server using subprocess.
Thanks for your help. The issue is resolved now.
Hi,
NER Tagger object is not getting serialized using pickle, jsonpickle or dill. Is this some known issue ?