Spaces:
Sleeping
Sleeping
fix: remove duplication in table view
Browse files
app.py
CHANGED
@@ -367,30 +367,34 @@ def refresh_gallery():
|
|
367 |
|
368 |
# Convert data to pandas DataFrame for table view
|
369 |
table_data = []
|
|
|
|
|
|
|
370 |
for card in eval_cards:
|
371 |
-
|
372 |
-
for
|
373 |
-
|
374 |
-
for author in authors:
|
375 |
if author in author_counts:
|
376 |
author_counts[author] += 1
|
377 |
else:
|
378 |
author_counts[author] = 1
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
|
|
|
|
394 |
|
395 |
df = pd.DataFrame(table_data)
|
396 |
|
|
|
367 |
|
368 |
# Convert data to pandas DataFrame for table view
|
369 |
table_data = []
|
370 |
+
|
371 |
+
# First, count authors across all cards
|
372 |
+
author_counts = {}
|
373 |
for card in eval_cards:
|
374 |
+
authors = card["authors"].split(", ")
|
375 |
+
for author in authors:
|
376 |
+
if author and author.strip(): # Skip empty authors
|
|
|
377 |
if author in author_counts:
|
378 |
author_counts[author] += 1
|
379 |
else:
|
380 |
author_counts[author] = 1
|
381 |
+
|
382 |
+
# Get top authors
|
383 |
+
top_authors = sorted(author_counts.items(), key=lambda x: x[1], reverse=True)[:20]
|
384 |
+
top_authors = [author for author, count in top_authors]
|
385 |
+
|
386 |
+
# Create table data with one entry per card
|
387 |
+
for card in eval_cards:
|
388 |
+
authors = card["authors"].split(", ")
|
389 |
+
filtered_authors = [author for author in authors if author in top_authors]
|
390 |
+
table_data.append(
|
391 |
+
{
|
392 |
+
"Title": card["title"],
|
393 |
+
"Authors": ", ".join(filtered_authors),
|
394 |
+
"Creation Date": card["creation_date"],
|
395 |
+
"Coverage Score": f"{card['coverage_score']}%",
|
396 |
+
}
|
397 |
+
)
|
398 |
|
399 |
df = pd.DataFrame(table_data)
|
400 |
|