Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement DOI citation tracking system using Crossref and Google Scholar APIs #142

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
160 changes: 160 additions & 0 deletions doi_citation_analysis.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# DOI Citation Analysis\n",
"\n",
"This notebook analyzes citations for specific DOIs using Crossref and Google Scholar."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Import required libraries"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-04T13:45:54.171007Z",
"iopub.status.busy": "2024-12-04T13:45:54.170541Z",
"iopub.status.idle": "2024-12-04T13:45:54.916229Z",
"shell.execute_reply": "2024-12-04T13:45:54.915650Z"
}
},
"outputs": [],
"source": [
"import pandas as pd\n",
"from scholarly import scholarly\n",
"from crossref.restful import Works"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Define function to check DOI citations"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-04T13:45:54.918389Z",
"iopub.status.busy": "2024-12-04T13:45:54.918129Z",
"iopub.status.idle": "2024-12-04T13:45:54.923307Z",
"shell.execute_reply": "2024-12-04T13:45:54.922821Z"
}
},
"outputs": [],
"source": [
"def check_doi_citations(doi_list):\n",
" works = Works()\n",
" results = []\n",
" \n",
" for doi in doi_list:\n",
" print(f\"Processing DOI: {doi}\")\n",
" # Get citation count from Crossref\n",
" try:\n",
" work = works.doi(doi)\n",
" crossref_citations = work['is-referenced-by-count']\n",
" except:\n",
" crossref_citations = None\n",
" \n",
" # Get citation count from Google Scholar\n",
" try:\n",
" query = scholarly.search_pubs(doi)\n",
" pub = next(query)\n",
" scholar_citations = pub.citedby\n",
" except:\n",
" scholar_citations = None\n",
" \n",
" results.append({\n",
" 'DOI': doi,\n",
" 'Crossref_Citations': crossref_citations,\n",
" 'Scholar_Citations': scholar_citations\n",
" })\n",
" \n",
" return pd.DataFrame(results)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Analyze citations for specific DOIs"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-04T13:45:54.925230Z",
"iopub.status.busy": "2024-12-04T13:45:54.924881Z",
"iopub.status.idle": "2024-12-04T13:46:02.647362Z",
"shell.execute_reply": "2024-12-04T13:46:02.646735Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Processing DOI: 10.5281/zenodo.5601995\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Processing DOI: 10.5281/zenodo.10432619\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Processing DOI: 10.5281/zenodo.7827755\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Processing DOI: 10.1038/s41592-019-0650-1\n"
]
}
],
"source": [
"dois = [\"10.5281/zenodo.5601995\", \"10.5281/zenodo.10432619\", \"10.5281/zenodo.7827755\", \"10.1038/s41592-019-0650-1\"]\n",
"citations_df = check_doi_citations(dois)\n",
"\n",
"# Save results to CSV\n",
"citations_df.to_csv('doi_citations.csv', index=False)"
]
}
],
"metadata": {
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
5 changes: 5 additions & 0 deletions doi_citations.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DOI,Crossref_Citations,Scholar_Citations
10.5281/zenodo.5601995,,
10.5281/zenodo.10432619,,
10.5281/zenodo.7827755,,
10.1038/s41592-019-0650-1,157.0,513