Spaces:
Sleeping
Sleeping
File size: 847 Bytes
a1e3a48 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import gradio as gr
from transformers import pipeline
# تحميل نموذج NER الإنجليزي
ner_pipeline = pipeline(
"token-classification",
model="dslim/bert-base-NER",
aggregation_strategy="simple"
)
def extract_entities(text):
if not text.strip():
return "Please enter some text."
entities = ner_pipeline(text)
result = ""
for ent in entities:
result += f"Word: {ent['word']} | Entity: {ent['entity_group']}\n"
return result
interface = gr.Interface(
fn=extract_entities,
inputs=gr.Textbox(
lines=5,
placeholder="Enter an English text (e.g. My name is John and I live in London)"
),
outputs=gr.Textbox(lines=12),
title="English NER Detector",
description="Testing dslim/bert-base-NER model for Named Entity Recognition"
)
interface.launch()
|