Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,7 @@ def get_nouns(text):
|
|
10 |
json_object={}
|
11 |
sen_list=[]
|
12 |
noun_list={}
|
|
|
13 |
blob = TextBlob(text)
|
14 |
for sentence in blob.sentences:
|
15 |
#print(sentence)
|
@@ -32,7 +33,16 @@ def get_nouns(text):
|
|
32 |
#json_object[sen_list[cnt]]=f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}'
|
33 |
blob_n = TextBlob(sen_list[cnt])
|
34 |
noun_p=blob_n.noun_phrases
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
for noun in noun_p:
|
37 |
if noun in list(noun_list.keys()):
|
38 |
noun_list[str(noun)].append(f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}')
|
@@ -70,7 +80,21 @@ def get_nouns(text):
|
|
70 |
return json_object,noun_list
|
71 |
def find_query(query,sen,nouns):
|
72 |
blob_f = TextBlob(query)
|
|
|
|
|
73 |
for ea in blob_f.parse().split(" "):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
print(ea)
|
75 |
print(ea.split("/"))
|
76 |
return blob_f.parse()
|
|
|
10 |
json_object={}
|
11 |
sen_list=[]
|
12 |
noun_list={}
|
13 |
+
noun_box=[]
|
14 |
blob = TextBlob(text)
|
15 |
for sentence in blob.sentences:
|
16 |
#print(sentence)
|
|
|
33 |
#json_object[sen_list[cnt]]=f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}'
|
34 |
blob_n = TextBlob(sen_list[cnt])
|
35 |
noun_p=blob_n.noun_phrases
|
36 |
+
noun_box=[]
|
37 |
+
for ea in blob_n.parse().split(" "):
|
38 |
+
n=ea.split("/")
|
39 |
+
if n[1] == "NN":
|
40 |
+
noun_box.append(n[0])
|
41 |
+
|
42 |
+
|
43 |
+
|
44 |
+
json_object[f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}']={'sentence':sen_list[cnt],'noun_phrase':noun_p,'nouns':noun_box}
|
45 |
+
|
46 |
for noun in noun_p:
|
47 |
if noun in list(noun_list.keys()):
|
48 |
noun_list[str(noun)].append(f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}')
|
|
|
80 |
return json_object,noun_list
|
81 |
def find_query(query,sen,nouns):
|
82 |
blob_f = TextBlob(query)
|
83 |
+
noun_box={}
|
84 |
+
noun_list=[]
|
85 |
for ea in blob_f.parse().split(" "):
|
86 |
+
n=ea.split("/")
|
87 |
+
if n[1] == "NN":
|
88 |
+
|
89 |
+
noun_list.append(n[0])
|
90 |
+
for nn in list(nouns.keys()):
|
91 |
+
|
92 |
+
if nn in noun_list:
|
93 |
+
|
94 |
+
|
95 |
+
noun_box[n[0]]
|
96 |
+
|
97 |
+
|
98 |
print(ea)
|
99 |
print(ea.split("/"))
|
100 |
return blob_f.parse()
|