ner-spacy / app.py
EricPeter's picture
Add application file
642c239
import spacy
from spacy import displacy
import gradio as gr
# nlp = spacy.load("en_core_web_sm")
nlp =spacy.load("en_pipeline")
def text_analysis(text):
doc = nlp(text)
html = displacy.render(doc, style="ent", page=True)
html = (
""
+ html
+ ""
)
pos_count = {
"char_count": len(text),
"token_count": 0,
}
pos_tokens = []
# for token in doc:
# pos_tokens.extend([(token.text, token.pos_), (" ", None)])
return html
demo = gr.Interface(
text_analysis,
gr.Textbox(placeholder="Enter sentence here..."),
["html"],
examples=[
["There is a challenge of food in Uganda. Gloria goes to Kyambogo University."],
[" She knows programming in HTML and CSS. Prof. Twinomujuni sent the team in Isingiro some 100 USD."],
["Students will bbe leaving the University on Friday September 20.They will graduate in 2023." ],
["Uganda has many parts that is the north, east, west and south."]
],
)
demo.launch()