poltextlab commited on
Commit
d67d863
1 Parent(s): 2233a79

legend fix

Browse files
Files changed (1) hide show
  1. interfaces/ner.py +2 -2
interfaces/ner.py CHANGED
@@ -34,10 +34,10 @@ def named_entity_recognition(text, language):
34
  pipeline = huspacy.load() if model_id.startswith("hu") else spacy.load(model_id)
35
  doc = pipeline(text)
36
  entities = [{"entity":ent.label_, "start":ent.start_char, "end":ent.end_char} for ent in doc.ents]
37
- legend = [f'<li> <b>{ent}</b> = <i>{spacy.glossary.GLOSSARY[ent]}</i> </li>' for ent in set(doc.ents) ]
38
  output = {"text":text, "entities":entities}
39
  model_id_hf = f"huspacy/{model_id}" if model_id.startswith("hu") else f"spacy/{model_id}"
40
- output_info = 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>'
41
  return output, output_info
42
 
43
  demo = gr.Interface(
 
34
  pipeline = huspacy.load() if model_id.startswith("hu") else spacy.load(model_id)
35
  doc = pipeline(text)
36
  entities = [{"entity":ent.label_, "start":ent.start_char, "end":ent.end_char} for ent in doc.ents]
37
+ legend = "<ul>"+"".join([f"<li> <b>{ent}</b> = <i>{spacy.glossary.GLOSSARY[ent]}</i> </li>" for ent in set(doc.ents)])+"</ul>"
38
  output = {"text":text, "entities":entities}
39
  model_id_hf = f"huspacy/{model_id}" if model_id.startswith("hu") else f"spacy/{model_id}"
40
+ 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>'
41
  return output, output_info
42
 
43
  demo = gr.Interface(