Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,24 +4,22 @@ from transformers import pipeline
|
|
| 4 |
# Load your fine-tuned SpanBERT ADR model
|
| 5 |
ner_pipeline = pipeline(
|
| 6 |
"token-classification",
|
| 7 |
-
model="hazarri/fine_tuned_spanbert", # replace with your actual model
|
| 8 |
aggregation_strategy="simple"
|
| 9 |
)
|
| 10 |
|
| 11 |
def extract_adrs(text):
|
| 12 |
-
# Run the model
|
| 13 |
results = ner_pipeline(text)
|
| 14 |
|
| 15 |
-
#
|
| 16 |
if not results:
|
| 17 |
return []
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
]
|
| 24 |
-
return formatted
|
| 25 |
|
| 26 |
# Gradio interface
|
| 27 |
demo = gr.Interface(
|
|
|
|
| 4 |
# Load your fine-tuned SpanBERT ADR model
|
| 5 |
ner_pipeline = pipeline(
|
| 6 |
"token-classification",
|
| 7 |
+
model="hazarri/fine_tuned_spanbert", # replace with your actual model name
|
| 8 |
aggregation_strategy="simple"
|
| 9 |
)
|
| 10 |
|
| 11 |
def extract_adrs(text):
|
| 12 |
+
# Run the model
|
| 13 |
results = ner_pipeline(text)
|
| 14 |
|
| 15 |
+
# Return empty list if no entities detected
|
| 16 |
if not results:
|
| 17 |
return []
|
| 18 |
|
| 19 |
+
# Extract only the ADR words
|
| 20 |
+
adrs = [r["word"] for r in results]
|
| 21 |
+
|
| 22 |
+
return adrs
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# Gradio interface
|
| 25 |
demo = gr.Interface(
|