2020-07-29 19:48:39 +03:00
|
|
|
from spacy.lang.en import English
|
|
|
|
from spacy.tokens import Span
|
|
|
|
from spacy import displacy
|
|
|
|
|
2020-09-04 14:19:16 +03:00
|
|
|
|
|
|
|
SAMPLE_TEXT = """First line
|
2020-07-29 19:48:39 +03:00
|
|
|
Second line, with ent
|
|
|
|
Third line
|
|
|
|
Fourth line
|
2020-09-04 14:19:16 +03:00
|
|
|
"""
|
2020-07-29 19:48:39 +03:00
|
|
|
|
|
|
|
|
|
|
|
def test_issue5838():
|
|
|
|
# Displacy's EntityRenderer break line
|
|
|
|
# not working after last entity
|
|
|
|
|
|
|
|
nlp = English()
|
|
|
|
doc = nlp(SAMPLE_TEXT)
|
2020-09-04 14:19:16 +03:00
|
|
|
doc.ents = [Span(doc, 7, 8, label="test")]
|
2020-07-29 19:48:39 +03:00
|
|
|
|
2020-09-04 14:19:16 +03:00
|
|
|
html = displacy.render(doc, style="ent")
|
|
|
|
found = html.count("</br>")
|
2020-07-29 19:48:39 +03:00
|
|
|
assert found == 4
|