From 406a0dc661f34038645469c64fbda6cac3f33dc4 Mon Sep 17 00:00:00 2001 From: Jan Stypka Date: Tue, 27 Aug 2019 21:19:04 +0200 Subject: [PATCH] Bump deps --- .travis.yml | 3 +-- magpie/base/word2vec.py | 8 ++++---- magpie/main.py | 4 ++-- magpie/nn/input_data.py | 4 ++-- setup.py | 17 ++++++++--------- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4320eca..eb0cec5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,7 @@ language: python sudo: false python: - - 2.7 - - 3.6 + - 3.7 notifications: email: diff --git a/magpie/base/word2vec.py b/magpie/base/word2vec.py index 0b92887..af4689d 100644 --- a/magpie/base/word2vec.py +++ b/magpie/base/word2vec.py @@ -50,8 +50,8 @@ def compute_word2vec_for_phrase(phrase, model): """ result = np.zeros(model.vector_size, dtype='float32') for word in phrase.split(): - if word in model: - result += model[word] + if word in model.wv: + result += model.wv[word] return result @@ -78,8 +78,8 @@ def fit_scaler(data_dir, word2vec_model, batch_size=1024, persist_to_path=None): vectors = [] for doc in batch: for word in doc.get_all_words(): - if word in word2vec_model: - vectors.append(word2vec_model[word]) + if word in word2vec_model.wv: + vectors.append(word2vec_model.wv[word]) matrix = np.array(vectors) print("Fitted to {} vectors".format(matrix.shape[0])) diff --git a/magpie/main.py b/magpie/main.py index 8172748..3919ce9 100644 --- a/magpie/main.py +++ b/magpie/main.py @@ -210,8 +210,8 @@ def _predict(self, doc): x_matrix = np.zeros((1, sample_length, embedding_size)) for i, w in enumerate(words): - if w in self.word2vec_model: - word_vector = self.word2vec_model[w].reshape(1, -1) + if w in self.word2vec_model.wv: + word_vector = self.word2vec_model.wv[w].reshape(1, -1) scaled_vector = self.scaler.transform(word_vector, copy=True)[0] x_matrix[doc.doc_id][i] = scaled_vector diff --git a/magpie/nn/input_data.py b/magpie/nn/input_data.py index ca2b0fb..8ea9978 100644 --- a/magpie/nn/input_data.py +++ b/magpie/nn/input_data.py @@ -73,8 +73,8 @@ def build_x_and_y(filenames, file_directory, **kwargs): words = doc.get_all_words()[:SAMPLE_LENGTH] for i, w in enumerate(words): - if w in word2vec_model: - word_vector = word2vec_model[w].reshape(1, -1) + if w in word2vec_model.wv: + word_vector = word2vec_model.wv[w].reshape(1, -1) x_matrix[doc_id][i] = scaler.transform(word_vector, copy=True)[0] labels = get_answers_for_doc( diff --git a/setup.py b/setup.py index 5d0e6d3..c874a2d 100644 --- a/setup.py +++ b/setup.py @@ -52,7 +52,6 @@ # Specify the Python versions you support here. In particular, ensure # that you indicate whether you support Python 2, Python 3 or both. - 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', ], @@ -68,14 +67,14 @@ # requirements files see: # https://packaging.python.org/en/latest/requirements.html install_requires=[ - 'nltk~=3.2', - 'numpy~=1.12', - 'scipy~=0.18', - 'gensim~=0.13', - 'scikit-learn~=0.18', - 'keras~=2.1.6', - 'h5py~=2.6', - 'tensorflow~=1.11.0' + 'nltk~=3.4', + 'numpy~=1.17', + 'scipy~=1.3.1', + 'gensim~=3.8.0', + 'scikit-learn~=0.21.3', + 'keras~=2.2.5', + 'h5py~=2.9', + 'tensorflow~=1.14.0' ], # List additional groups of dependencies here (e.g. development