taishi-i commited on
Commit
ed8d73f
1 Parent(s): 2fcc9e9

add source search function

Browse files
Files changed (1) hide show
  1. app.py +24 -3
app.py CHANGED
@@ -29,7 +29,7 @@ for data_json in json_data:
29
  data = pd.DataFrame(data)
30
 
31
 
32
- def show_search_results(language_filter, queries):
33
  queries = queries.lower()
34
  queries = queries.split()
35
 
@@ -43,6 +43,12 @@ def show_search_results(language_filter, queries):
43
  )
44
  ]
45
 
 
 
 
 
 
 
46
  for query in queries:
47
  contained_description = data["description"].str.contains(query)
48
 
@@ -90,15 +96,30 @@ with gr.Blocks() as demo:
90
  choices=languages,
91
  )
92
 
 
 
 
 
 
 
93
  df = gr.DataFrame(
94
  value=data, type="pandas", datatype="markdown", height=1000
95
  )
96
 
97
  query.change(
98
- fn=show_search_results, inputs=[language_selector, query], outputs=df
 
 
99
  )
100
  language_selector.change(
101
- fn=show_search_results, inputs=[language_selector, query], outputs=df
 
 
 
 
 
 
 
102
  )
103
 
104
  demo.launch()
 
29
  data = pd.DataFrame(data)
30
 
31
 
32
+ def show_search_results(language_filter, queries, source_checkbox):
33
  queries = queries.lower()
34
  queries = queries.split()
35
 
 
43
  )
44
  ]
45
 
46
+ if "GitHub" not in source_checkbox:
47
+ df_search = df_search[df_search["source"] != "GitHub"]
48
+
49
+ if "Hugging Face" not in source_checkbox:
50
+ df_search = df_search[df_search["source"] != "Hugging Face"]
51
+
52
  for query in queries:
53
  contained_description = data["description"].str.contains(query)
54
 
 
96
  choices=languages,
97
  )
98
 
99
+ source_checkbox = gr.CheckboxGroup(
100
+ ["GitHub", "Hugging Face"],
101
+ value=["GitHub", "Hugging Face"],
102
+ label="Source",
103
+ )
104
+
105
  df = gr.DataFrame(
106
  value=data, type="pandas", datatype="markdown", height=1000
107
  )
108
 
109
  query.change(
110
+ fn=show_search_results,
111
+ inputs=[language_selector, query, source_checkbox],
112
+ outputs=df,
113
  )
114
  language_selector.change(
115
+ fn=show_search_results,
116
+ inputs=[language_selector, query, source_checkbox],
117
+ outputs=df,
118
+ )
119
+ source_checkbox.change(
120
+ fn=show_search_results,
121
+ inputs=[language_selector, query, source_checkbox],
122
+ outputs=df,
123
  )
124
 
125
  demo.launch()