Skip to content

Commit

Permalink
chore(nalp): Changes support for gensim v4+.
Browse files Browse the repository at this point in the history
  • Loading branch information
gugarosa committed Jan 19, 2022
1 parent 8a7d8b7 commit f90b2a0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions nalp/encoders/word2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def learn(self, tokens, max_features=128, window_size=5, min_count=1,
"""

self.encoder = W2V(sentences=[tokens], size=max_features, window=window_size, min_count=min_count,
sg=algorithm, alpha=learning_rate, iter=iterations,
self.encoder = W2V(sentences=[tokens], vector_size=max_features, window=window_size, min_count=min_count,
sg=algorithm, alpha=learning_rate, epochs=iterations,
workers=multiprocessing.cpu_count())

def encode(self, tokens):
Expand Down Expand Up @@ -94,7 +94,6 @@ def decode(self, encoded_tokens):

raise RuntimeError(e)

decoded_tokens = [self.encoder.wv.most_similar(
positive=[t])[0][0] for t in encoded_tokens]
decoded_tokens = [self.encoder.wv.most_similar(positive=[t])[0][0] for t in encoded_tokens]

return decoded_tokens
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
coverage>=5.5
gensim>=3.8.3
gensim>=4.1.2
matplotlib>=3.3.4
mido>=1.2.9
nltk>=3.5
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
url='https://github.com/gugarosa/nalp',
license='Apache 2.0',
install_requires=['coverage>=5.5',
'gensim>=3.8.3',
'gensim>=4.1.2',
'matplotlib>=3.3.4',
'mido>=1.2.9',
'nltk>=3.5',
Expand Down

0 comments on commit f90b2a0

Please sign in to comment.