Spaces:
Running
Running
adding style, maybe this helps showing legend
Browse files- interfaces/ner.py +1 -1
interfaces/ner.py
CHANGED
@@ -37,7 +37,7 @@ def named_entity_recognition(text, language):
|
|
37 |
doc = pipeline(text)
|
38 |
entities = [{"entity":ent.label_, "start":ent.start_char, "end":ent.end_char} for ent in doc.ents]
|
39 |
labels_used = [ent.label_ for ent in doc.ents]
|
40 |
-
legend =
|
41 |
output = {"text":text, "entities":entities}
|
42 |
model_id_hf = f"huspacy/{model_id}" if model_id.startswith("hu") else f"spacy/{model_id}"
|
43 |
output_info = legend + f'<p style="text-align: center; display: block">Prediction was made using the <a href="https://huggingface.co/{model_id_hf}">{model_id_hf}</a> model.</p> <ul> {" ".join(legend)} </ul>'
|
|
|
37 |
doc = pipeline(text)
|
38 |
entities = [{"entity":ent.label_, "start":ent.start_char, "end":ent.end_char} for ent in doc.ents]
|
39 |
labels_used = [ent.label_ for ent in doc.ents]
|
40 |
+
legend = '<p style="text-align: left; display: block">Legend:</p><ul style="text-align: left; display: block">'+"".join([f"<li> <b>{label}</b> = <i>{NER_DICT[label]}</i> </li>" for label in set(labels_used)])+"</ul>"
|
41 |
output = {"text":text, "entities":entities}
|
42 |
model_id_hf = f"huspacy/{model_id}" if model_id.startswith("hu") else f"spacy/{model_id}"
|
43 |
output_info = legend + f'<p style="text-align: center; display: block">Prediction was made using the <a href="https://huggingface.co/{model_id_hf}">{model_id_hf}</a> model.</p> <ul> {" ".join(legend)} </ul>'
|