Skip to content

Commit

Permalink
open file explicitely using utf-8 (pytorch#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
siran authored and soumith committed Jun 4, 2018
1 parent f982047 commit f835081
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions word_language_model/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def tokenize(self, path):
"""Tokenizes a text file."""
assert os.path.exists(path)
# Add words to the dictionary
with open(path, 'r') as f:
with open(path, 'r', encoding="utf8") as f:
tokens = 0
for line in f:
words = line.split() + ['<eos>']
Expand All @@ -36,7 +36,7 @@ def tokenize(self, path):
self.dictionary.add_word(word)

# Tokenize file content
with open(path, 'r') as f:
with open(path, 'r', encoding="utf8") as f:
ids = torch.LongTensor(tokens)
token = 0
for line in f:
Expand Down

0 comments on commit f835081

Please sign in to comment.