From d88c8380d1eb0aa44992e142776302c2194641f9 Mon Sep 17 00:00:00 2001 From: Michael Skarlinski Date: Wed, 23 Oct 2024 11:27:46 -0700 Subject: [PATCH] override an arxiv with real doi if it has one --- paperqa/clients/semantic_scholar.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/paperqa/clients/semantic_scholar.py b/paperqa/clients/semantic_scholar.py index 5be3a92f..ea6384a7 100644 --- a/paperqa/clients/semantic_scholar.py +++ b/paperqa/clients/semantic_scholar.py @@ -156,10 +156,11 @@ async def parse_s2_to_doc_details( if "data" in paper_data: paper_data = paper_data["data"][0] - if "ArXiv" in paper_data["externalIds"]: - doi = "10.48550/arXiv." + paper_data["externalIds"]["ArXiv"] - elif "DOI" in paper_data["externalIds"]: + # DOI check goes 1st to override an ArXiV DOI + if "DOI" in paper_data["externalIds"]: doi = paper_data["externalIds"]["DOI"] + elif "ArXiv" in paper_data["externalIds"]: + doi = "10.48550/arXiv." + paper_data["externalIds"]["ArXiv"] else: raise DOINotFoundError(f"Could not find DOI for {paper_data}.")