Spaces:
Sleeping
Sleeping
update
Browse files
app.py
CHANGED
@@ -62,7 +62,7 @@ def convert_to_logical_expression(logics, keywords, fields):
|
|
62 |
"All": "all"
|
63 |
}
|
64 |
# Create a list of expressions for each logic, keyword, and field
|
65 |
-
expressions = [f'{logic}+{field_mapping[field]}:"{keyword}"'
|
66 |
|
67 |
# Combine expressions using logic operators
|
68 |
logical_expression = f"+".join(expressions)
|
@@ -71,6 +71,7 @@ def convert_to_logical_expression(logics, keywords, fields):
|
|
71 |
|
72 |
return logical_expression, api_url
|
73 |
|
|
|
74 |
with gr.Blocks(title='Arxiv Search🔍️') as demo:
|
75 |
gr.HTML('''
|
76 |
<center>
|
@@ -86,7 +87,7 @@ with gr.Blocks(title='Arxiv Search🔍️') as demo:
|
|
86 |
keyword = gr.Textbox(lines=1, label='Search Term')
|
87 |
Keywords.append(keyword)
|
88 |
with gr.Column(scale=5):
|
89 |
-
tag = gr.Dropdown(['Title', 'Abstract', 'All'], label='Search Type', value='
|
90 |
Fields.append(tag)
|
91 |
else:
|
92 |
with gr.Column(scale=1):
|
@@ -96,17 +97,19 @@ with gr.Blocks(title='Arxiv Search🔍️') as demo:
|
|
96 |
keyword = gr.Textbox(lines=1, label='Search Term')
|
97 |
Keywords.append(keyword)
|
98 |
with gr.Column(scale=3):
|
99 |
-
tag = gr.Dropdown(['Title', 'Abstract', 'All'], label='Search Type', value='
|
100 |
Fields.append(tag)
|
101 |
|
102 |
arxiv_res = gr.HTML(label = 'Arxiv Search Results')
|
103 |
submit = gr.Button(label='Search', variant='primary')
|
|
|
104 |
submit.click(fn=arxiv_search, inputs=[*Logics, *Keywords, *Fields], outputs=arxiv_res)
|
|
|
105 |
|
106 |
gr.Examples([
|
107 |
[ "NeRF", "Title", "AND", "GAN", "Abstract"],
|
108 |
[ "GAN", "All", "OR", "Diffusion", "All"],
|
109 |
-
], inputs=[ Keywords[0], Fields[0], Logics[
|
110 |
|
111 |
demo.launch(debug = True)
|
112 |
|
|
|
62 |
"All": "all"
|
63 |
}
|
64 |
# Create a list of expressions for each logic, keyword, and field
|
65 |
+
expressions = [f'{logic}+{field_mapping[field]}:"{keyword}"' for logic, keyword, field in zip(logics, keywords, fields) if keyword != '']
|
66 |
|
67 |
# Combine expressions using logic operators
|
68 |
logical_expression = f"+".join(expressions)
|
|
|
71 |
|
72 |
return logical_expression, api_url
|
73 |
|
74 |
+
|
75 |
with gr.Blocks(title='Arxiv Search🔍️') as demo:
|
76 |
gr.HTML('''
|
77 |
<center>
|
|
|
87 |
keyword = gr.Textbox(lines=1, label='Search Term')
|
88 |
Keywords.append(keyword)
|
89 |
with gr.Column(scale=5):
|
90 |
+
tag = gr.Dropdown(['Title', 'Abstract', 'All'], label='Search Type', value='Title')
|
91 |
Fields.append(tag)
|
92 |
else:
|
93 |
with gr.Column(scale=1):
|
|
|
97 |
keyword = gr.Textbox(lines=1, label='Search Term')
|
98 |
Keywords.append(keyword)
|
99 |
with gr.Column(scale=3):
|
100 |
+
tag = gr.Dropdown(['Title', 'Abstract', 'All'], label='Search Type', value='Title')
|
101 |
Fields.append(tag)
|
102 |
|
103 |
arxiv_res = gr.HTML(label = 'Arxiv Search Results')
|
104 |
submit = gr.Button(label='Search', variant='primary')
|
105 |
+
clear = gr.ClearButton(label='Clear')
|
106 |
submit.click(fn=arxiv_search, inputs=[*Logics, *Keywords, *Fields], outputs=arxiv_res)
|
107 |
+
clear.click(outputs=[*Logics, *Keywords, *Fields], fn=lambda: ['OR']*4 + ['']*5 + ['Title']*5, show_progress=False)
|
108 |
|
109 |
gr.Examples([
|
110 |
[ "NeRF", "Title", "AND", "GAN", "Abstract"],
|
111 |
[ "GAN", "All", "OR", "Diffusion", "All"],
|
112 |
+
], inputs=[ Keywords[0], Fields[0], Logics[0], Keywords[1], Fields[1]])
|
113 |
|
114 |
demo.launch(debug = True)
|
115 |
|