Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,17 +9,20 @@ nlp = spacy.load("en_core_web_sm")
|
|
9 |
|
10 |
def text_analysis(text):
|
11 |
doc = nlp(text)
|
12 |
-
|
13 |
-
|
|
|
|
|
14 |
"<div style='max-width:100%; max-height:360px; overflow:auto'>"
|
15 |
-
+
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
+ "</div>"
|
17 |
)
|
18 |
-
pos_count = {
|
19 |
-
"char_count": len(text),
|
20 |
-
"token_count": 0,
|
21 |
-
}
|
22 |
-
pos_tokens = []
|
23 |
|
24 |
rows = []
|
25 |
for token in doc:
|
@@ -27,12 +30,14 @@ def text_analysis(text):
|
|
27 |
token.shape_, token.is_alpha, token.is_stop))
|
28 |
|
29 |
table = pd.DataFrame(rows, columns = ["TEXT", "LEMMA","POS","TAG","DEP","SHAPE","ALPHA","STOP"])
|
30 |
-
|
|
|
|
|
31 |
|
32 |
demo = gr.Interface(
|
33 |
text_analysis,
|
34 |
gr.Textbox(placeholder="Enter sentence here..."),
|
35 |
-
[gr.Dataframe(), "html"],
|
36 |
examples=[
|
37 |
["Data Science Dojo is the leading platform providing training in data science, data analytics, and machine learning."],
|
38 |
["It's the best time to execute the plan."],
|
|
|
9 |
|
10 |
def text_analysis(text):
|
11 |
doc = nlp(text)
|
12 |
+
dependency_parsing = displacy.render(doc, style="dep", page=True)
|
13 |
+
named_entity_recognition = displacy.render(doc, style="ent")
|
14 |
+
|
15 |
+
visual1 = (
|
16 |
"<div style='max-width:100%; max-height:360px; overflow:auto'>"
|
17 |
+
+ dependency_parsing
|
18 |
+
+ "</div>"
|
19 |
+
)
|
20 |
+
|
21 |
+
visual2 = (
|
22 |
+
"<div style='max-width:100%; max-height:360px; overflow:auto'>"
|
23 |
+
+ named_entity_recognition
|
24 |
+ "</div>"
|
25 |
)
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
rows = []
|
28 |
for token in doc:
|
|
|
30 |
token.shape_, token.is_alpha, token.is_stop))
|
31 |
|
32 |
table = pd.DataFrame(rows, columns = ["TEXT", "LEMMA","POS","TAG","DEP","SHAPE","ALPHA","STOP"])
|
33 |
+
|
34 |
+
return table, visual1, visual2
|
35 |
+
|
36 |
|
37 |
demo = gr.Interface(
|
38 |
text_analysis,
|
39 |
gr.Textbox(placeholder="Enter sentence here..."),
|
40 |
+
[gr.Dataframe(), "html", "html"],
|
41 |
examples=[
|
42 |
["Data Science Dojo is the leading platform providing training in data science, data analytics, and machine learning."],
|
43 |
["It's the best time to execute the plan."],
|