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

Fix local import degrading the performance of word2vec model loading … #2682

Merged
merged 1 commit into from
Nov 21, 2019
Merged
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
5 changes: 3 additions & 2 deletions gensim/models/utils_any2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import logging
from gensim import utils
import gensim.models.keyedvectors

from numpy import zeros, dtype, float32 as REAL, ascontiguousarray, frombuffer

Expand Down Expand Up @@ -150,7 +151,7 @@ def _save_word2vec_format(fname, vocab, vectors, fvocab=None, binary=False, tota


def _add_word_to_result(result, counts, word, weights, vocab_size):
from gensim.models.keyedvectors import Vocab

word_id = len(result.vocab)
if word in result.vocab:
logger.warning("duplicate word '%s' in word2vec file, ignoring all but first", word)
Expand All @@ -165,7 +166,7 @@ def _add_word_to_result(result, counts, word, weights, vocab_size):
logger.warning("vocabulary file is incomplete: '%s' is missing", word)
word_count = None

result.vocab[word] = Vocab(index=word_id, count=word_count)
result.vocab[word] = gensim.models.keyedvectors.Vocab(index=word_id, count=word_count)
result.vectors[word_id] = weights
result.index2word.append(word)

Expand Down