Skip to content

Commit caa3347

Browse files
author
Sandra Mierz
authored
Include ror in orcid search (#17)
* include ror id in orcid search
1 parent c21e8ae commit caa3347

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

organization-people/orcid_get_people_by_organization.ipynb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
"\n",
106106
"#--- example execution\n",
107107
"ror_data=query_ror_api(example_ror)\n",
108+
"organization_ror_id=example_ror.replace(\"https://ror.org/\", \"\")\n",
108109
"# if you want to see the retrieved metadata, uncomment next lines\n",
109110
"#import pprint\n",
110111
"#pprint.pprint(ror_data)"
@@ -148,7 +149,7 @@
148149
"name": "stdout",
149150
"output_type": "stream",
150151
"text": [
151-
"grid ID: grid.461819.3\n",
152+
"Grid ID: grid.461819.3\n",
152153
"Wikidata ID: Q2399120\n"
153154
]
154155
}
@@ -169,7 +170,7 @@
169170
"\n",
170171
"#--- example execution\n",
171172
"organization_grid_id=extract_grid_from_ror_data(ror_data)\n",
172-
"print(\"grid ID: \" + str(organization_grid_id or ''))\n",
173+
"print(\"Grid ID: \" + str(organization_grid_id or ''))\n",
173174
"organization_wikidata_id=extract_wikidata_from_ror_data(ror_data)\n",
174175
"print(\"Wikidata ID: \" + str(organization_wikidata_id or ''))"
175176
]
@@ -261,7 +262,7 @@
261262
},
262263
"source": [
263264
"### Connection organization -> people\n",
264-
"The second part of the process is to query for the people affiliated with the organization. For this we use the ORCID API and search for people affiliated with an organization like it is explained in the ORCID tutorial [\"How do I find ORCID record holders at my institution?\"](https://info.orcid.org/faq/how-do-i-find-orcid-record-holders-at-my-institution/). As parameters for the query we use the Grid ID and Ringgold ID for the organization.\n"
265+
"The second part of the process is to query for the people affiliated with the organization. For this we use the ORCID API and search for people affiliated with an organization like it is explained in the ORCID tutorial [\"How do I find ORCID record holders at my institution?\"](https://info.orcid.org/faq/how-do-i-find-orcid-record-holders-at-my-institution/). As parameters for the query we use the ROR ID, Grid ID and Ringgold ID for the organization.\n"
265266
]
266267
},
267268
{
@@ -391,11 +392,13 @@
391392
"# URL for ORCID search API\n",
392393
"ORCID_SEARCH_API = \"https://pub.orcid.org/v3.0/expanded-search/\"\n",
393394
"\n",
394-
"# query ORCID with an organization's Grid ID and Ringgold\n",
395-
"def query_orcid_for_affiliations(grid_id, ringgold_id):\n",
396-
" query = f\"grid-org-id:{grid_id}\" if grid_id else \"\"\n",
397-
" query += \" OR \" if grid_id and ringgold_id else \"\"\n",
398-
" query += f\"ringgold-org-id:{ringgold_id}\" if ringgold_id else \"\"\n",
395+
"# query ORCID with an organization's ROR, Grid and Ringgold ID\n",
396+
"def query_orcid_for_affiliations(ror_id, grid_id, ringgold_id):\n",
397+
" grid_search = f\"grid-org-id:{grid_id}\" if grid_id else \"\"\n",
398+
" ringgold_search = f\"ringgold-org-id:{ringgold_id}\" if ringgold_id else \"\"\n",
399+
" ror_search = f\"ror-org-id:{ror_id}\" if ror_id else \"\"\n",
400+
" orga_search_ids = [ror_search, grid_search, ringgold_search]\n",
401+
" query = ' OR '.join(filter(None, orga_search_ids))\n",
399402
"\n",
400403
" response = requests.get(url=ORCID_SEARCH_API,\n",
401404
" params={'q': query},\n",
@@ -415,7 +418,7 @@
415418
"\n",
416419
"\n",
417420
"#-- example execution\n",
418-
"affiliated_people = query_orcid_for_affiliations(organization_grid_id, organization_ringgold_id)\n",
421+
"affiliated_people = query_orcid_for_affiliations(organization_ror_id, organization_grid_id, organization_ringgold_id)\n",
419422
"affiliated_count = affiliated_people.get('num-found','')\n",
420423
"print(f\"Number of affiliated people: {affiliated_count}\")\n",
421424
"\n",

0 commit comments

Comments
 (0)