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