rhea2809 commited on
Commit
d38eecf
·
verified ·
1 Parent(s): af612ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +122 -7
app.py CHANGED
@@ -14,9 +14,10 @@ class DataList:
14
  self.table_header = '''
15
  <tr>
16
  <td width="15%">Name</td>
17
- <td width="52%">Description</td>
18
  <td width="15%">Module</td>
19
  <td width="20%">Type (Format)</td>
 
20
  </tr>'''
21
 
22
  def _preprocess_table(self) -> None:
@@ -32,34 +33,38 @@ class DataList:
32
  <td>{row.Description}</td>
33
  <td>{row.Module}</td>
34
  <td>{row.Type}</td>
 
35
  </tr>'''
36
  rows.append(row)
37
  self.table['html_table_content'] = rows
38
 
39
  def render(self, search_query: str,
40
  filter_names: list[str],
41
- filter_names2: list[str], ) -> tuple[int, str]:
 
42
  self.table = pd.read_csv(csv_url)
43
  self._preprocess_table()
44
 
45
  self.table_header = '''
46
  <tr>
47
  <td width="15%">Name</td>
48
- <td width="52%">Description</td>
49
  <td width="15%">Module</td>
50
  <td width="20%">Type (Format)</td>
 
51
  </tr>'''
52
  df = self.table
53
  if search_query:
54
  df = df[df.name_lowercase.str.contains(search_query.lower())]
55
- df = self.filter_table(df, filter_names,filter_names2)
56
  result = self.to_html(df, self.table_header)
57
  return result
58
 
59
  @staticmethod
60
- def filter_table(df: pd.DataFrame, filter_names: list[str], filter_names2: list[str]) -> pd.DataFrame:
61
  df = df.loc[df.Module.isin(set(filter_names))]
62
  df= df[df.Type.str.contains('|'.join(filter_names2),case=False, regex=True)]
 
63
  return df
64
 
65
  @staticmethod
@@ -98,11 +103,121 @@ with gr.Blocks(css=css) as demo:
98
  search_box = gr.Textbox( label='Search Name', placeholder='You can search for titles with regular expressions. e.g. (?<!sur)face',max_lines=1, scale = 5)
99
  filter_names = gr.CheckboxGroup(choices=["Responsible AI 101", "Responsible AI Governance", "AI System Risk and Assurance", "Generative and Agentic AI", "AI Regulation and Compliance", "AI Procurement"], value=["Responsible AI 101", "Responsible AI Governance", "AI System Risk and Assurance", "Generative and Agentic AI", "AI Regulation and Compliance", "AI Procurement"], label='Type')
100
  filter_names2 = gr.CheckboxGroup(choices=['Deck','Document/Report','Infogrphic','Video/Audio','Repository/Directory',], value=['Deck','Document/Report','Infogrphic','Video/Audio','Repository/Directory',], label='Type (Format)')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  search_button = gr.Button('Search', size = 'sm', scale =1)
102
  table = gr.HTML(show_label=False)
103
 
104
- demo.load(fn=data_list.render, inputs=[search_box, filter_names,filter_names2,], outputs=[table,])
105
- search_button.click(fn=data_list.render, inputs=[search_box, filter_names,filter_names2,], outputs=[table,])
106
 
107
  demo.queue()
108
  demo.launch(share=False)
 
14
  self.table_header = '''
15
  <tr>
16
  <td width="15%">Name</td>
17
+ <td width="30%">Description</td>
18
  <td width="15%">Module</td>
19
  <td width="20%">Type (Format)</td>
20
+ <td width="20%">Hashtags (Format)</td>
21
  </tr>'''
22
 
23
  def _preprocess_table(self) -> None:
 
33
  <td>{row.Description}</td>
34
  <td>{row.Module}</td>
35
  <td>{row.Type}</td>
36
+ <td>{row.Hashtags}</td>
37
  </tr>'''
38
  rows.append(row)
39
  self.table['html_table_content'] = rows
40
 
41
  def render(self, search_query: str,
42
  filter_names: list[str],
43
+ filter_names2: list[str],
44
+ filter_names3: list[str],) -> tuple[int, str]:
45
  self.table = pd.read_csv(csv_url)
46
  self._preprocess_table()
47
 
48
  self.table_header = '''
49
  <tr>
50
  <td width="15%">Name</td>
51
+ <td width="30%">Description</td>
52
  <td width="15%">Module</td>
53
  <td width="20%">Type (Format)</td>
54
+ <td width="20%">Hashtags (Format)</td>
55
  </tr>'''
56
  df = self.table
57
  if search_query:
58
  df = df[df.name_lowercase.str.contains(search_query.lower())]
59
+ df = self.filter_table(df, filter_names,filter_names2,filter_names3)
60
  result = self.to_html(df, self.table_header)
61
  return result
62
 
63
  @staticmethod
64
+ def filter_table(df: pd.DataFrame, filter_names: list[str], filter_names2: list[str], filter_names3: list[str]) -> pd.DataFrame:
65
  df = df.loc[df.Module.isin(set(filter_names))]
66
  df= df[df.Type.str.contains('|'.join(filter_names2),case=False, regex=True)]
67
+ df= df[df.Type.str.contains('|'.join(filter_names3),case=False, regex=True)]
68
  return df
69
 
70
  @staticmethod
 
103
  search_box = gr.Textbox( label='Search Name', placeholder='You can search for titles with regular expressions. e.g. (?<!sur)face',max_lines=1, scale = 5)
104
  filter_names = gr.CheckboxGroup(choices=["Responsible AI 101", "Responsible AI Governance", "AI System Risk and Assurance", "Generative and Agentic AI", "AI Regulation and Compliance", "AI Procurement"], value=["Responsible AI 101", "Responsible AI Governance", "AI System Risk and Assurance", "Generative and Agentic AI", "AI Regulation and Compliance", "AI Procurement"], label='Type')
105
  filter_names2 = gr.CheckboxGroup(choices=['Deck','Document/Report','Infogrphic','Video/Audio','Repository/Directory',], value=['Deck','Document/Report','Infogrphic','Video/Audio','Repository/Directory',], label='Type (Format)')
106
+ filter_names3 = gr.CheckboxGroup(choices=[
107
+ "#AIImpacts",
108
+ "#AIAssessment&Audit",
109
+ "#AIDesign",
110
+ "#AIDevelopment",
111
+ "#AIDeployment",
112
+ "#AIMonitoring",
113
+ "#AIOperating&Maintenance",
114
+ "#AIDecommissioning",
115
+ "#AITesting&Evaluation",
116
+ "#AITraining",
117
+ "#AIStandards",
118
+ "#AIUseCase",
119
+ "#Accountability&Transparency",
120
+ "#CheatSheet",
121
+ "#Checklist",
122
+ "#CaseStudy",
123
+ "#Cybersecurity",
124
+ "#Data&AI",
125
+ "#EUAIAct",
126
+ "#EUGDPR",
127
+ "#EmergingTopic",
128
+ "#Explainability&Interpretability",
129
+ "#FactSheet",
130
+ "#Fairness&Bias",
131
+ "#FederalRegulations",
132
+ "#Frameworks",
133
+ "#FrontierAI",
134
+ "#ForAuditors",
135
+ "#ForDevelopers",
136
+ "#ForDeployers",
137
+ "#ForLeadership",
138
+ "#GlobalStandards",
139
+ "#Glossary",
140
+ "#Government&PublicSector",
141
+ "#Guide",
142
+ "#Healthcare",
143
+ "#HR",
144
+ "#ISO42001",
145
+ "#Industrial",
146
+ "#Manufacturing",
147
+ "#Marketing",
148
+ "#News&Journalism",
149
+ "#Privacy",
150
+ "#Report",
151
+ "#Retail",
152
+ "#Safety",
153
+ "#Security&Resiliency",
154
+ "#StateRegulations",
155
+ "#Template",
156
+ "#Toolkit",
157
+ "#Training",
158
+ "#Validity&Reliability",
159
+ "#WhitePaper"
160
+ ]
161
+ , value=[
162
+ "#AIImpacts",
163
+ "#AIAssessment&Audit",
164
+ "#AIDesign",
165
+ "#AIDevelopment",
166
+ "#AIDeployment",
167
+ "#AIMonitoring",
168
+ "#AIOperating&Maintenance",
169
+ "#AIDecommissioning",
170
+ "#AITesting&Evaluation",
171
+ "#AITraining",
172
+ "#AIStandards",
173
+ "#AIUseCase",
174
+ "#Accountability&Transparency",
175
+ "#CheatSheet",
176
+ "#Checklist",
177
+ "#CaseStudy",
178
+ "#Cybersecurity",
179
+ "#Data&AI",
180
+ "#EUAIAct",
181
+ "#EUGDPR",
182
+ "#EmergingTopic",
183
+ "#Explainability&Interpretability",
184
+ "#FactSheet",
185
+ "#Fairness&Bias",
186
+ "#FederalRegulations",
187
+ "#Frameworks",
188
+ "#FrontierAI",
189
+ "#ForAuditors",
190
+ "#ForDevelopers",
191
+ "#ForDeployers",
192
+ "#ForLeadership",
193
+ "#GlobalStandards",
194
+ "#Glossary",
195
+ "#Government&PublicSector",
196
+ "#Guide",
197
+ "#Healthcare",
198
+ "#HR",
199
+ "#ISO42001",
200
+ "#Industrial",
201
+ "#Manufacturing",
202
+ "#Marketing",
203
+ "#News&Journalism",
204
+ "#Privacy",
205
+ "#Report",
206
+ "#Retail",
207
+ "#Safety",
208
+ "#Security&Resiliency",
209
+ "#StateRegulations",
210
+ "#Template",
211
+ "#Toolkit",
212
+ "#Training",
213
+ "#Validity&Reliability",
214
+ "#WhitePaper"
215
+ ], label='Type (Format)')
216
  search_button = gr.Button('Search', size = 'sm', scale =1)
217
  table = gr.HTML(show_label=False)
218
 
219
+ demo.load(fn=data_list.render, inputs=[search_box, filter_names,filter_names2,filter_names3,], outputs=[table,])
220
+ search_button.click(fn=data_list.render, inputs=[search_box, filter_names,filter_names2,filter_names3,], outputs=[table,])
221
 
222
  demo.queue()
223
  demo.launch(share=False)