Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for span in list(doc.ents):
start = span.start_char
end = span.end_char
fragments = text[offset:start].split("\n")
for i, fragment in enumerate(fragments):
markup += html.escape(fragment)
if len(fragments) > 1 and i != len(fragments) - 1:
markup += "<br>"
ent = {'label': '', 'id': span._.id, 'bg': "rgb(74, 154, 239, {})".format(span._.acc * span._.acc + 0.12), 'text': html.escape(span.text)}
# Add the entity
markup += TPL_ENT.format(**ent)
offset = end
markup += html.escape(text[offset:])
out = TPL_ENTS.format(content=markup, dir='ltr')
return out
for span in list(doc['entities']):
start = span['start']
end = span['end']
fragments = text[offset:start].split("\n")
for i, fragment in enumerate(fragments):
markup += html.escape(fragment)
if len(fragments) > 1 and i != len(fragments) - 1:
markup += "<br>"
ent = {'label': '', 'id': span['id'], 'bg': "rgb(74, 154, 239, {})".format(1 * 1 + 0.12), 'text': html.escape(span['str'])}
# Add the entity
markup += TPL_ENT.format(**ent)
offset = end
markup += html.escape(text[offset:])
out = TPL_ENTS.format(content=markup, dir='ltr')
return out