Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -23,15 +23,15 @@ def process_text(text):
|
|
23 |
"""Process input text and return highlighted entities."""
|
24 |
pipeline = load_healthcare_ner_pipeline()
|
25 |
entities = pipeline(text)
|
26 |
-
|
|
|
27 |
# Highlight entities in the text
|
28 |
-
html_output = highlight_entities(text, entities)
|
29 |
-
|
30 |
# Log usage
|
31 |
-
log_demo_usage(text, len(entities))
|
32 |
-
|
33 |
-
return html_output
|
34 |
|
|
|
35 |
def highlight_entities(text, entities):
|
36 |
"""Highlight identified entities in the input text."""
|
37 |
highlighted_text = text
|
@@ -42,6 +42,7 @@ def highlight_entities(text, entities):
|
|
42 |
f'<mark style="background-color: yellow;">{entity_text}</mark>'
|
43 |
)
|
44 |
return f"<p>{highlighted_text}</p>"
|
|
|
45 |
|
46 |
def log_demo_usage(text, num_entities):
|
47 |
"""Log demo usage for analytics."""
|
@@ -55,7 +56,8 @@ demo = gr.Interface(
|
|
55 |
placeholder="Le patient présente une hypertension artérielle...",
|
56 |
lines=5
|
57 |
),
|
58 |
-
|
|
|
59 |
title="French Healthcare NER Demo | As featured in 'NLP on OCI'",
|
60 |
description="""
|
61 |
🔬 Live demo of the French Healthcare NER model built in Chapter 5 of 'NLP on OCI'
|
|
|
23 |
"""Process input text and return highlighted entities."""
|
24 |
pipeline = load_healthcare_ner_pipeline()
|
25 |
entities = pipeline(text)
|
26 |
+
return {"text": text, "entities": entities}
|
27 |
+
|
28 |
# Highlight entities in the text
|
29 |
+
#html_output = highlight_entities(text, entities)
|
|
|
30 |
# Log usage
|
31 |
+
#log_demo_usage(text, len(entities))
|
32 |
+
#return html_output
|
|
|
33 |
|
34 |
+
"""
|
35 |
def highlight_entities(text, entities):
|
36 |
"""Highlight identified entities in the input text."""
|
37 |
highlighted_text = text
|
|
|
42 |
f'<mark style="background-color: yellow;">{entity_text}</mark>'
|
43 |
)
|
44 |
return f"<p>{highlighted_text}</p>"
|
45 |
+
"""
|
46 |
|
47 |
def log_demo_usage(text, num_entities):
|
48 |
"""Log demo usage for analytics."""
|
|
|
56 |
placeholder="Le patient présente une hypertension artérielle...",
|
57 |
lines=5
|
58 |
),
|
59 |
+
gr.HighlightedText(),
|
60 |
+
#outputs=gr.HTML(label="Identified Medical Entities"),
|
61 |
title="French Healthcare NER Demo | As featured in 'NLP on OCI'",
|
62 |
description="""
|
63 |
🔬 Live demo of the French Healthcare NER model built in Chapter 5 of 'NLP on OCI'
|