davanstrien HF Staff commited on
Commit
d106587
·
1 Parent(s): 5966956

Refactor get_papers function to handle already

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -96,15 +96,18 @@ def get_papers(
96
  ]
97
 
98
  already_claimed = groupby_hf_user_papers(indexed_papers, hf_user_name)
99
- results = (
100
- "# Papers already indexed by Hugging Face which you haven't claimed\n"
101
- + "These papers are already indexed by Hugging Face, but you haven't claimed them yet. You can claim them by clicking on the link and then clicking on the 'Claim' button on the Hugging Face papers page.\n"
102
- )
103
- for paper in already_claimed[False]:
104
- url = f"https://huggingface.co/papers/{paper['id']}"
105
- results += f"- [{paper['title']}]({url})\n"
 
 
 
106
  if papers_indexed_by_hf.get(False):
107
- results += "# Papers not yet indexed by Hugging Face\n"
108
  for paper in papers_indexed_by_hf[False]:
109
  paper_title = paper["title"]
110
  arxiv_id = paper["externalIds"]["ArXiv"]
 
96
  ]
97
 
98
  already_claimed = groupby_hf_user_papers(indexed_papers, hf_user_name)
99
+ if already_claimed.get(False):
100
+ results = (
101
+ "# Papers already indexed by Hugging Face which you haven't claimed\n"
102
+ + "These papers are already indexed by Hugging Face, but you haven't claimed them yet. You can claim them by clicking on the link and then clicking on the 'Claim' button on the Hugging Face papers page.\n"
103
+ )
104
+ for paper in already_claimed[False]:
105
+ url = f"https://huggingface.co/papers/{paper['id']}"
106
+ results += f"- [{paper['title']}]({url})\n"
107
+ else:
108
+ results = "You have claimed all papers indexed by Hugging Face!\n"
109
  if papers_indexed_by_hf.get(False):
110
+ results += "# Papers not yet indexed by Hugging Face which you can claim\n"
111
  for paper in papers_indexed_by_hf[False]:
112
  paper_title = paper["title"]
113
  arxiv_id = paper["externalIds"]["ArXiv"]