@pytest.mark.models
def test_issue514(EN):
 text = [u'This', u'is', u'a', u'sentence', u'about', u'pasta', u'.']
 vocab = EN.entity.vocab
 doc = get_doc(vocab, text)
 EN.entity.add_label(u'Food')
 EN.entity(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')])
 doc2 = get_doc(EN.entity.vocab).from_bytes(doc.to_bytes())
 assert ([(ent.label_, ent.text) for ent in doc2.ents] == [(u'Food', u'pasta')])

@ pytest . mark . models def test_issue514 ( EN ) : text = [ u'This' , u'is' , u'a' , u'sentence' , u'about' , u'pasta' , u'.' ] vocab = EN . entity . vocab doc = get_doc ( vocab , text ) EN . entity . add_label ( u'Food' ) EN . entity ( 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' ) ] ) doc2 = get_doc ( EN . entity . vocab ) . from_bytes ( doc . to_bytes ( ) ) assert ( [ ( ent . label_ , ent . text ) for ent in doc2 . ents ] == [ ( u'Food' , u'pasta' ) ] )
test serializing after adding entity .