mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-26 17:24:41 +03:00
Test Issue #514: Serializer fails when new entity type has been added.
This commit is contained in:
parent
f97548c6f1
commit
79aa03fe98
|
@ -108,10 +108,20 @@ def test_serialize_after_adding_entity():
|
|||
entity_recognizer.add_label('Food')
|
||||
entity_recognizer(doc)
|
||||
|
||||
|
||||
label_id = vocab.strings[u'Food']
|
||||
doc.ents = [(label_id, 5,6)]
|
||||
|
||||
assert [(ent.label_, ent.text) for ent in doc.ents] == [(u'Food', u'pasta')]
|
||||
|
||||
byte_string = doc.to_bytes()
|
||||
|
||||
|
||||
@pytest.mark.models
|
||||
def test_serialize_after_adding_entity(EN):
|
||||
EN.entity.add_label(u'Food')
|
||||
doc = EN(u'This is a sentence about pasta.')
|
||||
label_id = EN.vocab.strings[u'Food']
|
||||
doc.ents = [(label_id, 5,6)]
|
||||
byte_string = doc.to_bytes()
|
||||
doc2 = Doc(EN.vocab).from_bytes(byte_string)
|
||||
assert [(ent.label_, ent.text) for ent in doc2.ents] == [(u'Food', u'pasta')]
|
||||
|
|
Loading…
Reference in New Issue
Block a user