EricPeter commited on
Commit
642c239
1 Parent(s): 8d46ba3

Add application file

Browse files
Files changed (2) hide show
  1. app.py +42 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import spacy
2
+ from spacy import displacy
3
+
4
+ import gradio as gr
5
+
6
+ # nlp = spacy.load("en_core_web_sm")
7
+ nlp =spacy.load("en_pipeline")
8
+
9
+
10
+ def text_analysis(text):
11
+ doc = nlp(text)
12
+ html = displacy.render(doc, style="ent", page=True)
13
+ html = (
14
+ ""
15
+ + html
16
+ + ""
17
+ )
18
+ pos_count = {
19
+ "char_count": len(text),
20
+ "token_count": 0,
21
+ }
22
+ pos_tokens = []
23
+
24
+ # for token in doc:
25
+ # pos_tokens.extend([(token.text, token.pos_), (" ", None)])
26
+
27
+ return html
28
+
29
+
30
+ demo = gr.Interface(
31
+ text_analysis,
32
+ gr.Textbox(placeholder="Enter sentence here..."),
33
+ ["html"],
34
+ examples=[
35
+ ["There is a challenge of food in Uganda. Gloria goes to Kyambogo University."],
36
+ [" She knows programming in HTML and CSS. Prof. Twinomujuni sent the team in Isingiro some 100 USD."],
37
+ ["Students will bbe leaving the University on Friday September 20.They will graduate in 2023." ],
38
+ ["Uganda has many parts that is the north, east, west and south."]
39
+ ],
40
+ )
41
+
42
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ spacy
2
+ gradio
3
+ https://huggingface.co/EricPeter/en_pipeline/resolve/main/en_pipeline-any-py3-none-any.whl