Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -402,44 +402,44 @@ def main():
|
|
402 |
|
403 |
# Display summaries with improved sorting and filtering
|
404 |
if st.session_state.summaries is not None:
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
if sort_column == 'Article Title':
|
412 |
-
ascending = st.radio(
|
413 |
-
"Sort order",
|
414 |
-
["A to Z", "Z to A"],
|
415 |
-
horizontal=True
|
416 |
-
) == "A to Z"
|
417 |
-
elif sort_column == 'Times Cited':
|
418 |
-
ascending = st.radio(
|
419 |
-
"Sort order",
|
420 |
-
["Most cited", "Least cited"],
|
421 |
-
horizontal=True
|
422 |
-
) == "Least cited"
|
423 |
-
else:
|
424 |
-
ascending = True # Default for other columns
|
425 |
-
|
426 |
-
# Create display dataframe
|
427 |
-
display_df = df.copy()
|
428 |
-
display_df['Summary'] = st.session_state.summaries
|
429 |
-
display_df['Publication Year'] = display_df['Publication Year'].astype(int)
|
430 |
-
display_df.rename(columns={'Times Cited, All Databases': 'Times Cited'}, inplace=True)
|
431 |
-
display_df['Times Cited'] = display_df['Times Cited'].fillna(0).astype(int)
|
432 |
-
|
433 |
-
# Apply filters
|
434 |
-
filtered_df = create_filter_controls(display_df, sort_column)
|
435 |
-
|
436 |
if sort_column == 'Article Title':
|
437 |
-
|
438 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
439 |
else:
|
440 |
-
|
441 |
-
|
442 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
443 |
|
444 |
# Show number of filtered results
|
445 |
if len(sorted_df) != len(display_df):
|
@@ -478,33 +478,33 @@ def main():
|
|
478 |
|
479 |
# Display papers using the filtered and sorted dataframe
|
480 |
for _, row in sorted_df.iterrows():
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
</div>
|
495 |
</div>
|
496 |
-
|
|
|
497 |
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
|
509 |
# Question-focused Summary Section (only if question provided)
|
510 |
if question.strip():
|
|
|
402 |
|
403 |
# Display summaries with improved sorting and filtering
|
404 |
if st.session_state.summaries is not None:
|
405 |
+
col1, col2 = st.columns(2)
|
406 |
+
with col1:
|
407 |
+
sort_options = ['Article Title', 'Authors', 'Publication Year', 'Source Title', 'Times Cited']
|
408 |
+
sort_column = st.selectbox("Sort/Filter by:", sort_options)
|
409 |
+
with col2:
|
410 |
+
# Only show A-Z/Z-A option for Article Title
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
if sort_column == 'Article Title':
|
412 |
+
ascending = st.radio(
|
413 |
+
"Sort order",
|
414 |
+
["A to Z", "Z to A"],
|
415 |
+
horizontal=True
|
416 |
+
) == "A to Z"
|
417 |
+
elif sort_column == 'Times Cited':
|
418 |
+
ascending = st.radio(
|
419 |
+
"Sort order",
|
420 |
+
["Most cited", "Least cited"],
|
421 |
+
horizontal=True
|
422 |
+
) == "Least cited"
|
423 |
else:
|
424 |
+
ascending = True # Default for other columns
|
425 |
+
|
426 |
+
# Create display dataframe
|
427 |
+
display_df = df.copy()
|
428 |
+
display_df['Summary'] = st.session_state.summaries
|
429 |
+
display_df['Publication Year'] = display_df['Publication Year'].astype(int)
|
430 |
+
display_df.rename(columns={'Times Cited, All Databases': 'Times Cited'}, inplace=True)
|
431 |
+
display_df['Times Cited'] = display_df['Times Cited'].fillna(0).astype(int)
|
432 |
+
|
433 |
+
# Apply filters
|
434 |
+
filtered_df = create_filter_controls(display_df, sort_column)
|
435 |
+
|
436 |
+
if sort_column == 'Article Title':
|
437 |
+
# Sort alphabetically
|
438 |
+
sorted_df = filtered_df.sort_values(by=sort_column, ascending=ascending)
|
439 |
+
else:
|
440 |
+
# Keep original order for other columns after filtering
|
441 |
+
# Keep original order for other columns after filtering
|
442 |
+
sorted_df = filtered_df
|
443 |
|
444 |
# Show number of filtered results
|
445 |
if len(sorted_df) != len(display_df):
|
|
|
478 |
|
479 |
# Display papers using the filtered and sorted dataframe
|
480 |
for _, row in sorted_df.iterrows():
|
481 |
+
paper_info_cols = st.columns([1, 1])
|
482 |
+
|
483 |
+
with paper_info_cols[0]: # PAPER column
|
484 |
+
st.markdown('<div class="paper-section"><div class="section-header">PAPER</div>', unsafe_allow_html=True)
|
485 |
+
st.markdown(f"""
|
486 |
+
<div class="paper-info">
|
487 |
+
<div class="paper-title">{row['Article Title']}</div>
|
488 |
+
<div class="paper-meta">
|
489 |
+
<strong>Authors:</strong> {row['Authors']}<br>
|
490 |
+
<strong>Source:</strong> {row['Source Title']}<br>
|
491 |
+
<strong>Publication Year:</strong> {row['Publication Year']}<br>
|
492 |
+
<strong>Times Cited:</strong> {row['Times Cited']}<br>
|
493 |
+
<strong>DOI:</strong> {row['DOI'] if pd.notna(row['DOI']) else 'None'}
|
|
|
494 |
</div>
|
495 |
+
</div>
|
496 |
+
""", unsafe_allow_html=True)
|
497 |
|
498 |
+
with paper_info_cols[1]: # SUMMARY column
|
499 |
+
st.markdown('<div class="paper-section"><div class="section-header">SUMMARY</div>', unsafe_allow_html=True)
|
500 |
+
st.markdown(f"""
|
501 |
+
<div class="paper-info">
|
502 |
+
{row['Summary']}
|
503 |
+
</div>
|
504 |
+
""", unsafe_allow_html=True)
|
505 |
+
|
506 |
+
# Add spacing between papers
|
507 |
+
st.markdown("<div style='margin-bottom: 20px;'></div>", unsafe_allow_html=True)
|
508 |
|
509 |
# Question-focused Summary Section (only if question provided)
|
510 |
if question.strip():
|