Spaces:
Runtime error
Runtime error
Add search box
Browse files
app.py
CHANGED
|
@@ -16,6 +16,11 @@ def main():
|
|
| 16 |
|
| 17 |
with gr.Blocks(css='style.css') as demo:
|
| 18 |
gr.Markdown(DESCRIPTION)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
names_with_link = gr.CheckboxGroup(choices=[
|
| 20 |
'Supp',
|
| 21 |
'arXiv',
|
|
@@ -26,9 +31,26 @@ def main():
|
|
| 26 |
table = gr.HTML(html_text, show_label=False)
|
| 27 |
gr.Markdown(FOOTER)
|
| 28 |
|
| 29 |
-
demo.load(paper_list.render,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
names_with_link.change(paper_list.render,
|
| 31 |
-
inputs=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
outputs=table)
|
| 33 |
|
| 34 |
demo.launch(enable_queue=True, share=False)
|
|
|
|
| 16 |
|
| 17 |
with gr.Blocks(css='style.css') as demo:
|
| 18 |
gr.Markdown(DESCRIPTION)
|
| 19 |
+
search_box = gr.Textbox(
|
| 20 |
+
label='Keywords',
|
| 21 |
+
placeholder='You can search for titles with regular expressions')
|
| 22 |
+
case_sensitive = gr.Checkbox(label='Case Sensitive')
|
| 23 |
+
search_button = gr.Button('Search')
|
| 24 |
names_with_link = gr.CheckboxGroup(choices=[
|
| 25 |
'Supp',
|
| 26 |
'arXiv',
|
|
|
|
| 31 |
table = gr.HTML(html_text, show_label=False)
|
| 32 |
gr.Markdown(FOOTER)
|
| 33 |
|
| 34 |
+
demo.load(paper_list.render,
|
| 35 |
+
inputs=[
|
| 36 |
+
search_box,
|
| 37 |
+
case_sensitive,
|
| 38 |
+
names_with_link,
|
| 39 |
+
],
|
| 40 |
+
outputs=table)
|
| 41 |
+
search_button.click(paper_list.render,
|
| 42 |
+
inputs=[
|
| 43 |
+
search_box,
|
| 44 |
+
case_sensitive,
|
| 45 |
+
names_with_link,
|
| 46 |
+
],
|
| 47 |
+
outputs=table)
|
| 48 |
names_with_link.change(paper_list.render,
|
| 49 |
+
inputs=[
|
| 50 |
+
search_box,
|
| 51 |
+
case_sensitive,
|
| 52 |
+
names_with_link,
|
| 53 |
+
],
|
| 54 |
outputs=table)
|
| 55 |
|
| 56 |
demo.launch(enable_queue=True, share=False)
|
papers.py
CHANGED
|
@@ -6,6 +6,8 @@ import pandas as pd
|
|
| 6 |
class PaperList:
|
| 7 |
def __init__(self):
|
| 8 |
self.table = pd.read_csv('papers.csv')
|
|
|
|
|
|
|
| 9 |
self.table_header = '''
|
| 10 |
<tr>
|
| 11 |
<td width="50%">Paper</td>
|
|
@@ -17,12 +19,19 @@ class PaperList:
|
|
| 17 |
<td width="5%">Hugging Face Spaces</td>
|
| 18 |
</tr>'''
|
| 19 |
|
| 20 |
-
def render(self,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
has_supp = 'Supp' in names_with_link
|
| 22 |
has_arxiv = 'arXiv' in names_with_link
|
| 23 |
has_github = 'GitHub' in names_with_link
|
| 24 |
has_hf_space = 'HF Space' in names_with_link
|
| 25 |
-
df = self.filter_table(
|
| 26 |
has_hf_space)
|
| 27 |
return self.to_html(df)
|
| 28 |
|
|
|
|
| 6 |
class PaperList:
|
| 7 |
def __init__(self):
|
| 8 |
self.table = pd.read_csv('papers.csv')
|
| 9 |
+
self.table['title_lowercase'] = self.table.title.str.lower()
|
| 10 |
+
|
| 11 |
self.table_header = '''
|
| 12 |
<tr>
|
| 13 |
<td width="50%">Paper</td>
|
|
|
|
| 19 |
<td width="5%">Hugging Face Spaces</td>
|
| 20 |
</tr>'''
|
| 21 |
|
| 22 |
+
def render(self, search_query: str, case_sensitive: bool,
|
| 23 |
+
names_with_link: list[str]) -> str:
|
| 24 |
+
df = self.table
|
| 25 |
+
if search_query:
|
| 26 |
+
if case_sensitive:
|
| 27 |
+
df = df[df.title.str.contains(search_query)]
|
| 28 |
+
else:
|
| 29 |
+
df = df[df.title_lowercase.str.contains(search_query.lower())]
|
| 30 |
has_supp = 'Supp' in names_with_link
|
| 31 |
has_arxiv = 'arXiv' in names_with_link
|
| 32 |
has_github = 'GitHub' in names_with_link
|
| 33 |
has_hf_space = 'HF Space' in names_with_link
|
| 34 |
+
df = self.filter_table(df, has_supp, has_arxiv, has_github,
|
| 35 |
has_hf_space)
|
| 36 |
return self.to_html(df)
|
| 37 |
|