MK-316 commited on
Commit
1d772ce
1 Parent(s): 62a9f71

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -11,7 +11,10 @@ def search_years(search_mode, query):
11
  matches = df[df['YEAR'].str.startswith(query[:4])]
12
  elif search_mode == "Search Years by Keywords":
13
  keyword_list = [keyword.strip() for keyword in query.split(',')]
14
- matches = df[df['TEXT'].apply(lambda x: any(keyword in x for keyword in keyword_list))]
 
 
 
15
  else:
16
  return [], "Please select exactly one search mode."
17
 
@@ -36,10 +39,10 @@ with gr.Blocks() as app:
36
  gr.Markdown("## ❄️ [1] Search Data")
37
 
38
  # Radio buttons to select search mode
39
- search_mode = gr.Radio(choices=["Search by YEAR", "Search Years by Keywords"], label="Search Mode")
40
 
41
  # Row for search query and button
42
- search_input = gr.Textbox(label="Search Query: e.g., 2024 (by YEAR) or tapping (by Keywords)", placeholder="Enter year or keywords")
43
  search_button = gr.Button("Click to Search")
44
  search_output = gr.Dropdown(label="Results (file names)", choices=[], visible=False)
45
  status_output = gr.Textbox(label="Status", visible=False)
 
11
  matches = df[df['YEAR'].str.startswith(query[:4])]
12
  elif search_mode == "Search Years by Keywords":
13
  keyword_list = [keyword.strip() for keyword in query.split(',')]
14
+ matches = df[df['KEYWORDS'].apply(lambda x: any(keyword in x for keyword in keyword_list))] # Search in 'KEYWORDS'
15
+ elif search_mode == "Search Years by Words": # New option for 'Search by Words'
16
+ word_list = [word.strip() for word in query.split(',')]
17
+ matches = df[df['TEXT'].apply(lambda x: any(word in x for word in word_list))] # Search in 'TEXT'
18
  else:
19
  return [], "Please select exactly one search mode."
20
 
 
39
  gr.Markdown("## ❄️ [1] Search Data")
40
 
41
  # Radio buttons to select search mode
42
+ search_mode = gr.Radio(choices=["Search by YEAR", "Search Years by Keywords", "Search Years by Words"], label="Search Mode") # Added 'Search by Words'
43
 
44
  # Row for search query and button
45
+ search_input = gr.Textbox(label="Search Query: e.g., 2024 (by YEAR) or tapping (by Keywords or Words)", placeholder="Enter year or keywords or words")
46
  search_button = gr.Button("Click to Search")
47
  search_output = gr.Dropdown(label="Results (file names)", choices=[], visible=False)
48
  status_output = gr.Textbox(label="Status", visible=False)