Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,10 +43,6 @@ def proc_sen(sen_list,cnt):
|
|
| 43 |
if n[1] == "NN":
|
| 44 |
noun_box1.append(n[0])
|
| 45 |
json_object={'sentence':sen_list[cnt],'noun_phrase':noun_p,'nouns':noun_box1}
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
return json_object
|
| 51 |
|
| 52 |
def proc_nouns(sen_list):
|
|
@@ -59,7 +55,7 @@ def proc_nouns(sen_list):
|
|
| 59 |
noun_list[str(nnn)]=[nn]
|
| 60 |
return noun_list
|
| 61 |
|
| 62 |
-
def get_nouns(text=text):
|
| 63 |
control_len=control_json['leng']-steps
|
| 64 |
control_char=list(control_json['control'])
|
| 65 |
control_char_val=list(control_json['control'][:control_len])
|
|
@@ -140,69 +136,6 @@ def get_nouns(text=text):
|
|
| 140 |
return json_out, noun_list
|
| 141 |
|
| 142 |
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
def get_nouns_OG(text,steps=1):
|
| 146 |
-
control_len=control_json['leng']-steps
|
| 147 |
-
control_new=control_json['control'][:control_len]
|
| 148 |
-
control_char=control_json['control'][control_len:]
|
| 149 |
-
print(control_new)
|
| 150 |
-
print(control_char)
|
| 151 |
-
json_object={}
|
| 152 |
-
sen_list=[]
|
| 153 |
-
noun_list={}
|
| 154 |
-
noun_box=[]
|
| 155 |
-
blob = TextBlob(text)
|
| 156 |
-
for sentence in blob.sentences:
|
| 157 |
-
sen_list.append(str(sentence))
|
| 158 |
-
key_cnt=len(sen_list)
|
| 159 |
-
cnt=0
|
| 160 |
-
go=True
|
| 161 |
-
a="Z"
|
| 162 |
-
if go:
|
| 163 |
-
for ea in range(10):
|
| 164 |
-
if go:
|
| 165 |
-
for b in range(50):
|
| 166 |
-
if go:
|
| 167 |
-
for c in range(50):
|
| 168 |
-
if go:
|
| 169 |
-
for d in range(50):
|
| 170 |
-
if go:
|
| 171 |
-
blob_n = TextBlob(sen_list[cnt])
|
| 172 |
-
noun_p=blob_n.noun_phrases
|
| 173 |
-
noun_box=[]
|
| 174 |
-
for ea in blob_n.parse().split(" "):
|
| 175 |
-
n=ea.split("/")
|
| 176 |
-
if n[1] == "NN":
|
| 177 |
-
noun_box.append(n[0])
|
| 178 |
-
json_object[f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}']={'sentence':sen_list[cnt],'noun_phrase':noun_p,'nouns':noun_box}
|
| 179 |
-
for noun in noun_p:
|
| 180 |
-
if noun in list(noun_list.keys()):
|
| 181 |
-
noun_list[str(noun)].append(f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}')
|
| 182 |
-
else:
|
| 183 |
-
noun_list[str(noun)]=[f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}']
|
| 184 |
-
for nn in noun_box:
|
| 185 |
-
if nn in list(noun_list.keys()):
|
| 186 |
-
noun_list[str(nn)].append(f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}')
|
| 187 |
-
else:
|
| 188 |
-
noun_list[str(nn)]=[f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}']
|
| 189 |
-
if json_object[f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}']=='ZNNN':
|
| 190 |
-
a="Y"
|
| 191 |
-
b=0
|
| 192 |
-
c=0
|
| 193 |
-
d=0
|
| 194 |
-
if json_object[f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}']=='YNNN':
|
| 195 |
-
a="X"
|
| 196 |
-
b=0
|
| 197 |
-
c=0
|
| 198 |
-
d=0
|
| 199 |
-
if cnt == key_cnt-1:
|
| 200 |
-
print('done')
|
| 201 |
-
go=False
|
| 202 |
-
print(list(json_object.keys())[-1])
|
| 203 |
-
else:
|
| 204 |
-
cnt+=1
|
| 205 |
-
return json_object,noun_list
|
| 206 |
def find_query(query,sen,nouns):
|
| 207 |
blob_f = TextBlob(query)
|
| 208 |
noun_box={}
|
|
|
|
| 43 |
if n[1] == "NN":
|
| 44 |
noun_box1.append(n[0])
|
| 45 |
json_object={'sentence':sen_list[cnt],'noun_phrase':noun_p,'nouns':noun_box1}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
return json_object
|
| 47 |
|
| 48 |
def proc_nouns(sen_list):
|
|
|
|
| 55 |
noun_list[str(nnn)]=[nn]
|
| 56 |
return noun_list
|
| 57 |
|
| 58 |
+
def get_nouns(text=text,steps=1):
|
| 59 |
control_len=control_json['leng']-steps
|
| 60 |
control_char=list(control_json['control'])
|
| 61 |
control_char_val=list(control_json['control'][:control_len])
|
|
|
|
| 136 |
return json_out, noun_list
|
| 137 |
|
| 138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
def find_query(query,sen,nouns):
|
| 140 |
blob_f = TextBlob(query)
|
| 141 |
noun_box={}
|