Spaces:
Sleeping
Sleeping
| 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() | |