n0w0f commited on
Commit
ee6ab25
·
1 Parent(s): 7b5eba5

fix: remove duplication in table view

Browse files
Files changed (1) hide show
  1. app.py +23 -19
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
- author_counts = {}
372
- for card in eval_cards:
373
- authors = card["authors"].split(", ")
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
- top_authors = sorted(author_counts.items(), key=lambda x: x[1], reverse=True)[:20]
381
- top_authors = [author for author, count in top_authors]
382
-
383
- for card in eval_cards:
384
- authors = card["authors"].split(", ")
385
- filtered_authors = [author for author in authors if author in top_authors]
386
- table_data.append(
387
- {
388
- "Title": card["title"],
389
- "Authors": ", ".join(filtered_authors),
390
- "Creation Date": card["creation_date"],
391
- "Coverage Score": f"{card['coverage_score']}%",
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