Merge pull request #860 from Yiqing-Zhou/patch-1
read().splitlines() -> readlines()
This commit is contained in:
@@ -67,10 +67,10 @@ def load_vocab(vocab_file):
|
|||||||
"""Loads a vocabulary file into a dictionary."""
|
"""Loads a vocabulary file into a dictionary."""
|
||||||
vocab = collections.OrderedDict()
|
vocab = collections.OrderedDict()
|
||||||
with open(vocab_file, "r", encoding="utf-8") as reader:
|
with open(vocab_file, "r", encoding="utf-8") as reader:
|
||||||
tokens = reader.read().splitlines()
|
tokens = reader.readlines()
|
||||||
for index, token in enumerate(tokens):
|
for index, token in enumerate(tokens):
|
||||||
|
token = token.rstrip('\n')
|
||||||
vocab[token] = index
|
vocab[token] = index
|
||||||
index += 1
|
|
||||||
return vocab
|
return vocab
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user