mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-07 13:44:55 +03:00
replace from_disk with from_bytes
This commit is contained in:
parent
96d080e84f
commit
acb0d1685f
Binary file not shown.
|
@ -991,9 +991,10 @@ def test_doc_spans_setdefault(en_tokenizer):
|
||||||
doc.spans.setdefault("key3", default=SpanGroup(doc, spans=[doc[0:1], doc[1:2]]))
|
doc.spans.setdefault("key3", default=SpanGroup(doc, spans=[doc[0:1], doc[1:2]]))
|
||||||
assert len(doc.spans["key3"]) == 2
|
assert len(doc.spans["key3"]) == 2
|
||||||
|
|
||||||
def test_doc_from_disk_v3():
|
def test_doc_sentiment_from_bytes_v3_to_v4():
|
||||||
"""Test if docs created in v3.x work with '.from_disk' without throwing errors. This doc includes the sentiment attribute which is removed in v4"""
|
"""Test if a doc with sentiment attribute created in v3.x works with '.from_bytes' in v4.x without throwing errors. The sentiment attribute was removed in v4"""
|
||||||
doc = Doc(Vocab()).from_disk("./data/doc_sentiment_v3.4.2")
|
doc_bytes = b'\x89\xa4text\xa5happy\xaaarray_head\x9fGQACKOLMN\xcd\x01\xc4\xcd\x01\xc6I\xcd\x01\xc5JP\xaaarray_body\x85\xc4\x02nd\xc3\xc4\x04type\xa3<u8\xc4\x04kind\xc4\x00\xc4\x05shape\x92\x01\x0f\xc4\x04data\xc4x\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x9a\xd3\x17\xca\xf0b\x03\xa4\x9a\xd3\x17\xca\xf0b\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\xa9sentiment\xcb?\xf0\x00\x00\x00\x00\x00\x00\xa6tensor\x85\xc4\x02nd\xc3\xc4\x04type\xa3<f4\xc4\x04kind\xc4\x00\xc4\x05shape\x91\x00\xc4\x04data\xc4\x00\xa4cats\x80\xa5spans\xc4\x01\x90\xa7strings\x92\xa0\xa5happy\xb2has_unknown_spaces\xc2'
|
||||||
assert doc.text == "This is a happy sentence."
|
doc = Doc(Vocab()).from_bytes(doc_bytes)
|
||||||
|
assert doc.text == "happy"
|
||||||
with pytest.raises(AttributeError):
|
with pytest.raises(AttributeError):
|
||||||
doc.sentiment == 1.0
|
doc.sentiment == 1.0
|
Loading…
Reference in New Issue
Block a user