fix docs_to_json

This commit is contained in:
svlandeg 2020-06-22 17:09:23 +02:00
parent 4e3c7e1f11
commit 478b538e4d

View File

@ -4,9 +4,9 @@ from pathlib import Path
from wasabi import Printer from wasabi import Printer
import srsly import srsly
import re import re
import sys
from ._app import app, Arg, Opt from ._app import app, Arg, Opt
from ..gold import docs_to_json
from ..tokens import DocBin from ..tokens import DocBin
from ..gold.converters import iob2docs, conll_ner2docs, json2docs from ..gold.converters import iob2docs, conll_ner2docs, json2docs
@ -26,7 +26,7 @@ CONVERTERS = {
} }
# File types # File types that can be written to stdout
FILE_TYPES_STDOUT = ("json") FILE_TYPES_STDOUT = ("json")
@ -81,6 +81,7 @@ def convert_cli(
msg=msg, msg=msg,
) )
def convert( def convert(
input_path: Path, input_path: Path,
output_dir: Path, output_dir: Path,
@ -124,7 +125,7 @@ def convert(
if not output_file.parent.exists(): if not output_file.parent.exists():
output_file.parent.mkdir(parents=True) output_file.parent.mkdir(parents=True)
if file_type == "json": if file_type == "json":
srsly.write_json(output_file, docs2json(docs)) srsly.write_json(output_file, docs_to_json(docs))
else: else:
data = DocBin(docs=docs).to_bytes() data = DocBin(docs=docs).to_bytes()
with output_file.open("wb") as file_: with output_file.open("wb") as file_: