Skip to content

Commit

Permalink
Test Issue #514: Serializer fails when new entity type has been added.
Browse files Browse the repository at this point in the history
  • Loading branch information
honnibal committed Oct 23, 2016
1 parent f97548c commit 79aa03f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion spacy/tests/serialize/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')]

0 comments on commit 79aa03f

Please sign in to comment.