Spaces:
Sleeping
Sleeping
Download app.py from thanhcong2001/Ext_Entity: direct link, hf CLI and curl.
- Browser
- Download file 472 Bytes
-
https://huggingface.co/spaces/thanhcong2001/Ext_Entity/resolve/main/app.py
- Command line
-
hf download hf://spaces/thanhcong2001/Ext_Entity/app.py
-
curl -L -o app.py https://huggingface.co/spaces/thanhcong2001/Ext_Entity/resolve/main/app.py
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() |