-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from emmo-repo/dev
update data types and examples
- Loading branch information
Showing
10 changed files
with
442 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Ignore the virtual environment directory | ||
.venv/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 12, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Import necessary libraries\n", | ||
"from rdflib import Graph\n", | ||
"from ontopy import get_ontology\n", | ||
"import json\n", | ||
"\n", | ||
"# Load the ontology\n", | ||
"echo = get_ontology('https://w3id.org/emmo/domain/electrochemistry/inferred').load()\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 13, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Diameter: 2 https://w3id.org/emmo#CentiMetre\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Create an RDF graph\n", | ||
"g = Graph()\n", | ||
"\n", | ||
"# Load the JSON-LD data\n", | ||
"json_ld_data = {\n", | ||
" \"@context\": \"https://w3id.org/emmo/domain/electrochemistry/context\",\n", | ||
" \"@type\": \"Electrode\",\n", | ||
" \"schema:manufacturer\": {\n", | ||
" \"@type\": \"schema:ResearchOrganization\",\n", | ||
" \"@id\": \"https://www.wikidata.org/wiki/Q3041255\",\n", | ||
" \"schema:name\": \"SINTEF\"\n", | ||
" },\n", | ||
" \"schema:creator\": {\n", | ||
" \"@type\": \"schema:Person\",\n", | ||
" \"@id\": \"https://orcid.org/0000-0002-8758-6109\",\n", | ||
" \"schema:name\": \"Simon Clark\"\n", | ||
" },\n", | ||
" \"hasActiveMaterial\": {\n", | ||
" \"@type\": [\"Zinc\", \"Foil\"]\n", | ||
" },\n", | ||
" \"hasProperty\": [\n", | ||
" {\n", | ||
" \"@type\": [\"SpecificCapacity\", \"MeasuredProperty\"],\n", | ||
" \"hasNumericalPart\": {\n", | ||
" \"@type\": \"Real\",\n", | ||
" \"hasNumericalValue\": 800\n", | ||
" },\n", | ||
" \"hasMeasurementUnit\": \"emmo:MilliAmpereHourPerGram\"\n", | ||
" },\n", | ||
" {\n", | ||
" \"@type\": [\"Thickness\", \"ConventionalProperty\"],\n", | ||
" \"hasNumericalPart\": {\n", | ||
" \"@type\": \"Real\",\n", | ||
" \"hasNumericalValue\": 250\n", | ||
" },\n", | ||
" \"hasMeasurementUnit\": \"emmo:MicroMetre\"\n", | ||
" },\n", | ||
" {\n", | ||
" \"@type\": [\"Diameter\", \"MeasuredProperty\"],\n", | ||
" \"hasNumericalPart\": {\n", | ||
" \"@type\": \"Real\",\n", | ||
" \"hasNumericalValue\": 2\n", | ||
" },\n", | ||
" \"hasMeasurementUnit\": \"emmo:CentiMetre\"\n", | ||
" },\n", | ||
" {\n", | ||
" \"@type\": [\"Mass\", \"MeasuredProperty\"],\n", | ||
" \"hasNumericalPart\": {\n", | ||
" \"@type\": \"Real\",\n", | ||
" \"hasNumericalValue\": 2.5\n", | ||
" },\n", | ||
" \"hasMeasurementUnit\": \"emmo:Gram\"\n", | ||
" }\n", | ||
" ]\n", | ||
"}\n", | ||
"\n", | ||
"# Convert JSON-LD data to RDF and add to the graph\n", | ||
"g.parse(data=json.dumps(json_ld_data), format='json-ld')\n", | ||
"\n", | ||
"# Query the graph to get the diameter\n", | ||
"query = f\"\"\"\n", | ||
"SELECT ?diameterValue ?measurementUnit\n", | ||
"WHERE {{\n", | ||
" ?electrode a <{echo.Electrode.iri}> ;\n", | ||
" <{echo.hasProperty.iri}> ?property .\n", | ||
"\n", | ||
" ?property a <{echo.Diameter.iri}> ;\n", | ||
" <{echo.hasNumericalPart.iri}> ?numericalPart ;\n", | ||
" <{echo.hasMeasurementUnit.iri}> ?measurementUnit .\n", | ||
"\n", | ||
" ?numericalPart <{echo.hasNumericalValue.iri}> ?diameterValue .\n", | ||
"}}\n", | ||
"\"\"\"\n", | ||
"\n", | ||
"# Run the query\n", | ||
"results = g.query(query)\n", | ||
"\n", | ||
"# Print results\n", | ||
"for row in results:\n", | ||
" unit = row.measurementUnit\n", | ||
" print(f\"Diameter: {row.diameterValue} {row.measurementUnit}\")\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": ".venv", | ||
"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.10.10" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"_actions":{"delete":"https://kadi-dlr.hiu-batteries.de/api/records/5334/files/3282eaa3-d8f8-4f8e-8f3d-cb618c34ae80","edit_data":"https://kadi-dlr.hiu-batteries.de/api/records/5334/files/3282eaa3-d8f8-4f8e-8f3d-cb618c34ae80","edit_metadata":"https://kadi-dlr.hiu-batteries.de/api/records/5334/files/3282eaa3-d8f8-4f8e-8f3d-cb618c34ae80"},"_links":{"download":"https://kadi-dlr.hiu-batteries.de/api/records/5334/files/3282eaa3-d8f8-4f8e-8f3d-cb618c34ae80/download","record":"https://kadi-dlr.hiu-batteries.de/api/records/5334","self":"https://kadi-dlr.hiu-batteries.de/api/records/5334/files/3282eaa3-d8f8-4f8e-8f3d-cb618c34ae80"},"checksum":"a2be68921f0c0046e530d951590576d3","created_at":"2024-08-02T09:22:39.972837+00:00","description":"","id":"3282eaa3-d8f8-4f8e-8f3d-cb618c34ae80","last_modified":"2024-08-02T09:22:40.027077+00:00","magic_mimetype":"application/json","mimetype":"application/json","name":"18650-LG-3500-MJ1-Graphite.jsonld","size":226,"state":"active","storage":{"storage_name":"Local","storage_type":"local"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.