Spaces:
Sleeping
Sleeping
File size: 472 Bytes
1c1af61 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# 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() |