|
105 | 105 | "\n",
|
106 | 106 | "#--- example execution\n",
|
107 | 107 | "ror_data=query_ror_api(example_ror)\n",
|
| 108 | + "organization_ror_id=example_ror.replace(\"https://ror.org/\", \"\")\n", |
108 | 109 | "# if you want to see the retrieved metadata, uncomment next lines\n",
|
109 | 110 | "#import pprint\n",
|
110 | 111 | "#pprint.pprint(ror_data)"
|
|
148 | 149 | "name": "stdout",
|
149 | 150 | "output_type": "stream",
|
150 | 151 | "text": [
|
151 |
| - "grid ID: grid.461819.3\n", |
| 152 | + "Grid ID: grid.461819.3\n", |
152 | 153 | "Wikidata ID: Q2399120\n"
|
153 | 154 | ]
|
154 | 155 | }
|
|
169 | 170 | "\n",
|
170 | 171 | "#--- example execution\n",
|
171 | 172 | "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", |
173 | 174 | "organization_wikidata_id=extract_wikidata_from_ror_data(ror_data)\n",
|
174 | 175 | "print(\"Wikidata ID: \" + str(organization_wikidata_id or ''))"
|
175 | 176 | ]
|
|
261 | 262 | },
|
262 | 263 | "source": [
|
263 | 264 | "### 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" |
265 | 266 | ]
|
266 | 267 | },
|
267 | 268 | {
|
|
391 | 392 | "# URL for ORCID search API\n",
|
392 | 393 | "ORCID_SEARCH_API = \"https://pub.orcid.org/v3.0/expanded-search/\"\n",
|
393 | 394 | "\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", |
399 | 402 | "\n",
|
400 | 403 | " response = requests.get(url=ORCID_SEARCH_API,\n",
|
401 | 404 | " params={'q': query},\n",
|
|
415 | 418 | "\n",
|
416 | 419 | "\n",
|
417 | 420 | "#-- 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", |
419 | 422 | "affiliated_count = affiliated_people.get('num-found','')\n",
|
420 | 423 | "print(f\"Number of affiliated people: {affiliated_count}\")\n",
|
421 | 424 | "\n",
|
|
0 commit comments