Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
@@ -41,7 +41,6 @@ def highlight_entities(text):
|
|
41 |
|
42 |
formatted_text += text[last_idx:]
|
43 |
|
44 |
-
# Generate legend
|
45 |
legend_html = "<div><b>Legend:</b><br>"
|
46 |
for label, color in ENTITY_COLORS.items():
|
47 |
legend_html += f'<span style="background-color:{color}; padding:2px 5px; border-radius:5px; margin-right:5px;">{label}</span>'
|
@@ -49,12 +48,14 @@ def highlight_entities(text):
|
|
49 |
|
50 |
return legend_html + formatted_text
|
51 |
|
|
|
|
|
52 |
grn = gr.Interface(
|
53 |
fn=highlight_entities,
|
54 |
-
inputs=gr.Textbox(label="Enter Spanish Text"),
|
55 |
outputs=gr.HTML(label="NER Highlighted Text"),
|
56 |
title="Spanish Named Entity Recognition",
|
57 |
description="This interactive demo performs Named Entity Recognition (NER) on Spanish text. Recognized entities such as persons, locations, and organizations are highlighted in distinct colors for better readability. A legend is provided to help interpret the color coding.",
|
58 |
)
|
59 |
|
60 |
-
grn.launch()
|
|
|
41 |
|
42 |
formatted_text += text[last_idx:]
|
43 |
|
|
|
44 |
legend_html = "<div><b>Legend:</b><br>"
|
45 |
for label, color in ENTITY_COLORS.items():
|
46 |
legend_html += f'<span style="background-color:{color}; padding:2px 5px; border-radius:5px; margin-right:5px;">{label}</span>'
|
|
|
48 |
|
49 |
return legend_html + formatted_text
|
50 |
|
51 |
+
example_text = "Elon Musk vive en Estados Unidos y es dueño de SpaceX, Tesla y Starlink."
|
52 |
+
|
53 |
grn = gr.Interface(
|
54 |
fn=highlight_entities,
|
55 |
+
inputs=gr.Textbox(label="Enter Spanish Text", value=example_text),
|
56 |
outputs=gr.HTML(label="NER Highlighted Text"),
|
57 |
title="Spanish Named Entity Recognition",
|
58 |
description="This interactive demo performs Named Entity Recognition (NER) on Spanish text. Recognized entities such as persons, locations, and organizations are highlighted in distinct colors for better readability. A legend is provided to help interpret the color coding.",
|
59 |
)
|
60 |
|
61 |
+
grn.launch()
|