Spaces:
Running
Running
vickeee465
commited on
Commit
·
12eab55
1
Parent(s):
9cfccba
full text ner output
Browse files- interfaces/ner.py +3 -2
interfaces/ner.py
CHANGED
@@ -33,10 +33,11 @@ def named_entity_recognition(text, language):
|
|
33 |
model_id = build_spacy_path(language)
|
34 |
pipeline = huspacy.load() if model_id.startswith("hu") else spacy.load(model_id)
|
35 |
doc = pipeline(text)
|
36 |
-
entities = [
|
|
|
37 |
model_id_hf = f"huspacy/{model_id}" if model_id.startswith("hu") else f"spacy/{model_id}"
|
38 |
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>'
|
39 |
-
return
|
40 |
|
41 |
demo = gr.Interface(
|
42 |
fn=named_entity_recognition,
|
|
|
33 |
model_id = build_spacy_path(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 |
+
output = {"text":text, "entities":entities}
|
38 |
model_id_hf = f"huspacy/{model_id}" if model_id.startswith("hu") else f"spacy/{model_id}"
|
39 |
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>'
|
40 |
+
return output, output_info
|
41 |
|
42 |
demo = gr.Interface(
|
43 |
fn=named_entity_recognition,
|