Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# get the most likely match of the first results
results = list(search_query)
if len(results) > 1 and assess_results:
maxscore = 0
result = results[0]
for res in results:
score = _scholar_score(txt, res.bib)
if score > maxscore:
maxscore = score
result = res
else:
result = results[0]
# use url_scholarbib to get bibtex from google
if getattr(result, 'url_scholarbib', ''):
bibtex = scholarly._get_page(result.url_scholarbib).strip()
else:
raise NotImplementedError('no bibtex import linke. Make crossref request using title?')
return bibtex
def fetch_bibtex_by_fulltext_scholar(txt, assess_results=True):
import scholarly
scholarly._get_page = _get_page_fast # remove waiting time
logger.debug(txt)
search_query = scholarly.search_pubs_query(txt)
# get the most likely match of the first results
results = list(search_query)
if len(results) > 1 and assess_results:
maxscore = 0
result = results[0]
for res in results:
score = _scholar_score(txt, res.bib)
if score > maxscore:
maxscore = score
result = res
else:
result = results[0]