Fix msgpack error

This commit is contained in:
Matthew Honnibal 2018-11-27 19:35:55 +01:00 committed by GitHub
parent ef0820827a
commit 0fdb25b958
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -122,7 +122,7 @@ class GoldCorpus(object):
directory.mkdir()
for i, doc_tuple in enumerate(doc_tuples):
with open(directory / '{}.msg'.format(i), 'wb') as file_:
msgpack.dump([doc_tuple], file_, use_bin_type=True, encoding='utf8')
msgpack.dump([doc_tuple], file_, use_bin_type=True)
@staticmethod
def walk_corpus(path):
@ -153,7 +153,7 @@ class GoldCorpus(object):
gold_tuples = read_json_file(loc)
elif loc.parts[-1].endswith('msg'):
with loc.open('rb') as file_:
gold_tuples = msgpack.load(file_, encoding='utf8')
gold_tuples = msgpack.load(file_, raw=False)
else:
msg = "Cannot read from file: %s. Supported formats: .json, .msg"
raise ValueError(msg % loc)