Skip to content

Commit

Permalink
🐞 fix(谷歌学术搜索): 包装search.results()为空可能造成的报错
Browse files Browse the repository at this point in the history
  • Loading branch information
duhaode520 committed May 15, 2023
1 parent c0e57e0 commit 3f31fb9
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions crazy_functions/谷歌检索小助手.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ def string_similar(s1, s2):
max_results = 1,
sort_by = arxiv.SortCriterion.Relevance,
)
paper = next(search.results())
if string_similar(title, paper.title) > 0.90: # same paper
abstract = paper.summary.replace('\n', ' ')
is_paper_in_arxiv = True
else: # different paper
try:
paper = next(search.results())
if string_similar(title, paper.title) > 0.90: # same paper
abstract = paper.summary.replace('\n', ' ')
is_paper_in_arxiv = True
else: # different paper
abstract = abstract
is_paper_in_arxiv = False
paper = next(search.results())
except:
abstract = abstract
is_paper_in_arxiv = False
paper = next(search.results())
print(title)
print(author)
print(citation)
Expand Down

0 comments on commit 3f31fb9

Please sign in to comment.