Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG] fix for loading old word2vec models #1179

Merged
merged 2 commits into from
Mar 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion gensim/models/word2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,14 +1291,15 @@ def load(cls, *args, **kwargs):
return model

def _load_specials(self, *args, **kwargs):
super(Word2Vec, self)._load_specials(*args, **kwargs)
# loading from a pre-KeyedVectors word2vec model
if not hasattr(self, 'wv'):
wv = KeyedVectors()
wv.syn0 = self.__dict__.get('syn0', [])
wv.syn0norm = self.__dict__.get('syn0norm', None)
wv.vocab = self.__dict__.get('vocab', {})
wv.index2word = self.__dict__.get('index2word', [])
self.wv = wv
super(Word2Vec, self)._load_specials(*args, **kwargs)

@classmethod
def load_word2vec_format(cls, fname, fvocab=None, binary=False, encoding='utf8', unicode_errors='strict',
Expand Down
Binary file modified gensim/test/test_data/word2vec_pre_kv_py2
Binary file not shown.
Binary file modified gensim/test/test_data/word2vec_pre_kv_py3
Binary file not shown.
Binary file modified gensim/test/test_data/word2vec_pre_kv_py3_4
Binary file not shown.
Binary file modified gensim/test/test_data/word2vec_pre_kv_sep_py2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified gensim/test/test_data/word2vec_pre_kv_sep_py2.syn0_lockf.npy
Binary file not shown.
Binary file modified gensim/test/test_data/word2vec_pre_kv_sep_py2.syn1neg.npy
Binary file not shown.
Binary file not shown.
Binary file modified gensim/test/test_data/word2vec_pre_kv_sep_py3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified gensim/test/test_data/word2vec_pre_kv_sep_py3.syn0_lockf.npy
Binary file not shown.
Binary file modified gensim/test/test_data/word2vec_pre_kv_sep_py3.syn1neg.npy
Binary file not shown.
Binary file not shown.
Binary file modified gensim/test/test_data/word2vec_pre_kv_sep_py3_4
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified gensim/test/test_data/word2vec_pre_kv_sep_py3_4.syn0_lockf.npy
Binary file not shown.
Binary file modified gensim/test/test_data/word2vec_pre_kv_sep_py3_4.syn1neg.npy
Binary file not shown.
Binary file not shown.