diff --git a/spacy/cli/convert.py b/spacy/cli/convert.py index 67f97f632..2d8661339 100644 --- a/spacy/cli/convert.py +++ b/spacy/cli/convert.py @@ -57,7 +57,8 @@ def convert( is written to stdout, so you can pipe them forward to a JSON file: $ spacy convert some_file.conllu > some_file.json """ - msg = Printer() + no_print = (output_dir == "-") + msg = Printer(no_print=no_print) input_path = Path(input_file) if file_type not in FILE_TYPES: msg.fail( @@ -102,6 +103,7 @@ def convert( use_morphology=morphology, lang=lang, model=model, + no_print=no_print, ) if output_dir != "-": # Export data to a file diff --git a/spacy/cli/converters/conll_ner2json.py b/spacy/cli/converters/conll_ner2json.py index a3a37d6c9..3d0e4d308 100644 --- a/spacy/cli/converters/conll_ner2json.py +++ b/spacy/cli/converters/conll_ner2json.py @@ -9,7 +9,7 @@ from ...tokens.doc import Doc from ...util import load_model -def conll_ner2json(input_data, n_sents=10, seg_sents=False, model=None, **kwargs): +def conll_ner2json(input_data, n_sents=10, seg_sents=False, model=None, no_print=False, **kwargs): """ Convert files in the CoNLL-2003 NER format and similar whitespace-separated columns into JSON format for use with train cli. @@ -34,7 +34,7 @@ def conll_ner2json(input_data, n_sents=10, seg_sents=False, model=None, **kwargs . O """ - msg = Printer() + msg = Printer(no_print=no_print) doc_delimiter = "-DOCSTART- -X- O O" # check for existing delimiters, which should be preserved if "\n\n" in input_data and seg_sents: diff --git a/spacy/cli/converters/iob2json.py b/spacy/cli/converters/iob2json.py index 740f29001..61c398f8d 100644 --- a/spacy/cli/converters/iob2json.py +++ b/spacy/cli/converters/iob2json.py @@ -8,7 +8,7 @@ from ...util import minibatch from .conll_ner2json import n_sents_info -def iob2json(input_data, n_sents=10, *args, **kwargs): +def iob2json(input_data, n_sents=10, no_print=False, *args, **kwargs): """ Convert IOB files with one sentence per line and tags separated with '|' into JSON format for use with train cli. IOB and IOB2 are accepted. @@ -20,7 +20,7 @@ def iob2json(input_data, n_sents=10, *args, **kwargs): I|PRP|O like|VBP|O London|NNP|I-GPE and|CC|O New|NNP|B-GPE York|NNP|I-GPE City|NNP|I-GPE .|.|O I|PRP|O like|VBP|O London|NNP|B-GPE and|CC|O New|NNP|B-GPE York|NNP|I-GPE City|NNP|I-GPE .|.|O """ - msg = Printer() + msg = Printer(no_print=no_print) docs = read_iob(input_data.split("\n")) if n_sents > 0: n_sents_info(msg, n_sents)