Spaces:
Paused
Paused
capture enter
Browse files
app.py
CHANGED
@@ -75,6 +75,10 @@ def process_results(results, highlight_terms):
|
|
75 |
|
76 |
def scisearch(query, language, num_results=10):
|
77 |
try:
|
|
|
|
|
|
|
|
|
78 |
post_data = {"query": query, "k": num_results}
|
79 |
if language != "detect_language":
|
80 |
post_data["lang"] = language
|
@@ -176,11 +180,20 @@ if __name__ == "__main__":
|
|
176 |
css=".underline-on-hover:hover { text-decoration: underline; } .flagging { font-size:12px; color:Silver; }"
|
177 |
)
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
with demo:
|
180 |
with gr.Row():
|
181 |
gr.Markdown(value=description)
|
182 |
with gr.Row():
|
183 |
query = gr.Textbox(lines=2, placeholder="Type your query here...", label="Query")
|
|
|
184 |
with gr.Row():
|
185 |
lang = gr.Dropdown(
|
186 |
choices=[
|
@@ -200,7 +213,7 @@ if __name__ == "__main__":
|
|
200 |
"detect_language",
|
201 |
"all",
|
202 |
],
|
203 |
-
value="
|
204 |
label="Language",
|
205 |
)
|
206 |
with gr.Row():
|
@@ -223,14 +236,6 @@ if __name__ == "__main__":
|
|
223 |
flag_btn = gr.Button("Flag Results")
|
224 |
flag_btn.click(flag, inputs=[query, lang, k, flag_txt], outputs=[flag_txt])
|
225 |
|
226 |
-
def submit(query, lang, k):
|
227 |
-
if query == "":
|
228 |
-
return ["", ""]
|
229 |
-
return {
|
230 |
-
results: scisearch(query, lang, k),
|
231 |
-
flagging_form: gr.update(visible=True),
|
232 |
-
}
|
233 |
-
|
234 |
submit_btn.click(submit, inputs=[query, lang, k], outputs=[results, flagging_form])
|
235 |
|
236 |
demo.launch(enable_queue=True, debug=True)
|
|
|
75 |
|
76 |
def scisearch(query, language, num_results=10):
|
77 |
try:
|
78 |
+
query = query.strip()
|
79 |
+
if query == "" or query is None:
|
80 |
+
return
|
81 |
+
|
82 |
post_data = {"query": query, "k": num_results}
|
83 |
if language != "detect_language":
|
84 |
post_data["lang"] = language
|
|
|
180 |
css=".underline-on-hover:hover { text-decoration: underline; } .flagging { font-size:12px; color:Silver; }"
|
181 |
)
|
182 |
|
183 |
+
def submit(query, lang, k):
|
184 |
+
if query == "":
|
185 |
+
return ["", ""]
|
186 |
+
return {
|
187 |
+
results: scisearch(query, lang, k),
|
188 |
+
flagging_form: gr.update(visible=True),
|
189 |
+
}
|
190 |
+
|
191 |
with demo:
|
192 |
with gr.Row():
|
193 |
gr.Markdown(value=description)
|
194 |
with gr.Row():
|
195 |
query = gr.Textbox(lines=2, placeholder="Type your query here...", label="Query")
|
196 |
+
query.submit(fn=submit)
|
197 |
with gr.Row():
|
198 |
lang = gr.Dropdown(
|
199 |
choices=[
|
|
|
213 |
"detect_language",
|
214 |
"all",
|
215 |
],
|
216 |
+
value="en",
|
217 |
label="Language",
|
218 |
)
|
219 |
with gr.Row():
|
|
|
236 |
flag_btn = gr.Button("Flag Results")
|
237 |
flag_btn.click(flag, inputs=[query, lang, k, flag_txt], outputs=[flag_txt])
|
238 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
submit_btn.click(submit, inputs=[query, lang, k], outputs=[results, flagging_form])
|
240 |
|
241 |
demo.launch(enable_queue=True, debug=True)
|