elitcloud / elit

🔠 Evolution of Language and Information Technology
https://elit.cloud
Other
47 stars 7 forks source link

Should avoid to use project relative path to load file #31

Closed imgarylai closed 5 years ago

imgarylai commented 5 years ago

https://github.com/elitcloud/elit/blob/c8fc984e926e957e21093a44d04096a0e14db9bc/elit/nlp/dep/parser/parser.py#L165

self._config.save_vocab_path is specified as a relative path in the config path. However, it causes problem if resources file are not in the same directory.

imgarylai commented 5 years ago

I don't know if this was caused by this patch.

>>> import mxnet as mx
>>> from elit.nlp.dep.parser.parser import BiaffineParser
>>> path = '/home/hhe43/elit/data/model/dep/jumbo-fasttext100'
>>> parser = BiaffineParser(context=mx.gpu(0))
>>> parser.load(path)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/glai2/elit/elit/nlp/dep/parser/parser.py", line 166, in load
    self._vocab = ParserVocabulary.load(self._config.save_vocab_path)
  File "/home/glai2/elit/elit/nlp/dep/common/savable.py", line 31, in load
    return pickle.load(f)
ModuleNotFoundError: No module named 'elit.dep'
>>>
hankcs commented 5 years ago

No, the model class was in 'elit.dep', after moving away, pickle complaints this. Let me try to make a new pickle file.

hankcs commented 5 years ago

I've just updated elit/data/model/dep/jumbo-fasttext100 in my home path. Please try it.

imgarylai commented 5 years ago

Data has been updated.