mirror of https://github.com/explosion/spaCy.git
Apply suggestions from code review
Co-authored-by: Renat Shigapov <57352291+shigapov@users.noreply.github.com>
This commit is contained in:
parent
00836c2d7d
commit
57b5fc1995
|
@ -316,6 +316,10 @@ class EntityRenderer:
|
|||
end = span["end"]
|
||||
kb_id = span.get("kb_id", "")
|
||||
kb_url = span.get("kb_url", "")
|
||||
if kb_id:
|
||||
kb_link = """<a style="text-decoration: none; color: black; font-weight: bold" href="{}">{}</a>""".format(kb_url, kb_id)
|
||||
else:
|
||||
kb_link = ""
|
||||
additional_params = span.get("params", {})
|
||||
entity = escape_html(text[start:end])
|
||||
fragments = text[offset:start].split("\n")
|
||||
|
@ -325,7 +329,7 @@ class EntityRenderer:
|
|||
markup += "</br>"
|
||||
if self.ents is None or label.upper() in self.ents:
|
||||
color = self.colors.get(label.upper(), self.default_color)
|
||||
ent_settings = {"label": label, "text": entity, "bg": color, "kb_id": kb_id, "kb_url": kb_url}
|
||||
ent_settings = {"label": label, "text": entity, "bg": color, "kb_link": kb_link}
|
||||
ent_settings.update(additional_params)
|
||||
markup += self.ent_template.format(**ent_settings)
|
||||
else:
|
||||
|
|
|
@ -52,7 +52,7 @@ TPL_ENT = """
|
|||
<mark class="entity" style="background: {bg}; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;">
|
||||
{text}
|
||||
<span style="font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem">{label}
|
||||
<a style="text-decoration: none; color: black; font-weight: bold" href="{kb_url}">{kb_id}</a>
|
||||
{kb_link}
|
||||
</span>
|
||||
</mark>
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue