File size: 1,035 Bytes
642c239 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
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() |