pgleeson commited on
Commit
9d306ea
·
1 Parent(s): d5b28d0

Improved formatting of publication results

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. publications.py +5 -2
app.py CHANGED
@@ -73,7 +73,7 @@ with tab_pubs:
73
 
74
  from publications import find_basis_paper
75
 
76
- st.markdown("**Find literature related to _C. elegans_**")
77
 
78
  with st.form("form_pubs"):
79
 
 
73
 
74
  from publications import find_basis_paper
75
 
76
+ st.markdown("**Find literature related to _C. elegans._** Uses: [Semantic Scholar](https://www.semanticscholar.org)")
77
 
78
  with st.form("form_pubs"):
79
 
publications.py CHANGED
@@ -23,7 +23,7 @@ def find_basis_paper(query, result_limit=10):
23
 
24
  rsp = requests.get('https://api.semanticscholar.org/graph/v1/paper/search',
25
  headers={'X-API-KEY': S2_API_KEY},
26
- params={'query': query, 'limit': result_limit, 'fields': 'title,url'})
27
  rsp.raise_for_status()
28
  results = rsp.json()
29
  total = results["total"]
@@ -41,6 +41,9 @@ def find_basis_paper(query, result_limit=10):
41
  def format_paper_list(papers):
42
  list = ''
43
  for idx, paper in enumerate(papers):
44
- list+=(f"{idx}: [{paper['title']}]({paper['url']}) \n\n")
 
 
 
45
 
46
  return list
 
23
 
24
  rsp = requests.get('https://api.semanticscholar.org/graph/v1/paper/search',
25
  headers={'X-API-KEY': S2_API_KEY},
26
+ params={'query': query, 'limit': result_limit, 'fields': 'title,url,authors,year,tldr,journal'})
27
  rsp.raise_for_status()
28
  results = rsp.json()
29
  total = results["total"]
 
41
  def format_paper_list(papers):
42
  list = ''
43
  for idx, paper in enumerate(papers):
44
+ print(paper)
45
+ list+=(f"{idx}: **{paper['authors'][0]['name']} et al. {paper['year']}**, [{paper['journal']['name']}]({paper['url']}) {paper['title'].strip()}\n\n")
46
+ if paper['tldr'] and paper['tldr']['text']:
47
+ list+=(f"> _{paper['tldr']['text'].strip()}_ \n\n")
48
 
49
  return list