2019-03-23 10:19:11 +00:00
|
|
|
# coding: utf8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from spacy.lang.en import English
|
|
|
|
from spacy.tokens import Doc
|
|
|
|
|
|
|
|
|
|
|
|
def test_issue3468():
|
2019-03-23 14:45:02 +00:00
|
|
|
"""Test that sentence boundaries are set correctly so Doc.is_sentenced can
|
|
|
|
be restored after serialization."""
|
2019-03-23 10:19:11 +00:00
|
|
|
nlp = English()
|
|
|
|
nlp.add_pipe(nlp.create_pipe("sentencizer"))
|
|
|
|
doc = nlp("Hello world")
|
|
|
|
assert doc[0].is_sent_start
|
2019-03-23 10:22:44 +00:00
|
|
|
assert doc.is_sentenced
|
2019-03-23 10:19:11 +00:00
|
|
|
assert len(list(doc.sents)) == 1
|
|
|
|
doc_bytes = doc.to_bytes()
|
|
|
|
new_doc = Doc(nlp.vocab).from_bytes(doc_bytes)
|
2019-03-23 10:24:29 +00:00
|
|
|
assert new_doc[0].is_sent_start
|
2019-03-23 10:22:44 +00:00
|
|
|
assert new_doc.is_sentenced
|
2019-03-23 10:19:11 +00:00
|
|
|
assert len(list(new_doc.sents)) == 1
|