Spaces:
Running
Running
date ranges
Browse files- app.py +40 -32
- df/PaperCentral.py +39 -40
- requirements.txt +1 -1
app.py
CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
|
|
2 |
from df.PaperCentral import PaperCentral
|
3 |
from gradio_calendar import Calendar
|
4 |
from datetime import datetime, timedelta
|
5 |
-
from typing import Union, List
|
6 |
from author_leaderboard_tab import author_leaderboard_tab
|
7 |
from author_leaderboard_contrib_tab import author_resource_leaderboard_tab
|
8 |
from zoneinfo import ZoneInfo # Available in Python 3.9 and later
|
@@ -18,10 +18,11 @@ with gr.Blocks(css="style.css") as demo:
|
|
18 |
with gr.Tab("Paper-central", id="tab-paper-central"):
|
19 |
with gr.Accordion(label="⭐Release notes", open=False):
|
20 |
gr.Markdown("""
|
21 |
-
-
|
22 |
-
-
|
23 |
-
-
|
24 |
-
-
|
|
|
25 |
""")
|
26 |
|
27 |
# Create a row for navigation buttons and calendar
|
@@ -39,6 +40,12 @@ with gr.Blocks(css="style.css") as demo:
|
|
39 |
value=datetime.now(ZoneInfo('America/Los_Angeles')).strftime('%Y-%m-%d')
|
40 |
# Default to today's date in PST
|
41 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
# Create a row for Hugging Face options and Conference options
|
44 |
with gr.Row():
|
@@ -119,7 +126,6 @@ with gr.Blocks(css="style.css") as demo:
|
|
119 |
author_resource_leaderboard_tab()
|
120 |
|
121 |
|
122 |
-
|
123 |
# Define function to move to the next day
|
124 |
def go_to_next_day(
|
125 |
date: Union[str, datetime],
|
@@ -128,19 +134,16 @@ with gr.Blocks(css="style.css") as demo:
|
|
128 |
conference_options_list: List[str],
|
129 |
author_search_input: str,
|
130 |
title_search_input: str,
|
|
|
131 |
) -> tuple:
|
132 |
"""
|
133 |
Moves the selected date to the next day and updates the data.
|
134 |
|
135 |
-
Args:
|
136 |
-
date (Union[str, datetime]): The current date selected in the calendar.
|
137 |
-
cat_options_list (List[str]): List of selected Category options.
|
138 |
-
hf_options_list (List[str]): List of selected Hugging Face options.
|
139 |
-
conference_options_list (List[str]): List of selected Conference options.
|
140 |
-
|
141 |
Returns:
|
142 |
tuple: The new date as a string and the updated Dataframe component.
|
143 |
"""
|
|
|
|
|
144 |
# Ensure the date is in string format
|
145 |
if isinstance(date, datetime):
|
146 |
date_str = date.strftime('%Y-%m-%d')
|
@@ -159,10 +162,11 @@ with gr.Blocks(css="style.css") as demo:
|
|
159 |
conference_options=conference_options_list,
|
160 |
author_search_input=author_search_input,
|
161 |
title_search_input=title_search_input,
|
|
|
162 |
)
|
163 |
|
164 |
# Return the new date and updated Dataframe
|
165 |
-
return new_date_str, updated_data
|
166 |
|
167 |
|
168 |
# Define function to move to the previous day
|
@@ -173,19 +177,17 @@ with gr.Blocks(css="style.css") as demo:
|
|
173 |
conference_options_list: List[str],
|
174 |
author_search_input: str,
|
175 |
title_search_input: str,
|
|
|
176 |
) -> tuple:
|
177 |
"""
|
178 |
Moves the selected date to the previous day and updates the data.
|
179 |
|
180 |
-
Args:
|
181 |
-
date (Union[str, datetime]): The current date selected in the calendar.
|
182 |
-
cat_options_list (List[str]): List of selected Category options.
|
183 |
-
hf_options_list (List[str]): List of selected Hugging Face options.
|
184 |
-
conference_options_list (List[str]): List of selected Conference options.
|
185 |
-
|
186 |
Returns:
|
187 |
tuple: The new date as a string and the updated Dataframe component.
|
188 |
"""
|
|
|
|
|
|
|
189 |
# Ensure the date is in string format
|
190 |
if isinstance(date, datetime):
|
191 |
date_str = date.strftime('%Y-%m-%d')
|
@@ -204,10 +206,11 @@ with gr.Blocks(css="style.css") as demo:
|
|
204 |
conference_options=conference_options_list,
|
205 |
author_search_input=author_search_input,
|
206 |
title_search_input=title_search_input,
|
|
|
207 |
)
|
208 |
|
209 |
# Return the new date and updated Dataframe
|
210 |
-
return new_date_str, updated_data
|
211 |
|
212 |
|
213 |
# Define function to update data when date or options change
|
@@ -218,18 +221,10 @@ with gr.Blocks(css="style.css") as demo:
|
|
218 |
conference_options_list: List[str],
|
219 |
author_search_input: str,
|
220 |
title_search_input: str,
|
|
|
221 |
):
|
222 |
"""
|
223 |
Updates the data displayed in the Dataframe based on the selected date and options.
|
224 |
-
|
225 |
-
Args:
|
226 |
-
date (Union[str, datetime]): The selected date.
|
227 |
-
cat_options_list (List[str]): List of selected Category options.
|
228 |
-
hf_options_list (List[str]): List of selected Hugging Face options.
|
229 |
-
conference_options_list (List[str]): List of selected Conference options.
|
230 |
-
|
231 |
-
Returns:
|
232 |
-
gr.Dataframe.update: An update object for the Dataframe component.
|
233 |
"""
|
234 |
return paper_central_df.filter(
|
235 |
selected_date=date,
|
@@ -238,6 +233,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
238 |
conference_options=conference_options_list,
|
239 |
author_search_input=author_search_input,
|
240 |
title_search_input=title_search_input,
|
|
|
241 |
)
|
242 |
|
243 |
|
@@ -249,8 +245,8 @@ with gr.Blocks(css="style.css") as demo:
|
|
249 |
conference_options_list: List[str],
|
250 |
author_search_input: str,
|
251 |
title_search_input: str,
|
|
|
252 |
):
|
253 |
-
|
254 |
cat_options_update = gr.update()
|
255 |
paper_central_component_update = gr.update()
|
256 |
visible = True
|
@@ -266,6 +262,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
266 |
conference_options_list,
|
267 |
author_search_input,
|
268 |
title_search_input,
|
|
|
269 |
)
|
270 |
visible = False
|
271 |
|
@@ -284,6 +281,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
284 |
conference_options_list: List[str],
|
285 |
author_search_input: str,
|
286 |
title_search_input: str,
|
|
|
287 |
):
|
288 |
conference_options_update = gr.update()
|
289 |
paper_central_component_update = gr.update()
|
@@ -300,6 +298,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
300 |
[],
|
301 |
author_search_input,
|
302 |
title_search_input,
|
|
|
303 |
)
|
304 |
visible = True
|
305 |
|
@@ -310,6 +309,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
310 |
return paper_central_component_update, conference_options_update, calendar_update, next_day_btn_update, prev_day_btn_update
|
311 |
|
312 |
|
|
|
313 |
inputs = [
|
314 |
calendar,
|
315 |
cat_options,
|
@@ -317,6 +317,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
317 |
conference_options,
|
318 |
author_search,
|
319 |
title_search,
|
|
|
320 |
]
|
321 |
|
322 |
# Set up the event listener for the author search
|
@@ -336,14 +337,14 @@ with gr.Blocks(css="style.css") as demo:
|
|
336 |
next_day_btn.click(
|
337 |
fn=go_to_next_day,
|
338 |
inputs=inputs,
|
339 |
-
outputs=[calendar, paper_central_component],
|
340 |
)
|
341 |
|
342 |
# Set up the event listener for the 'Previous Day' button
|
343 |
prev_day_btn.click(
|
344 |
fn=go_to_previous_day,
|
345 |
inputs=inputs,
|
346 |
-
outputs=[calendar, paper_central_component],
|
347 |
)
|
348 |
|
349 |
# Set up the event listener for the calendar date change
|
@@ -374,6 +375,13 @@ with gr.Blocks(css="style.css") as demo:
|
|
374 |
outputs=[paper_central_component, conference_options, calendar, next_day_btn, prev_day_btn],
|
375 |
)
|
376 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
377 |
# Load the initial data when the app starts
|
378 |
request = gr.Request()
|
379 |
|
|
|
2 |
from df.PaperCentral import PaperCentral
|
3 |
from gradio_calendar import Calendar
|
4 |
from datetime import datetime, timedelta
|
5 |
+
from typing import Union, List, Optional
|
6 |
from author_leaderboard_tab import author_leaderboard_tab
|
7 |
from author_leaderboard_contrib_tab import author_resource_leaderboard_tab
|
8 |
from zoneinfo import ZoneInfo # Available in Python 3.9 and later
|
|
|
18 |
with gr.Tab("Paper-central", id="tab-paper-central"):
|
19 |
with gr.Accordion(label="⭐Release notes", open=False):
|
20 |
gr.Markdown("""
|
21 |
+
- **October 16, 2024** – Added functionality to filter papers by date ranges.
|
22 |
+
- **October 11, 2024** – Introduced leaderboards feature.
|
23 |
+
- **October 8, 2024** – MICCAI 2024 proceedings added.
|
24 |
+
- **October 7, 2024** – COLM 2024 proceedings added.
|
25 |
+
- **October 4, 2024** – Added functionality to filter papers by title.
|
26 |
""")
|
27 |
|
28 |
# Create a row for navigation buttons and calendar
|
|
|
40 |
value=datetime.now(ZoneInfo('America/Los_Angeles')).strftime('%Y-%m-%d')
|
41 |
# Default to today's date in PST
|
42 |
)
|
43 |
+
# Add Radio buttons for date ranges
|
44 |
+
date_range_radio = gr.Radio(
|
45 |
+
label="Date Range",
|
46 |
+
choices=["This week", "This month", "This year", "All time"],
|
47 |
+
value=None,
|
48 |
+
)
|
49 |
|
50 |
# Create a row for Hugging Face options and Conference options
|
51 |
with gr.Row():
|
|
|
126 |
author_resource_leaderboard_tab()
|
127 |
|
128 |
|
|
|
129 |
# Define function to move to the next day
|
130 |
def go_to_next_day(
|
131 |
date: Union[str, datetime],
|
|
|
134 |
conference_options_list: List[str],
|
135 |
author_search_input: str,
|
136 |
title_search_input: str,
|
137 |
+
date_range_option: Optional[str],
|
138 |
) -> tuple:
|
139 |
"""
|
140 |
Moves the selected date to the next day and updates the data.
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
Returns:
|
143 |
tuple: The new date as a string and the updated Dataframe component.
|
144 |
"""
|
145 |
+
date_range_update = gr.update(value=None)
|
146 |
+
|
147 |
# Ensure the date is in string format
|
148 |
if isinstance(date, datetime):
|
149 |
date_str = date.strftime('%Y-%m-%d')
|
|
|
162 |
conference_options=conference_options_list,
|
163 |
author_search_input=author_search_input,
|
164 |
title_search_input=title_search_input,
|
165 |
+
date_range_option=date_range_option,
|
166 |
)
|
167 |
|
168 |
# Return the new date and updated Dataframe
|
169 |
+
return new_date_str, updated_data, date_range_update
|
170 |
|
171 |
|
172 |
# Define function to move to the previous day
|
|
|
177 |
conference_options_list: List[str],
|
178 |
author_search_input: str,
|
179 |
title_search_input: str,
|
180 |
+
date_range_option: Optional[str],
|
181 |
) -> tuple:
|
182 |
"""
|
183 |
Moves the selected date to the previous day and updates the data.
|
184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
Returns:
|
186 |
tuple: The new date as a string and the updated Dataframe component.
|
187 |
"""
|
188 |
+
# If date_range_option is selected, do nothing
|
189 |
+
date_range_update = gr.update(value=None)
|
190 |
+
|
191 |
# Ensure the date is in string format
|
192 |
if isinstance(date, datetime):
|
193 |
date_str = date.strftime('%Y-%m-%d')
|
|
|
206 |
conference_options=conference_options_list,
|
207 |
author_search_input=author_search_input,
|
208 |
title_search_input=title_search_input,
|
209 |
+
date_range_option=date_range_option,
|
210 |
)
|
211 |
|
212 |
# Return the new date and updated Dataframe
|
213 |
+
return new_date_str, updated_data, date_range_update
|
214 |
|
215 |
|
216 |
# Define function to update data when date or options change
|
|
|
221 |
conference_options_list: List[str],
|
222 |
author_search_input: str,
|
223 |
title_search_input: str,
|
224 |
+
date_range_option: Optional[str],
|
225 |
):
|
226 |
"""
|
227 |
Updates the data displayed in the Dataframe based on the selected date and options.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
"""
|
229 |
return paper_central_df.filter(
|
230 |
selected_date=date,
|
|
|
233 |
conference_options=conference_options_list,
|
234 |
author_search_input=author_search_input,
|
235 |
title_search_input=title_search_input,
|
236 |
+
date_range_option=date_range_option,
|
237 |
)
|
238 |
|
239 |
|
|
|
245 |
conference_options_list: List[str],
|
246 |
author_search_input: str,
|
247 |
title_search_input: str,
|
248 |
+
date_range_option: Optional[str],
|
249 |
):
|
|
|
250 |
cat_options_update = gr.update()
|
251 |
paper_central_component_update = gr.update()
|
252 |
visible = True
|
|
|
262 |
conference_options_list,
|
263 |
author_search_input,
|
264 |
title_search_input,
|
265 |
+
date_range_option,
|
266 |
)
|
267 |
visible = False
|
268 |
|
|
|
281 |
conference_options_list: List[str],
|
282 |
author_search_input: str,
|
283 |
title_search_input: str,
|
284 |
+
date_range_option: Optional[str],
|
285 |
):
|
286 |
conference_options_update = gr.update()
|
287 |
paper_central_component_update = gr.update()
|
|
|
298 |
[],
|
299 |
author_search_input,
|
300 |
title_search_input,
|
301 |
+
date_range_option,
|
302 |
)
|
303 |
visible = True
|
304 |
|
|
|
309 |
return paper_central_component_update, conference_options_update, calendar_update, next_day_btn_update, prev_day_btn_update
|
310 |
|
311 |
|
312 |
+
# Include date_range_radio in the inputs
|
313 |
inputs = [
|
314 |
calendar,
|
315 |
cat_options,
|
|
|
317 |
conference_options,
|
318 |
author_search,
|
319 |
title_search,
|
320 |
+
date_range_radio,
|
321 |
]
|
322 |
|
323 |
# Set up the event listener for the author search
|
|
|
337 |
next_day_btn.click(
|
338 |
fn=go_to_next_day,
|
339 |
inputs=inputs,
|
340 |
+
outputs=[calendar, paper_central_component, date_range_radio],
|
341 |
)
|
342 |
|
343 |
# Set up the event listener for the 'Previous Day' button
|
344 |
prev_day_btn.click(
|
345 |
fn=go_to_previous_day,
|
346 |
inputs=inputs,
|
347 |
+
outputs=[calendar, paper_central_component, date_range_radio],
|
348 |
)
|
349 |
|
350 |
# Set up the event listener for the calendar date change
|
|
|
375 |
outputs=[paper_central_component, conference_options, calendar, next_day_btn, prev_day_btn],
|
376 |
)
|
377 |
|
378 |
+
# Set up the event listener for the date range radio button change
|
379 |
+
date_range_radio.change(
|
380 |
+
fn=update_data,
|
381 |
+
inputs=inputs,
|
382 |
+
outputs=paper_central_component,
|
383 |
+
)
|
384 |
+
|
385 |
# Load the initial data when the app starts
|
386 |
request = gr.Request()
|
387 |
|
df/PaperCentral.py
CHANGED
@@ -13,6 +13,7 @@ from constants import (
|
|
13 |
import gradio as gr
|
14 |
from utils import load_and_process
|
15 |
import numpy as np
|
|
|
16 |
|
17 |
|
18 |
class PaperCentral:
|
@@ -278,23 +279,17 @@ class PaperCentral:
|
|
278 |
conference_options: Optional[List[str]] = None,
|
279 |
author_search_input: Optional[str] = None,
|
280 |
title_search_input: Optional[str] = None,
|
|
|
281 |
) -> gr.update:
|
282 |
"""
|
283 |
Filter the DataFrame based on selected date and options, and prepare it for display.
|
284 |
-
|
285 |
-
Args:
|
286 |
-
selected_date (Optional[str]): The date to filter the DataFrame.
|
287 |
-
hf_options (Optional[List[str]]): List of options selected by the user.
|
288 |
-
conference_options (Optional[List[str]]): List of conference options selected by the user.
|
289 |
-
|
290 |
-
Returns:
|
291 |
-
gr.Update: An update object for the Gradio Dataframe component.
|
292 |
"""
|
293 |
filtered_df: pd.DataFrame = self.df_raw.copy()
|
294 |
|
295 |
# Start with the initial columns to display
|
296 |
columns_to_show: List[str] = PaperCentral.COLUMNS_START_PAPER_PAGE.copy()
|
297 |
|
|
|
298 |
if title_search_input:
|
299 |
if 'title' not in columns_to_show:
|
300 |
columns_to_show.append('authors')
|
@@ -303,14 +298,13 @@ class PaperCentral:
|
|
303 |
|
304 |
def title_match(title):
|
305 |
if isinstance(title, str):
|
306 |
-
# If authors_list is a single string
|
307 |
return search_string in title.lower()
|
308 |
else:
|
309 |
-
# Handle unexpected data types
|
310 |
return False
|
311 |
|
312 |
filtered_df = filtered_df[filtered_df['title'].apply(title_match)]
|
313 |
|
|
|
314 |
if author_search_input:
|
315 |
if 'authors' not in columns_to_show:
|
316 |
columns_to_show.append('authors')
|
@@ -318,55 +312,71 @@ class PaperCentral:
|
|
318 |
search_string = author_search_input.lower()
|
319 |
|
320 |
def author_matches(authors_list):
|
321 |
-
# Check if authors_list is None or empty
|
322 |
if authors_list is None or len(authors_list) == 0:
|
323 |
return False
|
324 |
-
|
325 |
-
# Check if authors_list is an iterable (list, tuple, Series, or ndarray)
|
326 |
if isinstance(authors_list, (list, tuple, pd.Series, np.ndarray)):
|
327 |
return any(
|
328 |
isinstance(author, str) and search_string in author.lower()
|
329 |
for author in authors_list
|
330 |
)
|
331 |
elif isinstance(authors_list, str):
|
332 |
-
# If authors_list is a single string
|
333 |
return search_string in authors_list.lower()
|
334 |
else:
|
335 |
-
# Handle unexpected data types
|
336 |
return False
|
337 |
|
338 |
filtered_df = filtered_df[filtered_df['authors'].apply(author_matches)]
|
339 |
|
|
|
340 |
if cat_options:
|
341 |
options = [o.replace(".*", "") for o in cat_options]
|
342 |
-
# Initialize filter series
|
343 |
conference_filter = pd.Series(False, index=filtered_df.index)
|
344 |
for option in options:
|
345 |
-
# Filter rows where 'conference_name' contains the conference string (case-insensitive)
|
346 |
conference_filter |= (
|
347 |
filtered_df['primary_category'].notna() &
|
348 |
filtered_df['primary_category'].str.contains(option, case=False)
|
349 |
)
|
350 |
filtered_df = filtered_df[conference_filter]
|
351 |
|
352 |
-
#
|
353 |
-
if
|
354 |
-
|
355 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
356 |
|
357 |
-
#
|
358 |
if hf_options:
|
359 |
if "🤗 artifacts" in hf_options:
|
360 |
-
# Filter rows where 'paper_page' is not empty or NaN
|
361 |
filtered_df = filtered_df[
|
362 |
(filtered_df['paper_page'] != "") & (filtered_df['paper_page'].notna())
|
363 |
]
|
364 |
-
|
365 |
-
# Add 'upvotes' column if not already in columns_to_show
|
366 |
if 'upvotes' not in columns_to_show:
|
367 |
columns_to_show.append('upvotes')
|
368 |
-
|
369 |
-
|
370 |
if 'num_models' not in columns_to_show:
|
371 |
columns_to_show.append('num_models')
|
372 |
if 'num_datasets' not in columns_to_show:
|
@@ -383,6 +393,7 @@ class PaperCentral:
|
|
383 |
if 'num_models' not in columns_to_show:
|
384 |
columns_to_show.append('num_models')
|
385 |
filtered_df = filtered_df[filtered_df['num_models'] != 0]
|
|
|
386 |
if "spaces" in hf_options:
|
387 |
if 'num_spaces' not in columns_to_show:
|
388 |
columns_to_show.append('num_spaces')
|
@@ -395,36 +406,26 @@ class PaperCentral:
|
|
395 |
|
396 |
# Apply conference filtering
|
397 |
if conference_options:
|
398 |
-
|
399 |
-
columns_to_show.remove("date")
|
400 |
-
columns_to_show.remove("arxiv_id")
|
401 |
|
402 |
if 'conference_name' not in columns_to_show:
|
403 |
columns_to_show.append('conference_name')
|
404 |
-
|
405 |
if 'proceedings' not in columns_to_show:
|
406 |
columns_to_show.append('proceedings')
|
407 |
-
|
408 |
if 'type' not in columns_to_show:
|
409 |
columns_to_show.append('type')
|
410 |
-
|
411 |
if 'id' not in columns_to_show:
|
412 |
columns_to_show.append('id')
|
413 |
|
414 |
-
# If "In proceedings" is selected
|
415 |
if "In proceedings" in conference_options:
|
416 |
-
# Filter rows where 'conference_name' is not None, not NaN, and not empty
|
417 |
filtered_df = filtered_df[
|
418 |
filtered_df['conference_name'].notna() & (filtered_df['conference_name'] != "")
|
419 |
]
|
420 |
|
421 |
-
# For other conference options
|
422 |
other_conferences = [conf for conf in conference_options if conf != "In proceedings"]
|
423 |
if other_conferences:
|
424 |
-
# Initialize filter series
|
425 |
conference_filter = pd.Series(False, index=filtered_df.index)
|
426 |
for conference in other_conferences:
|
427 |
-
# Filter rows where 'conference_name' contains the conference string (case-insensitive)
|
428 |
conference_filter |= (
|
429 |
filtered_df['conference_name'].notna() &
|
430 |
(filtered_df['conference_name'].str.lower() == conference.lower())
|
@@ -436,8 +437,6 @@ class PaperCentral:
|
|
436 |
|
437 |
# Ensure columns are ordered according to COLUMNS_ORDER_PAPER_PAGE
|
438 |
columns_in_order: List[str] = [col for col in PaperCentral.COLUMNS_ORDER_PAPER_PAGE if col in columns_to_show]
|
439 |
-
|
440 |
-
# Select and reorder the columns
|
441 |
filtered_df = filtered_df[columns_in_order]
|
442 |
|
443 |
# Rename columns for display
|
|
|
13 |
import gradio as gr
|
14 |
from utils import load_and_process
|
15 |
import numpy as np
|
16 |
+
from datetime import datetime, timedelta
|
17 |
|
18 |
|
19 |
class PaperCentral:
|
|
|
279 |
conference_options: Optional[List[str]] = None,
|
280 |
author_search_input: Optional[str] = None,
|
281 |
title_search_input: Optional[str] = None,
|
282 |
+
date_range_option: Optional[str] = None,
|
283 |
) -> gr.update:
|
284 |
"""
|
285 |
Filter the DataFrame based on selected date and options, and prepare it for display.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
"""
|
287 |
filtered_df: pd.DataFrame = self.df_raw.copy()
|
288 |
|
289 |
# Start with the initial columns to display
|
290 |
columns_to_show: List[str] = PaperCentral.COLUMNS_START_PAPER_PAGE.copy()
|
291 |
|
292 |
+
# Handle title search
|
293 |
if title_search_input:
|
294 |
if 'title' not in columns_to_show:
|
295 |
columns_to_show.append('authors')
|
|
|
298 |
|
299 |
def title_match(title):
|
300 |
if isinstance(title, str):
|
|
|
301 |
return search_string in title.lower()
|
302 |
else:
|
|
|
303 |
return False
|
304 |
|
305 |
filtered_df = filtered_df[filtered_df['title'].apply(title_match)]
|
306 |
|
307 |
+
# Handle author search
|
308 |
if author_search_input:
|
309 |
if 'authors' not in columns_to_show:
|
310 |
columns_to_show.append('authors')
|
|
|
312 |
search_string = author_search_input.lower()
|
313 |
|
314 |
def author_matches(authors_list):
|
|
|
315 |
if authors_list is None or len(authors_list) == 0:
|
316 |
return False
|
|
|
|
|
317 |
if isinstance(authors_list, (list, tuple, pd.Series, np.ndarray)):
|
318 |
return any(
|
319 |
isinstance(author, str) and search_string in author.lower()
|
320 |
for author in authors_list
|
321 |
)
|
322 |
elif isinstance(authors_list, str):
|
|
|
323 |
return search_string in authors_list.lower()
|
324 |
else:
|
|
|
325 |
return False
|
326 |
|
327 |
filtered_df = filtered_df[filtered_df['authors'].apply(author_matches)]
|
328 |
|
329 |
+
# Handle category options
|
330 |
if cat_options:
|
331 |
options = [o.replace(".*", "") for o in cat_options]
|
|
|
332 |
conference_filter = pd.Series(False, index=filtered_df.index)
|
333 |
for option in options:
|
|
|
334 |
conference_filter |= (
|
335 |
filtered_df['primary_category'].notna() &
|
336 |
filtered_df['primary_category'].str.contains(option, case=False)
|
337 |
)
|
338 |
filtered_df = filtered_df[conference_filter]
|
339 |
|
340 |
+
# Handle date filtering
|
341 |
+
if not conference_options:
|
342 |
+
if date_range_option:
|
343 |
+
today = datetime.now()
|
344 |
+
if date_range_option == "This week":
|
345 |
+
start_date = (today - timedelta(days=7)).strftime('%Y-%m-%d')
|
346 |
+
end_date = today.strftime('%Y-%m-%d')
|
347 |
+
elif date_range_option == "This month":
|
348 |
+
start_date = (today - timedelta(days=30)).strftime('%Y-%m-%d')
|
349 |
+
end_date = today.strftime('%Y-%m-%d')
|
350 |
+
elif date_range_option == "This year":
|
351 |
+
start_date = (today - timedelta(days=365)).strftime('%Y-%m-%d')
|
352 |
+
end_date = today.strftime('%Y-%m-%d')
|
353 |
+
elif date_range_option == "All time":
|
354 |
+
start_date = None
|
355 |
+
end_date = None
|
356 |
+
else:
|
357 |
+
start_date = None
|
358 |
+
end_date = None
|
359 |
+
|
360 |
+
if start_date and end_date:
|
361 |
+
filtered_df = filtered_df[
|
362 |
+
(filtered_df['date'] >= start_date) & (filtered_df['date'] <= end_date)
|
363 |
+
]
|
364 |
+
else:
|
365 |
+
pass # No date filtering for "All time"
|
366 |
+
elif selected_date:
|
367 |
+
selected_date = pd.to_datetime(selected_date).strftime('%Y-%m-%d')
|
368 |
+
filtered_df = filtered_df[filtered_df['date'] == selected_date]
|
369 |
|
370 |
+
# Handle Hugging Face options
|
371 |
if hf_options:
|
372 |
if "🤗 artifacts" in hf_options:
|
|
|
373 |
filtered_df = filtered_df[
|
374 |
(filtered_df['paper_page'] != "") & (filtered_df['paper_page'].notna())
|
375 |
]
|
|
|
|
|
376 |
if 'upvotes' not in columns_to_show:
|
377 |
columns_to_show.append('upvotes')
|
378 |
+
if 'num_comments' not in columns_to_show:
|
379 |
+
columns_to_show.append('num_comments')
|
380 |
if 'num_models' not in columns_to_show:
|
381 |
columns_to_show.append('num_models')
|
382 |
if 'num_datasets' not in columns_to_show:
|
|
|
393 |
if 'num_models' not in columns_to_show:
|
394 |
columns_to_show.append('num_models')
|
395 |
filtered_df = filtered_df[filtered_df['num_models'] != 0]
|
396 |
+
|
397 |
if "spaces" in hf_options:
|
398 |
if 'num_spaces' not in columns_to_show:
|
399 |
columns_to_show.append('num_spaces')
|
|
|
406 |
|
407 |
# Apply conference filtering
|
408 |
if conference_options:
|
409 |
+
columns_to_show = [col for col in columns_to_show if col not in ["date", "arxiv_id"]]
|
|
|
|
|
410 |
|
411 |
if 'conference_name' not in columns_to_show:
|
412 |
columns_to_show.append('conference_name')
|
|
|
413 |
if 'proceedings' not in columns_to_show:
|
414 |
columns_to_show.append('proceedings')
|
|
|
415 |
if 'type' not in columns_to_show:
|
416 |
columns_to_show.append('type')
|
|
|
417 |
if 'id' not in columns_to_show:
|
418 |
columns_to_show.append('id')
|
419 |
|
|
|
420 |
if "In proceedings" in conference_options:
|
|
|
421 |
filtered_df = filtered_df[
|
422 |
filtered_df['conference_name'].notna() & (filtered_df['conference_name'] != "")
|
423 |
]
|
424 |
|
|
|
425 |
other_conferences = [conf for conf in conference_options if conf != "In proceedings"]
|
426 |
if other_conferences:
|
|
|
427 |
conference_filter = pd.Series(False, index=filtered_df.index)
|
428 |
for conference in other_conferences:
|
|
|
429 |
conference_filter |= (
|
430 |
filtered_df['conference_name'].notna() &
|
431 |
(filtered_df['conference_name'].str.lower() == conference.lower())
|
|
|
437 |
|
438 |
# Ensure columns are ordered according to COLUMNS_ORDER_PAPER_PAGE
|
439 |
columns_in_order: List[str] = [col for col in PaperCentral.COLUMNS_ORDER_PAPER_PAGE if col in columns_to_show]
|
|
|
|
|
440 |
filtered_df = filtered_df[columns_in_order]
|
441 |
|
442 |
# Rename columns for display
|
requirements.txt
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
gradio
|
2 |
gradio_calendar
|
3 |
datasets
|
|
|
1 |
+
gradio==4.44.0
|
2 |
gradio_calendar
|
3 |
datasets
|