Ext_Entity / app.py
thanhcong2001's picture
Create app.py
1c1af61 verified
raw
history blame contribute delete
472 Bytes
# load ner model
from transformers import pipeline
ner_pipe = pipeline(
'ner',
model= 'dslim/bert-base-NER',
aggregation_strategy = 'simple'
)
def ext_entities(sentence):
doc = ner_pipe(sentence.title())
outputs = ''
for t in doc:
outputs += f"{t['word']} - {t['entity_group']}\n{t['score']}\n"
return outputs
import gradio as gr
demo = gr.Interface(fn=ext_entities,inputs='text',outputs='text',title='Extract Entities')
demo.launch()