vec2graph icon indicating copy to clipboard operation
vec2graph copied to clipboard

`vec2graph` not working with Gensim 4.0

Open karelin opened this issue 2 years ago • 3 comments

Attempt to run vec2graph with gensim=4.0.0 produces error:

Traceback (most recent call last): File "graphs.py", line 13, in visualize('graphs', model, 'party') File "C:\Anaconda\lib\site-packages\vec2graph\genviz.py", line 146, in visualize data = get_data(model, words, depth=depth, topn=topn) File "C:\Anaconda\lib\site-packages\vec2graph\genviz.py", line 23, in get_data if word not in model.vocab: File "C:\Anaconda\lib\site-packages\gensim-4.0.1-py3.8-win-amd64.egg\gensim\models\keyedvectors.py", line 645, in vocab raise AttributeError( AttributeError: The vocab attribute was removed from KeyedVector in Gensim 4.0.0. Use KeyedVector's .key_to_index dict, .index_to_key list, and methods .get_vecattr(key, attr) and .set_vecattr(key, attr, new_val) instead. See https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4

karelin avatar Aug 10 '21 09:08 karelin

Quick fix is replace model.vocab to model.index_to_key in line 25 of genviz.py

karelin avatar Aug 10 '21 14:08 karelin

Thanks for the report! There are many breaking changes in Gensim 4, so we still continue to use Gensim 3.8.3 in most of our servers.

However, the fix for this particular issue is even simpler, see this commit

Can you confirm it works for you in Gensim 4?

akutuzov avatar Aug 10 '21 16:08 akutuzov

Thanks for the report! There are many breaking changes in Gensim 4, so we still continue to use Gensim 3.8.3 in most of our servers.

However, the fix for this particular issue is even simpler, see this commit

Can you confirm it works for you in Gensim 4?

I installed the vec2graph library directly from the repository, I can confirm the functionality for the last release version of Gensim 4.1.2

malakhovks avatar Dec 20 '21 19:12 malakhovks