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