Skip to content

Commit

Permalink
Test Issue #514: Serialization fails after adding a new entity label.
Browse files Browse the repository at this point in the history
  • Loading branch information
honnibal committed Oct 23, 2016
1 parent 936e624 commit 4de30a8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions spacy/tests/serialize/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,21 @@ def test_serialize_empty_doc():
assert b == b''
loaded = Doc(vocab).from_bytes(b)
assert len(loaded) == 0


def test_serialize_after_adding_entity():
# Re issue #514
vocab = spacy.en.English.Defaults.create_vocab()
entity_recognizer = spacy.en.English.Defaults.create_entity()

doc = Doc(vocab, words=u'This is a sentence about pasta .'.split())
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()

0 comments on commit 4de30a8

Please sign in to comment.