mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-10 19:57:17 +03:00
Use spacy.compat.json_dumps for Python 2/3 compatibility (resolves #991)
This commit is contained in:
parent
0605b95f2e
commit
48da244058
|
@ -2,6 +2,7 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
from ...compat import json_dumps
|
||||||
from ... import util
|
from ... import util
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +30,8 @@ def conllu2json(input_path, output_path, n_sents=10, use_morphology=False):
|
||||||
|
|
||||||
output_filename = input_path.parts[-1].replace(".conllu", ".json")
|
output_filename = input_path.parts[-1].replace(".conllu", ".json")
|
||||||
output_file = output_path / output_filename
|
output_file = output_path / output_filename
|
||||||
json.dump(docs, output_file.open('w', encoding='utf-8'), indent=2)
|
with output_file.open('w', encoding='utf-8') as f:
|
||||||
|
f.write(json_dumps(docs))
|
||||||
util.print_msg("Created {} documents".format(len(docs)),
|
util.print_msg("Created {} documents".format(len(docs)),
|
||||||
title="Generated output file {}".format(output_file))
|
title="Generated output file {}".format(output_file))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user