Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #134 from nickyeolk/glove_error
Browse files Browse the repository at this point in the history
add explicit encoding for opening w2v to allow code to work on windows
  • Loading branch information
Alex Conneau committed Aug 29, 2019
2 parents a987923 + 9b87282 commit 31eede6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions models.py
Expand Up @@ -104,7 +104,7 @@ def get_w2v(self, word_dict):
assert hasattr(self, 'w2v_path'), 'w2v path not set'
# create word_vec with w2v vectors
word_vec = {}
with open(self.w2v_path) as f:
with open(self.w2v_path, encoding='utf-8') as f:
for line in f:
word, vec = line.split(' ', 1)
if word in word_dict:
Expand All @@ -117,7 +117,7 @@ def get_w2v_k(self, K):
# create word_vec with k first w2v vectors
k = 0
word_vec = {}
with open(self.w2v_path) as f:
with open(self.w2v_path, encoding='utf-8') as f:
for line in f:
word, vec = line.split(' ', 1)
if k <= K:
Expand Down

0 comments on commit 31eede6

Please sign in to comment.