Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -94,6 +94,7 @@ def find_query(query,sen,nouns):
|
|
94 |
blob_f = TextBlob(query)
|
95 |
noun_box={}
|
96 |
noun_list=[]
|
|
|
97 |
for ea in blob_f.parse().split(" "):
|
98 |
n=ea.split("/")
|
99 |
if n[1] == "NN":
|
@@ -110,7 +111,12 @@ def find_query(query,sen,nouns):
|
|
110 |
noun_box[str(nl)]=[]
|
111 |
for ea_n in nouns[nn]:
|
112 |
noun_box[str(nl)].append(ea_n)
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
with gr.Blocks() as app:
|
116 |
inp = gr.Textbox(label="Paste Text",lines=10)
|
@@ -119,12 +125,13 @@ with gr.Blocks() as app:
|
|
119 |
query=gr.Textbox(label="Search query")
|
120 |
search_btn=gr.Button("Search")
|
121 |
out_box=gr.Textbox(label="Results")
|
|
|
122 |
with gr.Row():
|
123 |
with gr.Column(scale=2):
|
124 |
sen=gr.JSON(label="Sentences")
|
125 |
with gr.Column(scale=1):
|
126 |
nouns=gr.JSON(label="Nouns")
|
127 |
-
search_btn.click(find_query,[query,sen,nouns],out_box)
|
128 |
btn.click(get_nouns,inp,[sen,nouns])
|
129 |
app.launch()
|
130 |
|
|
|
94 |
blob_f = TextBlob(query)
|
95 |
noun_box={}
|
96 |
noun_list=[]
|
97 |
+
sen_box=[]
|
98 |
for ea in blob_f.parse().split(" "):
|
99 |
n=ea.split("/")
|
100 |
if n[1] == "NN":
|
|
|
111 |
noun_box[str(nl)]=[]
|
112 |
for ea_n in nouns[nn]:
|
113 |
noun_box[str(nl)].append(ea_n)
|
114 |
+
for ea in noun_box.values():
|
115 |
+
for vals in ea:
|
116 |
+
sen_box.append(sen[vals])
|
117 |
+
|
118 |
+
|
119 |
+
return noun_box,sen_box
|
120 |
|
121 |
with gr.Blocks() as app:
|
122 |
inp = gr.Textbox(label="Paste Text",lines=10)
|
|
|
125 |
query=gr.Textbox(label="Search query")
|
126 |
search_btn=gr.Button("Search")
|
127 |
out_box=gr.Textbox(label="Results")
|
128 |
+
sen_box=gr.Textbox(label="Sentences")
|
129 |
with gr.Row():
|
130 |
with gr.Column(scale=2):
|
131 |
sen=gr.JSON(label="Sentences")
|
132 |
with gr.Column(scale=1):
|
133 |
nouns=gr.JSON(label="Nouns")
|
134 |
+
search_btn.click(find_query,[query,sen,nouns],[out_box,sen_box])
|
135 |
btn.click(get_nouns,inp,[sen,nouns])
|
136 |
app.launch()
|
137 |
|