{ "cells": [ { "cell_type": "markdown", "id": "e5ac9be3-8f90-4d66-a7ee-38f61965aa4e", "metadata": {}, "source": [ "# Agents\n", "\n", "Agents are used in the standard name table to attribute authors and related organizations to the table." ] }, { "cell_type": "code", "execution_count": 1, "id": "80c0cda9-fb9b-4126-a9fd-2e24f3908ed1", "metadata": {}, "outputs": [], "source": [ "import ssnolib" ] }, { "cell_type": "code", "execution_count": 2, "id": "d897ca70-5b33-4947-a33e-46a287702250", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Person(id=https://orcid.org/0000-0001-8729-0482, lastName=Probst, orcidId=https://orcid.org/0000-0001-8729-0482, firstname=Matthias)" ], "text/plain": [ "Person(id=https://orcid.org/0000-0001-8729-0482, lastName=Probst, orcidId=https://orcid.org/0000-0001-8729-0482, firstname=Matthias)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "person = ssnolib.Person(firstname=\"Matthias\", lastName=\"Probst\", orcidId=\"https://orcid.org/0000-0001-8729-0482\")\n", "person" ] }, { "cell_type": "code", "execution_count": 3, "id": "0eab926d-bc3a-46b8-be0d-ad6860c03268", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Organization(id=https://ror.org/04t3en479, name=Awesome university@en, hasRorId=https://ror.org/04t3en479)" ], "text/plain": [ "Organization(id=https://ror.org/04t3en479, name=Awesome university@en, hasRorId=https://ror.org/04t3en479)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "orga = ssnolib.Organization(name=\"Awesome university@en\", hasRorId=\"https://ror.org/04t3en479\")\n", "orga" ] }, { "cell_type": "markdown", "id": "36395919-a7b3-4bf5-909f-28c9d793fb40", "metadata": {}, "source": [ "Because the `ssnolib.Person` was set up in a way, that the orcidId - if given - is used as the ID when exported to JSON-LD:" ] }, { "cell_type": "code", "execution_count": 4, "id": "e88346c1-4509-49da-ba0f-607ecf9ae30a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\n", " \"@context\": {\n", " \"owl\": \"http://www.w3.org/2002/07/owl#\",\n", " \"rdfs\": \"http://www.w3.org/2000/01/rdf-schema#\",\n", " \"dcterms\": \"http://purl.org/dc/terms/\",\n", " \"schema\": \"https://schema.org/\",\n", " \"skos\": \"http://www.w3.org/2004/02/skos/core#\",\n", " \"prov\": \"http://www.w3.org/ns/prov#\",\n", " \"foaf\": \"http://xmlns.com/foaf/0.1/\",\n", " \"m4i\": \"http://w3id.org/nfdi4ing/metadata4ing#\"\n", " },\n", " \"@type\": \"prov:Person\",\n", " \"foaf:lastName\": \"Probst\",\n", " \"m4i:orcidId\": {\n", " \"@id\": \"https://orcid.org/0000-0001-8729-0482\"\n", " },\n", " \"firstname\": \"Matthias\",\n", " \"@id\": \"https://orcid.org/0000-0001-8729-0482\"\n", "}\n" ] } ], "source": [ "print(person.model_dump_jsonld())" ] }, { "cell_type": "markdown", "id": "de617e50-ddfb-47c2-9987-bd6fa83b1ab2", "metadata": {}, "source": [ "The same accounts for `hasRorId` in organizations:" ] }, { "cell_type": "code", "execution_count": 5, "id": "0f3c79b4-86ff-4422-9141-9eeb75c63c58", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\n", " \"@context\": {\n", " \"owl\": \"http://www.w3.org/2002/07/owl#\",\n", " \"rdfs\": \"http://www.w3.org/2000/01/rdf-schema#\",\n", " \"dcterms\": \"http://purl.org/dc/terms/\",\n", " \"schema\": \"https://schema.org/\",\n", " \"skos\": \"http://www.w3.org/2004/02/skos/core#\",\n", " \"prov\": \"http://www.w3.org/ns/prov#\",\n", " \"foaf\": \"http://xmlns.com/foaf/0.1/\",\n", " \"m4i\": \"http://w3id.org/nfdi4ing/metadata4ing#\"\n", " },\n", " \"@type\": \"prov:Organization\",\n", " \"foaf:name\": {\n", " \"@value\": \"Awesome university\",\n", " \"@language\": \"en\"\n", " },\n", " \"m4i:hasRorId\": {\n", " \"@id\": \"https://ror.org/04t3en479\"\n", " },\n", " \"@id\": \"https://ror.org/04t3en479\"\n", "}\n" ] } ], "source": [ "print(orga.model_dump_jsonld())" ] }, { "cell_type": "markdown", "id": "84258719-c5e4-43b3-b8e4-683bad5e1b14", "metadata": {}, "source": [ "Alternative, dump the as Turtle:" ] }, { "cell_type": "code", "execution_count": 6, "id": "64170271-bbe4-40be-863a-820b6c74a05e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "@prefix foaf: .\n", "@prefix m4i: .\n", "@prefix prov: .\n", "\n", " a prov:Person ;\n", " m4i:orcidId ;\n", " foaf:lastName \"Probst\" .\n", "\n", "\n" ] } ], "source": [ "print(person.model_dump_ttl())" ] }, { "cell_type": "code", "execution_count": 7, "id": "bdb7f09f-b3d3-4e67-894d-cf48c787bd66", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "@prefix foaf: .\n", "@prefix m4i: .\n", "@prefix prov: .\n", "\n", " a prov:Organization ;\n", " m4i:hasRorId ;\n", " foaf:name \"Awesome university\"@en .\n", "\n", "\n" ] } ], "source": [ "print(orga.model_dump_ttl())" ] }, { "cell_type": "code", "execution_count": null, "id": "16d2499b-6c08-4b1b-bbf6-8e98d834bb4f", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "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.11.11" } }, "nbformat": 4, "nbformat_minor": 5 }