Update app.py
Browse files
app.py
CHANGED
|
@@ -3,9 +3,6 @@ import gradio as gr
|
|
| 3 |
import math
|
| 4 |
import os
|
| 5 |
os.system("python -m textblob.download_corpora")
|
| 6 |
-
control_json={'control':'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','char':'','leng':62}
|
| 7 |
-
string_json={'control':'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN','char':'OPQRSTUVWXYZ','leng':50}
|
| 8 |
-
cont_list=list(string_json['control'])
|
| 9 |
|
| 10 |
def get_sen_list(text):
|
| 11 |
sen_list=[]
|
|
@@ -48,21 +45,23 @@ def proc_nouns(sen_list):
|
|
| 48 |
print("done nouns")
|
| 49 |
return noun_list
|
| 50 |
|
| 51 |
-
def sort_doc(
|
| 52 |
-
|
|
|
|
|
|
|
| 53 |
|
| 54 |
########################################
|
| 55 |
-
sen_list=get_sen_list(text)
|
| 56 |
-
key_cnt=len(sen_list)
|
| 57 |
|
| 58 |
-
sen_obj_box=[]
|
| 59 |
-
for ii,ee in enumerate(sen_list):
|
| 60 |
-
|
| 61 |
-
|
| 62 |
|
| 63 |
-
#sen_list=sen_obj_box
|
| 64 |
######################################
|
| 65 |
-
key_cnt=len(sen_obj_box)
|
|
|
|
| 66 |
print(key_cnt)
|
| 67 |
#noun_cnt=len(noun_box)
|
| 68 |
#print(noun_cnt)
|
|
@@ -116,7 +115,7 @@ def sort_doc(text,steps_in=0,control=None):
|
|
| 116 |
|
| 117 |
|
| 118 |
if go:
|
| 119 |
-
for i, ea in enumerate(
|
| 120 |
if go:
|
| 121 |
if cnt > char_len-1:
|
| 122 |
#print(step_cont_box)
|
|
@@ -138,31 +137,31 @@ def sort_doc(text,steps_in=0,control=None):
|
|
| 138 |
print(j)
|
| 139 |
out_js = out_js+control_char[j]
|
| 140 |
|
| 141 |
-
sen_obj_out=sen_obj_box[i]
|
| 142 |
|
| 143 |
-
aa=3
|
| 144 |
-
bb=3
|
| 145 |
-
aa=i if i < 3 else 3
|
| 146 |
|
| 147 |
-
sen_obj_out['sentence']=sen_list[i-aa:i+bb]
|
| 148 |
|
| 149 |
#sen_obj_out=sen_obj[i-3:i+3]
|
| 150 |
#sen_obj=sen_obj_box[i]
|
| 151 |
#sen_obj=proc_sen(sen_list,i)
|
| 152 |
|
| 153 |
#json_out[out_js]={'nouns':ea}
|
| 154 |
-
json_out[out_js]=
|
| 155 |
-
print ("#################")
|
| 156 |
-
print (out_js)
|
| 157 |
-
print (sen_obj)
|
| 158 |
-
print ("#################")
|
| 159 |
|
| 160 |
big_cnt+=1
|
| 161 |
if big_cnt==key_cnt:
|
| 162 |
print("DONE")
|
| 163 |
go=False
|
| 164 |
-
noun_list=proc_nouns(json_out)
|
| 165 |
-
return json_out
|
| 166 |
|
| 167 |
|
| 168 |
def find_query(query,sen,nouns):
|
|
|
|
| 3 |
import math
|
| 4 |
import os
|
| 5 |
os.system("python -m textblob.download_corpora")
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def get_sen_list(text):
|
| 8 |
sen_list=[]
|
|
|
|
| 45 |
print("done nouns")
|
| 46 |
return noun_list
|
| 47 |
|
| 48 |
+
def sort_doc(list: in_list,steps_in=0,control=None):
|
| 49 |
+
control_json={'control':'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','char':'','leng':62}
|
| 50 |
+
|
| 51 |
+
#text=str(text)
|
| 52 |
|
| 53 |
########################################
|
| 54 |
+
#sen_list=get_sen_list(text)
|
| 55 |
+
#key_cnt=len(sen_list)
|
| 56 |
|
| 57 |
+
#sen_obj_box=[]
|
| 58 |
+
#for ii,ee in enumerate(sen_list):
|
| 59 |
+
# sen_obj=proc_sen(sen_list,ii)
|
| 60 |
+
# sen_obj_box.append(sen_obj)
|
| 61 |
|
|
|
|
| 62 |
######################################
|
| 63 |
+
#key_cnt=len(sen_obj_box)
|
| 64 |
+
key_cnt=len(in_list)
|
| 65 |
print(key_cnt)
|
| 66 |
#noun_cnt=len(noun_box)
|
| 67 |
#print(noun_cnt)
|
|
|
|
| 115 |
|
| 116 |
|
| 117 |
if go:
|
| 118 |
+
for i, ea in enumerate(in_list):
|
| 119 |
if go:
|
| 120 |
if cnt > char_len-1:
|
| 121 |
#print(step_cont_box)
|
|
|
|
| 137 |
print(j)
|
| 138 |
out_js = out_js+control_char[j]
|
| 139 |
|
| 140 |
+
#sen_obj_out=sen_obj_box[i]
|
| 141 |
|
| 142 |
+
#aa=3
|
| 143 |
+
#bb=3
|
| 144 |
+
#aa=i if i < 3 else 3
|
| 145 |
|
| 146 |
+
#sen_obj_out['sentence']=sen_list[i-aa:i+bb]
|
| 147 |
|
| 148 |
#sen_obj_out=sen_obj[i-3:i+3]
|
| 149 |
#sen_obj=sen_obj_box[i]
|
| 150 |
#sen_obj=proc_sen(sen_list,i)
|
| 151 |
|
| 152 |
#json_out[out_js]={'nouns':ea}
|
| 153 |
+
json_out[out_js]=in_list[i]
|
| 154 |
+
#print ("#################")
|
| 155 |
+
#print (out_js)
|
| 156 |
+
#print (sen_obj)
|
| 157 |
+
#print ("#################")
|
| 158 |
|
| 159 |
big_cnt+=1
|
| 160 |
if big_cnt==key_cnt:
|
| 161 |
print("DONE")
|
| 162 |
go=False
|
| 163 |
+
#noun_list=proc_nouns(json_out)
|
| 164 |
+
return json_out
|
| 165 |
|
| 166 |
|
| 167 |
def find_query(query,sen,nouns):
|