From 1e252b129ce89d1313133f04685f73b459429ec6 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Sun, 17 Feb 2019 12:22:07 +0100 Subject: [PATCH] Auto-format --- spacy/errors.py | 2 +- spacy/tests/doc/test_doc_split.py | 31 +++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/spacy/errors.py b/spacy/errors.py index 07f132c98..f2bee10a5 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -325,7 +325,7 @@ class Errors(object): "in previous versions, but had significant bugs that led to poor " "performance") E117 = ("The newly split tokens must match the text of the original token. " - "New orths: {new}. Old text: {old}.") + "New orths: {new}. Old text: {old}.") @add_codes diff --git a/spacy/tests/doc/test_doc_split.py b/spacy/tests/doc/test_doc_split.py index 28effae6c..3999aabca 100644 --- a/spacy/tests/doc/test_doc_split.py +++ b/spacy/tests/doc/test_doc_split.py @@ -22,9 +22,9 @@ def test_doc_split(en_vocab): ["Los", "Angeles"], [(doc[0], 1), doc[1]], attrs={ - "tag": ["NNP"]*2, + "tag": ["NNP"] * 2, "lemma": ["Los", "Angeles"], - "ent_type": ["GPE"]*2 + "ent_type": ["GPE"] * 2, }, ) assert len(doc) == 4 @@ -46,8 +46,12 @@ def test_split_dependencies(en_vocab): dep1 = doc.vocab.strings.add("amod") dep2 = doc.vocab.strings.add("subject") with doc.retokenize() as retokenizer: - retokenizer.split(doc[0], ["Los", "Angeles"], - [(doc[0], 1), doc[1]], attrs={'dep': [dep1, dep2]}) + retokenizer.split( + doc[0], + ["Los", "Angeles"], + [(doc[0], 1), doc[1]], + attrs={"dep": [dep1, dep2]}, + ) assert doc[0].dep == dep1 assert doc[1].dep == dep2 @@ -73,8 +77,7 @@ def test_spans_entity_merge_iob(): assert doc[0].ent_iob_ == "B" assert doc[1].ent_iob_ == "I" with doc.retokenize() as retokenizer: - retokenizer.split(doc[0], ["a", "b", "c"], - [(doc[0], 1), (doc[0], 2), doc[1]]) + retokenizer.split(doc[0], ["a", "b", "c"], [(doc[0], 1), (doc[0], 2), doc[1]]) assert doc[0].ent_iob_ == "B" assert doc[1].ent_iob_ == "I" assert doc[2].ent_iob_ == "I" @@ -94,10 +97,18 @@ def test_spans_sentence_update_after_merge(en_vocab): init_len = len(sent1) init_len2 = len(sent2) with doc.retokenize() as retokenizer: - retokenizer.split(doc[0], ["Stewart", "Lee"], [(doc[0], 1), doc[1]], - attrs={"dep": ["compound", "nsubj"]}) - retokenizer.split(doc[13], ["Joe", "Pasquale"], [(doc[13], 1), doc[12]], - attrs={"dep": ["compound", "dobj"]}) + retokenizer.split( + doc[0], + ["Stewart", "Lee"], + [(doc[0], 1), doc[1]], + attrs={"dep": ["compound", "nsubj"]}, + ) + retokenizer.split( + doc[13], + ["Joe", "Pasquale"], + [(doc[13], 1), doc[12]], + attrs={"dep": ["compound", "dobj"]}, + ) sent1, sent2 = list(doc.sents) assert len(sent1) == init_len + 1 assert len(sent2) == init_len2 + 1