nikitakit / self-attentive-parser

High-accuracy NLP parser with models for 11 languages.
https://parser.kitaev.io/
MIT License
871 stars 153 forks source link

Cannot load model when its name unicode #13

Closed suhassumukh closed 5 years ago

suhassumukh commented 5 years ago

One of the most problematic things in Py2 is unicode and str. To backport several features, I (and so do many) usually use

from __future__ import unicode_literals

This means when I import your model benepar_en_small, I get an error.

parser = BeneparComponent("benepar_en_small")
Exception: Argument is neither a valid module name nor a path to an existing file: benepar_en_small

This is because of

            if isinstance(name, str) and '/' not in name:
                graph_def = tf.GraphDef.FromString(load_model(name))

I think making it basestring instead of just str can resolve this issue. Please let me know if this is comfortable.

nikitakit commented 5 years ago

This should be fixed as of the v0.1.0 release today. Thank you for reporting!

I've also addressed a lot of corner cases involving the combination of unicode_literals and other parts of the parser API, especially the NLTK integration. Please open an issue if anything else comes up!