mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-06 21:30:22 +03:00
black
This commit is contained in:
parent
a9991abf8f
commit
185293aa78
|
@ -14,22 +14,27 @@ from ..vocab import Vocab
|
||||||
from ..util import ensure_path, load_model
|
from ..util import ensure_path, load_model
|
||||||
|
|
||||||
|
|
||||||
path_help = ("Location of the documents to predict on. "
|
path_help = (
|
||||||
"Can be a single file in .spacy format or a "
|
"Location of the documents to predict on. "
|
||||||
".jsonl file. Files with other extensions "
|
"Can be a single file in .spacy format or a "
|
||||||
"are treated as single plain text documents. "
|
".jsonl file. Files with other extensions "
|
||||||
"If a directory is provided "
|
"are treated as single plain text documents. "
|
||||||
"it is traversed recursively to grab all files to "
|
"If a directory is provided "
|
||||||
"be processed. The files can be a mixture of .spacy, "
|
"it is traversed recursively to grab all files to "
|
||||||
".jsonl and text files. If .jsonl is provided the "
|
"be processed. The files can be a mixture of .spacy, "
|
||||||
"specified field is going to be grabbed ('text' "
|
".jsonl and text files. If .jsonl is provided the "
|
||||||
"by default).")
|
"specified field is going to be grabbed ('text' "
|
||||||
|
"by default)."
|
||||||
|
)
|
||||||
out_help = "Path where to save the result .spacy file"
|
out_help = "Path where to save the result .spacy file"
|
||||||
code_help = ("Path to Python file with additional "
|
code_help = (
|
||||||
"code (registered functions) to be imported")
|
"Path to Python file with additional " "code (registered functions) to be imported"
|
||||||
|
)
|
||||||
gold_help = "Use gold preprocessing provided in the .spacy files"
|
gold_help = "Use gold preprocessing provided in the .spacy files"
|
||||||
force_msg = ("The provided output file already exists. "
|
force_msg = (
|
||||||
"To force overwriting the output file, set the --force or -F flag.")
|
"The provided output file already exists. "
|
||||||
|
"To force overwriting the output file, set the --force or -F flag."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
DocOrStrStream = Union[Iterable[str], Iterable[Doc]]
|
DocOrStrStream = Union[Iterable[str], Iterable[Doc]]
|
||||||
|
@ -52,8 +57,7 @@ def _stream_jsonl(path: Path, field: str) -> Iterable[str]:
|
||||||
for entry in srsly.read_jsonl(path):
|
for entry in srsly.read_jsonl(path):
|
||||||
if field not in entry:
|
if field not in entry:
|
||||||
raise msg.fail(
|
raise msg.fail(
|
||||||
f"{path} does not contain the required '{field}' field.",
|
f"{path} does not contain the required '{field}' field.", exits=1
|
||||||
exits=1
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
yield entry[field]
|
yield entry[field]
|
||||||
|
@ -64,7 +68,7 @@ def _stream_texts(paths: Iterable[Path]) -> Iterable[str]:
|
||||||
Yields strings from text files in paths.
|
Yields strings from text files in paths.
|
||||||
"""
|
"""
|
||||||
for path in paths:
|
for path in paths:
|
||||||
with open(path, 'r') as fin:
|
with open(path, "r") as fin:
|
||||||
text = fin.read()
|
text = fin.read()
|
||||||
yield text
|
yield text
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user