mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-26 17:24:41 +03:00
Test Issue #514: Serialization fails after adding a new entity label.
This commit is contained in:
parent
936e6246aa
commit
4de30a8e38
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user