Skip to content

Commit

Permalink
chore
Browse files Browse the repository at this point in the history
  • Loading branch information
jannisborn committed Nov 23, 2024
1 parent c01d712 commit cdbfcbe
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions paperscraper/citations/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,3 @@ def check_overlap(n1: str, n2: str) -> bool:
s1 = {w for w in n1.lower().replace(".", "").split() if len(w) > 1}
s2 = {w for w in n2.lower().replace(".", "").split() if len(w) > 1}
return len(s1 | s2) == len(s1)


async def get_paper_data(client: httpx.AsyncClient, paper_id: str, fields: str) -> dict:
"""
Fetch paper data from the Semantic Scholar API.
"""
response = await client.get(
f"https://api.semanticscholar.org/graph/v1/paper/{paper_id}",
params={"fields": fields},
)
response.raise_for_status()
return response.json()


async def get_citations(
client: httpx.AsyncClient, paper_id: str, offset: int = 0, limit: int = 1000
) -> List[dict]:
"""
Fetch all citing papers for a given paper ID.
"""
citations = []
while True:
response = await client.get(
f"https://api.semanticscholar.org/graph/v1/paper/{paper_id}/citations",
params={"fields": "authors", "limit": limit, "offset": offset},
)
response.raise_for_status()
page = response.json()["data"]
citations.extend([edge["citingPaper"] for edge in page])

if len(page) < limit:
break
offset += limit
return citations

0 comments on commit cdbfcbe

Please sign in to comment.