spacy_ner / app.py
brijw's picture
Create app.py
1ba6d9d
raw
history blame
701 Bytes
import gradio as gr
#os is used to change the directory
import os
#spacy is used for the NER
import spacy
#pandas is used to read, edit, and write tabular data
import pandas as pd
from spacy import displacy
from collections import Counter
import en_core_web_sm
# spacy.cli.download("en_core_web_lg")
nlp = en_core_web_sm.load()
nlp = spacy.load("en_core_web_sm")
def ner(sentence):
doc = nlp(sentence)
ents = [(e.text, e.label_) for e in doc.ents]
return ents
examples = [
"where did Wandobire's laptop come from, was it africa or uganda?",
]
iface=gr.Interface(ner, gr.Textbox(placeholder="Enter sentence here..."),
gr.HighlightedText(), examples=examples)
iface.launch()