|
|
from transformers import pipeline |
|
|
import gradio as gr |
|
|
|
|
|
model_checkpoint = "MuntasirHossain/bert-finetuned-ner" |
|
|
model = pipeline("ner", model=model_checkpoint, aggregation_strategy="simple") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ner(text): |
|
|
a = "" |
|
|
results = model(text) |
|
|
for result in results: |
|
|
a += result['word'] + " : " + result['entity_group'] + ", " |
|
|
a = a[0:len(a)-3] |
|
|
return a |
|
|
|
|
|
|
|
|
description = "This AI model is trained to identify and classify named entities in unstructured text." |
|
|
title = "Named Entity Recognition" |
|
|
theme = "grass" |
|
|
examples=["Mount Everest is Earth's highest mountain, located in the Mahalangur Himal sub-range of the Himalayas. Edmund Hillary and Tenzing Norgay were the first climbers confirmed\ |
|
|
to have reached the summit of Mount Everest on May 29, 1953."] |
|
|
|
|
|
gr.Interface(fn=ner, |
|
|
inputs="textbox", |
|
|
outputs="text", |
|
|
|
|
|
|
|
|
title=title, |
|
|
theme = theme, |
|
|
description=description, |
|
|
examples=examples, |
|
|
).launch() |