ola13 commited on
Commit
128dbfe
·
1 Parent(s): 63a9efb

whitespace handling

Browse files
Files changed (1) hide show
  1. app.py +8 -3
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
@@ -224,13 +228,14 @@ if __name__ == "__main__":
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
 
228
  flag_btn.click(flag, inputs=[query, lang, k, flag_txt], outputs=[flag_txt])
229
 
230
  def submit(query, lang, k):
231
+ query = query.strip()
232
+ if query is None or query == "":
233
+ return "", ""
234
  return {
235
  results: scisearch(query, lang, k),
236
  flagging_form: gr.update(visible=True),
237
  }
238
+ query.submit(fn=submit, inputs=[query, lang, k], outputs=[results, flagging_form])
239
  submit_btn.click(submit, inputs=[query, lang, k], outputs=[results, flagging_form])
240
 
241
  demo.launch(enable_queue=True, debug=True)