Update app.py
Browse files
app.py
CHANGED
|
@@ -12,26 +12,30 @@ model = GLiNER.from_pretrained("VAGOsolutions/mmbert_GLiNER", token=hf_token).ev
|
|
| 12 |
examples = [
|
| 13 |
# English Example
|
| 14 |
[
|
| 15 |
-
"On March 15, 2024, Dr. Sarah Johnson from Boston General Hospital diagnosed patient Michael Thompson, born on June 10, 1980 in New York, with pneumonia. The patient resides at 123 Main Street, Boston, and was prescribed a 7-day course of Amoxicillin 500mg.",
|
| 16 |
"date, doctor, hospital, diagnosis, patient, date of birth, place of birth, address, prescription, duration, medication",
|
|
|
|
| 17 |
False,
|
| 18 |
],
|
| 19 |
# German Example
|
| 20 |
[
|
| 21 |
-
"Die Firma TechSolutions GmbH, mit Sitz in der Musterstraße 45, Berlin, hat am 20.04.2024 einen Vertrag über 50.000€ mit der Innovations AG abgeschlossen. Der Geschäftsführer Max Müller und die Projektleiterin Anna Schmidt werden das Projekt bis zum 30.06.2024 abschließen.",
|
| 22 |
"firma, adresse, datum, vertrag, betrag, partner, geschäftsführer, projektleiter, deadline",
|
|
|
|
| 23 |
False,
|
| 24 |
],
|
| 25 |
# Italian Example
|
| 26 |
[
|
| 27 |
-
"La ditta Giardini Belli S.p.A., con partita IVA 01234567890, ha emesso una fattura di 500€ per la consulenza giuridica fornita dall'avvocato Giulia Bianchi, il cui studio si trova in Piazza del Duomo, Milano, dal giorno 01/04/2024.",
|
| 28 |
-
"
|
|
|
|
| 29 |
False,
|
| 30 |
],
|
| 31 |
# Spanish Example
|
| 32 |
[
|
| 33 |
-
"El 12/05/2024, el Banco Nacional de España aprobó un préstamo hipotecario de 300.000€ a favor de Carlos García, empleado en la empresa Tecnología Avanzada S.L., con sede en Calle Gran Vía 25, Madrid. El préstamo tiene un plazo de amortización de 25 años y está garantizado por la propiedad ubicada en Avenida de la Paz 10, Barcelona.",
|
| 34 |
"fecha, banco, tipo de préstamo, importe, beneficiario, empleador, dirección empresa, plazo, garantía, dirección propiedad",
|
|
|
|
| 35 |
False,
|
| 36 |
],
|
| 37 |
]
|
|
@@ -79,7 +83,7 @@ with gr.Blocks(title="GLiNER-base") as demo:
|
|
| 79 |
)
|
| 80 |
|
| 81 |
input_text = gr.Textbox(
|
| 82 |
-
value=examples[0][0], label="Text input", placeholder="Enter your text here", lines=6
|
| 83 |
)
|
| 84 |
with gr.Row() as row:
|
| 85 |
labels = gr.Textbox(
|
|
@@ -105,12 +109,13 @@ with gr.Blocks(title="GLiNER-base") as demo:
|
|
| 105 |
)
|
| 106 |
output = gr.HighlightedText(label="Predicted Entities")
|
| 107 |
submit_btn = gr.Button("Submit")
|
| 108 |
-
|
| 109 |
-
examples,
|
| 110 |
-
fn=ner,
|
| 111 |
inputs=[input_text, labels, threshold, nested_ner],
|
| 112 |
outputs=output,
|
|
|
|
| 113 |
cache_examples=True,
|
|
|
|
| 114 |
)
|
| 115 |
|
| 116 |
# Submitting
|
|
|
|
| 12 |
examples = [
|
| 13 |
# English Example
|
| 14 |
[
|
| 15 |
+
"[EN] On March 15, 2024, Dr. Sarah Johnson from Boston General Hospital diagnosed patient Michael Thompson, born on June 10, 1980 in New York, with pneumonia. The patient resides at 123 Main Street, Boston, and was prescribed a 7-day course of Amoxicillin 500mg.",
|
| 16 |
"date, doctor, hospital, diagnosis, patient, date of birth, place of birth, address, prescription, duration, medication",
|
| 17 |
+
0.75,
|
| 18 |
False,
|
| 19 |
],
|
| 20 |
# German Example
|
| 21 |
[
|
| 22 |
+
"[DE] Die Firma TechSolutions GmbH, mit Sitz in der Musterstraße 45, Berlin, hat am 20.04.2024 einen Vertrag über 50.000€ mit der Innovations AG abgeschlossen. Der Geschäftsführer Max Müller und die Projektleiterin Anna Schmidt werden das Projekt bis zum 30.06.2024 abschließen.",
|
| 23 |
"firma, adresse, datum, vertrag, betrag, partner, geschäftsführer, projektleiter, deadline",
|
| 24 |
+
0.75,
|
| 25 |
False,
|
| 26 |
],
|
| 27 |
# Italian Example
|
| 28 |
[
|
| 29 |
+
"[IT] La ditta Giardini Belli S.p.A., con partita IVA 01234567890, ha emesso una fattura di 500€ per la consulenza giuridica fornita dall'avvocato Giulia Bianchi, il cui studio si trova in Piazza del Duomo, Milano, dal giorno 01/04/2024.",
|
| 30 |
+
"organizzazione, partita iva, importo, avvocato, indirizzo, data",
|
| 31 |
+
0.75,
|
| 32 |
False,
|
| 33 |
],
|
| 34 |
# Spanish Example
|
| 35 |
[
|
| 36 |
+
"[ES] El 12/05/2024, el Banco Nacional de España aprobó un préstamo hipotecario de 300.000€ a favor de Carlos García, empleado en la empresa Tecnología Avanzada S.L., con sede en Calle Gran Vía 25, Madrid. El préstamo tiene un plazo de amortización de 25 años y está garantizado por la propiedad ubicada en Avenida de la Paz 10, Barcelona.",
|
| 37 |
"fecha, banco, tipo de préstamo, importe, beneficiario, empleador, dirección empresa, plazo, garantía, dirección propiedad",
|
| 38 |
+
0.75,
|
| 39 |
False,
|
| 40 |
],
|
| 41 |
]
|
|
|
|
| 83 |
)
|
| 84 |
|
| 85 |
input_text = gr.Textbox(
|
| 86 |
+
value=examples[0][0], label="Text input", placeholder="Enter your text here (optional: prefix with [EN], [DE], [IT], [ES] for language tag)", lines=6
|
| 87 |
)
|
| 88 |
with gr.Row() as row:
|
| 89 |
labels = gr.Textbox(
|
|
|
|
| 109 |
)
|
| 110 |
output = gr.HighlightedText(label="Predicted Entities")
|
| 111 |
submit_btn = gr.Button("Submit")
|
| 112 |
+
examples_component = gr.Examples(
|
| 113 |
+
examples=examples,
|
|
|
|
| 114 |
inputs=[input_text, labels, threshold, nested_ner],
|
| 115 |
outputs=output,
|
| 116 |
+
fn=ner,
|
| 117 |
cache_examples=True,
|
| 118 |
+
label="Examples",
|
| 119 |
)
|
| 120 |
|
| 121 |
# Submitting
|