Open karelin opened 3 years ago
Quick fix is replace model.vocab
to model.index_to_key
in line 25 of genviz.py
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?
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
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