mirror of
https://github.com/explosion/spaCy.git
synced 2025-09-21 19:42:37 +03:00
include test for user attr
This commit is contained in:
parent
74140f5145
commit
dd240ef2c0
|
@ -885,10 +885,10 @@ def test_applycli_jsonl():
|
||||||
with make_tempdir() as data_path:
|
with make_tempdir() as data_path:
|
||||||
output = data_path / "testout.spacy"
|
output = data_path / "testout.spacy"
|
||||||
data = [{"field": "Testing apply cli.", "key": 234}]
|
data = [{"field": "Testing apply cli.", "key": 234}]
|
||||||
|
data2 = [{"field": "234"}]
|
||||||
srsly.write_jsonl(data_path / "test.jsonl", data)
|
srsly.write_jsonl(data_path / "test.jsonl", data)
|
||||||
apply(data_path, output, "blank:en", "field", 1, 1)
|
apply(data_path, output, "blank:en", "field", 1, 1)
|
||||||
data = [{"field": "234"}]
|
srsly.write_jsonl(data_path / "test2.jsonl", data2)
|
||||||
srsly.write_jsonl(data_path / "test2.jsonl", data)
|
|
||||||
apply(data_path, output, "blank:en", "field", 1, 1)
|
apply(data_path, output, "blank:en", "field", 1, 1)
|
||||||
|
|
||||||
|
|
||||||
|
@ -921,6 +921,22 @@ def test_applycli_mixed():
|
||||||
assert doc.text == text
|
assert doc.text == text
|
||||||
|
|
||||||
|
|
||||||
|
def test_applycli_user_data():
|
||||||
|
Doc.set_extension("ext", default=0)
|
||||||
|
val = ("ext", 0)
|
||||||
|
with make_tempdir() as data_path:
|
||||||
|
output = data_path / "testout.spacy"
|
||||||
|
nlp = spacy.blank("en")
|
||||||
|
doc = nlp("testing apply cli.")
|
||||||
|
doc._.ext = val
|
||||||
|
docbin = DocBin(store_user_data=True)
|
||||||
|
docbin.add(doc)
|
||||||
|
docbin.to_disk(data_path / "testin.spacy")
|
||||||
|
apply(data_path, output, "blank:en", "", 1, 1)
|
||||||
|
result = list(DocBin().from_disk(output).get_docs(nlp.vocab))
|
||||||
|
assert result[0]._.ext == val
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"reqs,output",
|
"reqs,output",
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue
Block a user