Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def getAuthorCitations(author):
# print(author)
# check if author has initials in name
author_name_without_initials = author.split(' ')[0] + ' ' + author.split(' ')[-1]
if author != author_name_without_initials:
flag_authorHasInitialsInName = True
else: flag_authorHasInitialsInName = False
search_query = scholarly.search_author(author)
try: # check if author is listed in google scholar
author_stats = next(search_query)
try: # if multiple people exist with same name, skip author
next(search_query); author_count = 2
except: author_count = 1
except:
author_count = 0
# if author is uniquely identified in scholar, get citation count
if author_count == 1:
try: author_citation_count = author_stats.citedby
except: author_citation_count = 0
elif (author_count == 0) and flag_authorHasInitialsInName:
author_citation_count = getAuthorCitations(author_name_without_initials)
else:
author_citation_count = 0
def getAuthorCitations(author):
# print(author)
# check if author has initials in name
author_name_without_initials = author.split(' ')[0] + ' ' + author.split(' ')[-1]
if author != author_name_without_initials:
flag_authorHasInitialsInName = True
else: flag_authorHasInitialsInName = False
search_query = scholarly.search_author(author)
try: # check if author is listed in google scholar
author_stats = next(search_query)
try: # if multiple people exist with same name, skip author
next(search_query); author_count = 2
except: author_count = 1
except:
author_count = 0
# if author is uniquely identified in scholar, get citation count
if author_count == 1:
try: author_citation_count = author_stats.citedby
except: author_citation_count = 0
elif (author_count == 0) and flag_authorHasInitialsInName:
author_citation_count = getAuthorCitations(author_name_without_initials)
else:
author_citation_count = 0
def query_scholar_for_author_profile(author):
try:
_author = next(scholarly.search_author(author))
except:
return "Ooopsie. Maybe we ran over the request limit?"
if _author == None:
return "Did not find a profile for %s" % author
resp_str = ""
resp_str += (_author.name + "\n")
resp_str += (_author.affiliation + "\n")
for interest in _author.interests:
resp_str += (interest + ' - ')
resp_str += "\n"
resp_str += ("https://scholar.google.ch/citations?user=" + _author.id)
return resp_str
def get_author(author_name):
# Retrieve the author's data, fill-in, and print
search_query = scholarly.search_author(author_name)
author = next(search_query).fill()
return author