From cc05d9dad6de5f74af13ba73d959d2ef80521385 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Thu, 24 Oct 2019 16:21:08 +0200 Subject: [PATCH] Auto-format [ci skip] --- spacy/cli/convert.py | 2 +- spacy/cli/converters/conll_ner2json.py | 4 +++- spacy/tests/regression/test_issue3001-3500.py | 6 ++++-- spacy/tests/test_gold.py | 6 +++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/spacy/cli/convert.py b/spacy/cli/convert.py index 2d8661339..fa867fa04 100644 --- a/spacy/cli/convert.py +++ b/spacy/cli/convert.py @@ -57,7 +57,7 @@ def convert( is written to stdout, so you can pipe them forward to a JSON file: $ spacy convert some_file.conllu > some_file.json """ - no_print = (output_dir == "-") + no_print = output_dir == "-" msg = Printer(no_print=no_print) input_path = Path(input_file) if file_type not in FILE_TYPES: diff --git a/spacy/cli/converters/conll_ner2json.py b/spacy/cli/converters/conll_ner2json.py index 3d0e4d308..46489ad7c 100644 --- a/spacy/cli/converters/conll_ner2json.py +++ b/spacy/cli/converters/conll_ner2json.py @@ -9,7 +9,9 @@ from ...tokens.doc import Doc from ...util import load_model -def conll_ner2json(input_data, n_sents=10, seg_sents=False, model=None, no_print=False, **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. diff --git a/spacy/tests/regression/test_issue3001-3500.py b/spacy/tests/regression/test_issue3001-3500.py index 8ed243051..63836e7bd 100644 --- a/spacy/tests/regression/test_issue3001-3500.py +++ b/spacy/tests/regression/test_issue3001-3500.py @@ -297,8 +297,10 @@ def test_issue3410(): def test_issue3412(): data = numpy.asarray([[0, 0, 0], [1, 2, 3], [9, 8, 7]], dtype="f") vectors = Vectors(data=data) - keys, best_rows, scores = vectors.most_similar(numpy.asarray([[9, 8, 7], [0, 0, 0]], dtype="f")) - assert(best_rows[0] == 2) + keys, best_rows, scores = vectors.most_similar( + numpy.asarray([[9, 8, 7], [0, 0, 0]], dtype="f") + ) + assert best_rows[0] == 2 def test_issue3447(): diff --git a/spacy/tests/test_gold.py b/spacy/tests/test_gold.py index 01eaa51be..a7c29f8db 100644 --- a/spacy/tests/test_gold.py +++ b/spacy/tests/test_gold.py @@ -90,7 +90,7 @@ def test_gold_ner_missing_tags(en_tokenizer): def test_iob_to_biluo(): good_iob = ["O", "O", "B-LOC", "I-LOC", "O", "B-PERSON"] good_biluo = ["O", "O", "B-LOC", "L-LOC", "O", "U-PERSON"] - bad_iob = ["O", "O", "\"", "B-LOC", "I-LOC"] + bad_iob = ["O", "O", '"', "B-LOC", "I-LOC"] converted_biluo = iob_to_biluo(good_iob) assert good_biluo == converted_biluo with pytest.raises(ValueError): @@ -99,9 +99,9 @@ def test_iob_to_biluo(): def test_roundtrip_docs_to_json(): text = "I flew to Silicon Valley via London." - tags = ['PRP', 'VBD', 'IN', 'NNP', 'NNP', 'IN', 'NNP', '.'] + tags = ["PRP", "VBD", "IN", "NNP", "NNP", "IN", "NNP", "."] heads = [1, 1, 1, 4, 2, 1, 5, 1] - deps = ['nsubj', 'ROOT', 'prep', 'compound', 'pobj', 'prep', 'pobj', 'punct'] + deps = ["nsubj", "ROOT", "prep", "compound", "pobj", "prep", "pobj", "punct"] biluo_tags = ["O", "O", "O", "B-LOC", "L-LOC", "O", "U-GPE", "O"] cats = {"TRAVEL": 1.0, "BAKING": 0.0} nlp = English()