mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-10 16:22:29 +03:00
fix formatting on examples
This commit is contained in:
parent
d37b2094f7
commit
f6108776aa
|
@ -90,57 +90,17 @@ TRAIN_EXAMPLE_2 = dict(
|
||||||
@pytest.mark.slow
|
@pytest.mark.slow
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"component,examples",
|
"component,examples",
|
||||||
|
# fmt: off
|
||||||
[
|
[
|
||||||
(
|
("tagger", [TRAIN_EXAMPLE_1, TRAIN_EXAMPLE_2]),
|
||||||
"tagger",
|
("morphologizer", [TRAIN_EXAMPLE_1, TRAIN_EXAMPLE_2]),
|
||||||
[
|
("trainable_lemmatizer", [TRAIN_EXAMPLE_1, TRAIN_EXAMPLE_2]),
|
||||||
TRAIN_EXAMPLE_1,
|
("parser", [TRAIN_EXAMPLE_1] * 30),
|
||||||
TRAIN_EXAMPLE_2,
|
("ner", [TRAIN_EXAMPLE_1, TRAIN_EXAMPLE_2]),
|
||||||
],
|
("spancat", [TRAIN_EXAMPLE_1, TRAIN_EXAMPLE_2]),
|
||||||
),
|
("textcat", [TRAIN_EXAMPLE_1, TRAIN_EXAMPLE_2]),
|
||||||
(
|
]
|
||||||
"morphologizer",
|
# fmt: on
|
||||||
[
|
|
||||||
TRAIN_EXAMPLE_1,
|
|
||||||
TRAIN_EXAMPLE_2,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"trainable_lemmatizer",
|
|
||||||
[
|
|
||||||
TRAIN_EXAMPLE_1,
|
|
||||||
TRAIN_EXAMPLE_2,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"parser",
|
|
||||||
[
|
|
||||||
TRAIN_EXAMPLE_1,
|
|
||||||
]
|
|
||||||
* 30,
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"ner",
|
|
||||||
[
|
|
||||||
TRAIN_EXAMPLE_1,
|
|
||||||
TRAIN_EXAMPLE_2,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"spancat",
|
|
||||||
[
|
|
||||||
TRAIN_EXAMPLE_1,
|
|
||||||
TRAIN_EXAMPLE_2,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"textcat",
|
|
||||||
[
|
|
||||||
TRAIN_EXAMPLE_1,
|
|
||||||
TRAIN_EXAMPLE_2,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
def test_init_config_trainable(component, examples, en_vocab):
|
def test_init_config_trainable(component, examples, en_vocab):
|
||||||
if component == "textcat":
|
if component == "textcat":
|
||||||
|
@ -203,33 +163,16 @@ def test_init_config_trainable(component, examples, en_vocab):
|
||||||
@pytest.mark.slow
|
@pytest.mark.slow
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"component,examples",
|
"component,examples",
|
||||||
[
|
# fmt: off
|
||||||
(
|
[("tagger,parser,morphologizer", [TRAIN_EXAMPLE_1, TRAIN_EXAMPLE_2] * 15)]
|
||||||
"tagger,parser,morphologizer",
|
# fmt: on
|
||||||
[
|
|
||||||
dict(
|
|
||||||
words=example_words_1,
|
|
||||||
tags=example_tags,
|
|
||||||
morphs=example_morphs,
|
|
||||||
deps=example_deps,
|
|
||||||
heads=[1, 1, 1],
|
|
||||||
pos=example_pos,
|
|
||||||
),
|
|
||||||
dict(
|
|
||||||
words=example_words_2,
|
|
||||||
tags=example_tags,
|
|
||||||
morphs=example_morphs,
|
|
||||||
deps=example_deps,
|
|
||||||
heads=[1, 1, 1],
|
|
||||||
pos=example_pos,
|
|
||||||
),
|
|
||||||
]
|
|
||||||
* 15,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
def test_init_config_trainable_multiple(component, examples, en_vocab):
|
def test_init_config_trainable_multiple(component, examples, en_vocab):
|
||||||
train_docs = [Doc(en_vocab, **example) for example in examples]
|
train_docs = []
|
||||||
|
for example in examples:
|
||||||
|
example = {k: v for k, v in example.items() if k not in ("cats", "spans")}
|
||||||
|
doc = Doc(en_vocab, **example)
|
||||||
|
train_docs.append(doc)
|
||||||
|
|
||||||
with make_tempdir() as d_in:
|
with make_tempdir() as d_in:
|
||||||
train_bin = DocBin(docs=train_docs)
|
train_bin = DocBin(docs=train_docs)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user