allenai / allennlp

An open-source NLP research library, built on PyTorch.
http://www.allennlp.org
Apache License 2.0
11.71k stars 2.24k forks source link

cannot import name 'allowed_transitions' from 'allennlp.modules.conditional_random_field' #5695

Closed KaiyeYang-git closed 1 year ago

KaiyeYang-git commented 1 year ago

I can't import the tweetnlp package with this warning tags, also coming with this address:'Programs\Python\Python39\lib\site-packages\allennlp\modules\conditional_random_field__init__.py'.

Does anyone know what happened?

iamlockelightning commented 1 year ago

+1

erzaliator commented 1 year ago

I have run into the same issue. I am running allennlp==2.10.0 and allennlp-models==2.10.0 . I have to stick to this constraint: allennlp>=2.0,<3.0 But I haven't been able to solve this issue.

iamlockelightning commented 1 year ago

Have made a PR(https://github.com/allenai/allennlp/pull/5697) and waiting for review.

erzaliator commented 1 year ago

So I found that the code was importing sub modules recursively. I went to the respective python scripts that this code was recursively referring to and corrected the imports. The code base was old and I have to change the sciprts to refer to the new path: import allennlp.modules.conditional_random_field.conditional_random_field instead of import allennlp.modules.conditional_random_field

Note: I was using some other library (not tweetnlp) that gave a similar error

KaiyeYang-git commented 1 year ago

Here comes solutions where I solved it already. https://github.com/cardiffnlp/tweetnlp/issues/3