Merge pull request #748 from duhaode520/master

🐞 fix(谷歌学术搜索): 包装search.results()为空可能造成的报错
This commit is contained in:
binary-husky 2023-05-15 17:27:41 +08:00 committed by GitHub
commit 5f79fed566
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,14 +36,18 @@ def get_meta_information(url, chatbot, history):
max_results = 1, max_results = 1,
sort_by = arxiv.SortCriterion.Relevance, sort_by = arxiv.SortCriterion.Relevance,
) )
paper = next(search.results()) try:
if string_similar(title, paper.title) > 0.90: # same paper paper = next(search.results())
abstract = paper.summary.replace('\n', ' ') if string_similar(title, paper.title) > 0.90: # same paper
is_paper_in_arxiv = True abstract = paper.summary.replace('\n', ' ')
else: # different paper is_paper_in_arxiv = True
else: # different paper
abstract = abstract
is_paper_in_arxiv = False
paper = next(search.results())
except:
abstract = abstract abstract = abstract
is_paper_in_arxiv = False is_paper_in_arxiv = False
paper = next(search.results())
print(title) print(title)
print(author) print(author)
print(citation) print(citation)