mirror of
https://github.com/explosion/spaCy.git
synced 2025-03-13 16:05:50 +03:00
fix docs_to_json
This commit is contained in:
parent
4e3c7e1f11
commit
478b538e4d
|
@ -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_:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user