hipster-philology / pandora

A Tagger-Lemmatizer for Natural Languages
MIT License
9 stars 4 forks source link

Error in annotating new data: Preprocessor' object has no attribute 'include_morph' #74

Closed Jean-Baptiste-Camps closed 7 years ago

Jean-Baptiste-Camps commented 7 years ago

When trying to annotate new data, with a model that includes morphology (label or multilabel), I encounter the following error:

Loading known lemmas...
Tagger loaded, now annotating...
     + test.txt
Traceback (most recent call last):
  File "tagger.py", line 6, in <module>
    cli_tagger()
  File "/home/jbc/Data/F/pandora/pandora_testing/hipster-philology/pandora/pandora/cli.py", line 255, in cli_tagger
    tag_dir(**vars(args))
  File "/home/jbc/Data/F/pandora/pandora_testing/hipster-philology/pandora/pandora/cli.py", line 186, in tag_dir
    annotations = tagger.annotate(unseen_tokens)
  File "/home/jbc/Data/F/pandora/pandora_testing/hipster-philology/pandora/pandora/tagger.py", line 689, in annotate
    predictions=preds['morph_out'])
  File "/home/jbc/Data/F/pandora/pandora_testing/hipster-philology/pandora/pandora/preprocessing.py", line 619, in inverse_transform_morph
    if self.include_morph == 'label':
AttributeError: 'Preprocessor' object has no attribute 'include_morph'
Exception ignored in: <bound method BaseSession.__del__ of <tensorflow.python.client.session.Session object at 0x7f94ac47bf60>>
Traceback (most recent call last):
  File "/home/jbc/Data/F/pandora/pandora_testing/hipster-philology/pandora/env/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 587, in __del__
AttributeError: 'NoneType' object has no attribute 'TF_NewStatus'

Ignoring the final exception, it seems that the parameter include_morph is not available at this point. I started looking, but do not find the problem for now.

Jean-Baptiste-Camps commented 7 years ago

Ok, apparently it is because the Preprocessor.load does not include morph, and I don't see it being saved either. Did we loose those functionalities at some point ?

PonteIneptique commented 7 years ago

This is not a main issue fix but I have something to avoid this issue. This comes down to variable not being set to None before the if,

PonteIneptique commented 7 years ago

Looking at Preprocessor, it seems that the morph data is not persisted (I can't find a line like

self.morph_encoder.save()

as it's the case for lemma_encoder and pos_encoder.

Jean-Baptiste-Camps commented 7 years ago

Solved by #75 .