jmacwan / POSPair

Simplifying representation for Natural Language Processing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ImportError: cannot import name '_compute_ngrams' from 'gensim.models.utils_any2vec

tburleyinfo opened this issue · comments

I have gensim installed but I keep getting errors similar to this one when I import POSpair.

The code I'm using:

import POSPair
sentences = POSPair.POSPairWordEmbeddings(data[0])

Output:

Traceback (most recent call last):
  File "DIVISIVE.py", line 90, in <module>
    import POSPair
  File "/usr/local/lib/python3.7/site-packages/POSPair/__init__.py", line 1, in <module>
    import POSPair.NLP_POSPair
  File "/usr/local/lib/python3.7/site-packages/POSPair/NLP_POSPair.py", line 7, in <module>
    from POSPairWordEmbeddings.gensim.models import Word2Vec as POSPairWE
  File "/usr/local/lib/python3.7/site-packages/POSPairWordEmbeddings/gensim/models/__init__.py", line 16, in <module>
    from .keyedvectors import KeyedVectors  # noqa:F401
  File "/usr/local/lib/python3.7/site-packages/POSPairWordEmbeddings/gensim/models/keyedvectors.py", line 188, in <module>
    from gensim.models.utils_any2vec import _save_word2vec_format, _load_word2vec_format, _compute_ngrams, _ft_hash
ImportError: cannot import name '_compute_ngrams' from 'gensim.models.utils_any2vec' (/usr/local/lib/python3.7/site-packages/gensim/models/utils_any2vec.py)

I should note the variable data[0] being used is a list of sentences.

Hello @tburleyinfo ,
Thanks for bringing up the issue.
It's okay if you don't install gensim library additionally, as POSPair already packages it together.
A fix might be to just use POSPair without importing gensim additionally in the same program. I am sorry for the inconvenience you may face for development due to this.