Skip to content

Commit

Permalink
Replace open() by smart_open() in `gensim.models.fasttext._load_f…
Browse files Browse the repository at this point in the history
…asttext_format` (#2335)

* replaced open by smart_open

* updated smart_open() version

* updated smart_open() version
  • Loading branch information
rsdel2007 authored and menshikh-iv committed Jan 17, 2019
1 parent 5509bd3 commit ea611b4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gensim/models/fasttext.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@
from numpy import ones, vstack, float32 as REAL, sum as np_sum
import six

# TODO use smart_open again when https://github.com/RaRe-Technologies/smart_open/issues/207 will be fixed
import gensim.models._fasttext_bin

from gensim.models.word2vec import Word2VecVocab, Word2VecTrainables, train_sg_pair, train_cbow_pair
from gensim.models.keyedvectors import FastTextKeyedVectors
from gensim.models.base_any2vec import BaseWordEmbeddingsModel
from gensim.models.utils_any2vec import _compute_ngrams, _ft_hash, _ft_hash_broken
from smart_open import smart_open

from gensim.utils import deprecated, call_on_class_only

Expand Down Expand Up @@ -979,7 +979,7 @@ def _load_fasttext_format(model_file, encoding='utf-8'):
"""
if not model_file.endswith('.bin'):
model_file += '.bin'
with open(model_file, 'rb') as fin:
with smart_open(model_file, 'rb') as fin:
m = gensim.models._fasttext_bin.load(fin, encoding=encoding)

model = FastText(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def finalize_options(self):
'numpy >= 1.11.3',
'scipy >= 0.18.1',
'six >= 1.5.0',
'smart_open >= 1.2.1',
'smart_open >= 1.7.0',
],
tests_require=linux_testenv,
extras_require={
Expand Down

0 comments on commit ea611b4

Please sign in to comment.