About the Battery Ontology#
The EMMO Battery Domain Ontology is a semantic resource for the terms and relations needed to describe things, processes, and data in the battery domain. It can be used to generate linked data for the Semantic Web, comply with the FAIR data guidelines, support interoperaility of data among different systems, and more!
The Battery Ontology is intended to support researchers, engineers, and developers within the electrochemical @@ -449,11 +463,11 @@
License
@@ -520,7 +534,7 @@
License
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/battery.html b/battery.html
index 4557ff5..f6c9a16 100644
--- a/battery.html
+++ b/battery.html
@@ -44,6 +44,7 @@
+
@@ -3798,7 +3799,7 @@ StateOfCharge
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/contribute.html b/contribute.html
index e957e2d..ba393dd 100644
--- a/contribute.html
+++ b/contribute.html
@@ -44,6 +44,7 @@
+
@@ -471,7 +472,7 @@ Propose additions/deletion of elements
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_alkaline_electrochemical_cell.html b/example_alkaline_electrochemical_cell.html
index e98b2b4..4916f39 100644
--- a/example_alkaline_electrochemical_cell.html
+++ b/example_alkaline_electrochemical_cell.html
@@ -44,6 +44,7 @@
+
@@ -446,7 +447,7 @@ Alkaline Electrochemical Cell
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_aqueous_electrolyte_KOH.html b/example_aqueous_electrolyte_KOH.html
index 99e8003..70368de 100644
--- a/example_aqueous_electrolyte_KOH.html
+++ b/example_aqueous_electrolyte_KOH.html
@@ -44,6 +44,7 @@
+
@@ -470,7 +471,7 @@ Aqueous KOH Electrolyte
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_cyclic_voltammetry.html b/example_cyclic_voltammetry.html
index 613013b..d720ec5 100644
--- a/example_cyclic_voltammetry.html
+++ b/example_cyclic_voltammetry.html
@@ -44,6 +44,7 @@
+
@@ -495,7 +496,7 @@ Cyclic Voltammetry Data
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_eis_nyquist.html b/example_eis_nyquist.html
index 024f9d1..dbea6be 100644
--- a/example_eis_nyquist.html
+++ b/example_eis_nyquist.html
@@ -44,6 +44,7 @@
+
@@ -492,7 +493,7 @@ Cyclic Voltammetry Data
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_person_jsonld_nb.html b/example_person_jsonld_nb.html
new file mode 100644
index 0000000..e7758d8
--- /dev/null
+++ b/example_person_jsonld_nb.html
@@ -0,0 +1,791 @@
+
+
+
+
+
+
+
+
+
+
+
+ JSON-LD Demonstration — BattInfo documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Skip to main content
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+JSON-LD Demonstration#
+In this notebook, we will explore the principles of JSON-LD using the example of a person. JSON-LD stands for “JSON for Linking Data” and it provides a method to enrich your JSON data with semantics.
+An operational version of this notebook can be accessed here.
+
+[ ]:
+
+
+# Install the required library for JSON schema validation
+!pip install jsonschema
+!pip install rdflib
+
+
+
+
+
+
+
+
+Requirement already satisfied: jsonschema in /usr/local/lib/python3.10/dist-packages (4.19.0)
+Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (23.1.0)
+Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (2023.7.1)
+Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.30.2)
+Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.10.2)
+Collecting rdflib
+ Downloading rdflib-7.0.0-py3-none-any.whl (531 kB)
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 531.9/531.9 kB 6.6 MB/s eta 0:00:00
+Collecting isodate<0.7.0,>=0.6.0 (from rdflib)
+ Downloading isodate-0.6.1-py2.py3-none-any.whl (41 kB)
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.7/41.7 kB 4.3 MB/s eta 0:00:00
+Requirement already satisfied: pyparsing<4,>=2.1.0 in /usr/local/lib/python3.10/dist-packages (from rdflib) (3.1.1)
+Requirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from isodate<0.7.0,>=0.6.0->rdflib) (1.16.0)
+Installing collected packages: isodate, rdflib
+Successfully installed isodate-0.6.1 rdflib-7.0.0
+
+
+
+[ ]:
+
+
+import jsonschema
+from jsonschema import validate
+import json
+import rdflib
+
+# Regular JSON representation of a person
+person_data = {
+ "@context": {
+ "schema": "https://schema.org/",
+ "firstName": "schema:givenName",
+ "lastName": "schema:lastName",
+ "birthdate": "schema:birthDate",
+ "institute": "schema:affiliation",
+ "name": "schema:name",
+ "street": "schema:streetAddress",
+ "city": "schema:locality",
+ "zip": "schema:postalCode"
+ },
+ "@id": "https://www.example.com/SimonClark",
+ "@type": "schema:Person",
+ "firstName": "Simon",
+ "lastName": "Clark",
+ "birthdate": "1987-04-23",
+ "institute": {
+ "@id": "https://www.example.com/SINTEF",
+ "@type": "schema:ResearchOrganization",
+ "name": "SINTEF",
+ "street": "Strindvegen 4",
+ "city": "Trondheim",
+ "zip": "7034"
+ }
+}
+
+
+
+In the JSON-LD example, we added an @context
that maps terms in our JSON data to their semantic meanings, using URIs (typically from established vocabularies, like schema.org). This allows machines to understand the semantics behind the data.
+
+[ ]:
+
+
+# Regular JSON representation of a person
+person_data = {
+ "@context": "https://schema.org/",
+ "@id": "https://orcid.org/0000-0002-8758-6109",
+ "@type": "Person",
+ "firstName": "Simon",
+ "lastName": "Clark",
+ "gender": {"@type": "Male"},
+ "birthDate": "1987-04-23",
+ "affiliation": {
+ "@id": "https://ror.org/01f677e56",
+ "@type": "ResearchOrganization"
+ }
+}
+
+# email to: simon.clark@sintef.no
+
+
+
+
+[ ]:
+
+
+person_schema = {
+ "type": "object",
+ "properties": {
+ "firstName": {
+ "type": "string"
+ },
+ "lastName": {
+ "type": "string",
+ "minLength": 1
+ },
+ "birthDate": { # Replacing age with birthdate
+ "type": "string",
+ "format": "date",
+ "pattern": "^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$"
+ },
+ "gender": {
+ "type": "object"
+ },
+ "affiliation": {
+ "type": "object"
+ }
+ },
+ "required": ["firstName", "lastName", "birthDate", "affiliation"] # Updated age to birthdate
+}
+
+# Function to validate JSON data against the schema
+def validate_json(data, schema):
+ try:
+ validate(instance=data, schema=schema)
+ return True, "JSON data is valid according to the schema."
+ except jsonschema.exceptions.ValidationError as ve:
+ return False, ve.message
+
+# Validate the sample JSON data
+is_valid, message = validate_json(person_data, person_schema)
+print(message)
+
+
+
+
+
+
+
+
+JSON data is valid according to the schema.
+
+
+
+[ ]:
+
+
+# Create a new graph
+g = rdflib.Graph()
+
+# Load schema.org vocabulary into the graph
+g.parse("https://schema.org/version/latest/schemaorg-current-http.jsonld", format="json-ld")
+
+person_data_str = json.dumps(person_data)
+g.parse(data=person_data_str, format="json-ld")
+
+# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX schema: <http://schema.org/>
+SELECT DISTINCT ?type WHERE {
+ ?type rdfs:subClassOf* schema:Organization .
+}
+LIMIT 20
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row)
+
+
+
+
+
+
+
+
+(rdflib.term.URIRef('http://schema.org/Organization'),)
+(rdflib.term.URIRef('http://schema.org/PerformingGroup'),)
+(rdflib.term.URIRef('http://schema.org/TheaterGroup'),)
+(rdflib.term.URIRef('http://schema.org/MusicGroup'),)
+(rdflib.term.URIRef('http://schema.org/DanceGroup'),)
+(rdflib.term.URIRef('http://schema.org/OnlineBusiness'),)
+(rdflib.term.URIRef('http://schema.org/OnlineStore'),)
+(rdflib.term.URIRef('http://schema.org/SportsOrganization'),)
+(rdflib.term.URIRef('http://schema.org/SportsTeam'),)
+(rdflib.term.URIRef('http://schema.org/Airline'),)
+(rdflib.term.URIRef('http://schema.org/SearchRescueOrganization'),)
+(rdflib.term.URIRef('http://schema.org/FundingScheme'),)
+(rdflib.term.URIRef('http://schema.org/NewsMediaOrganization'),)
+(rdflib.term.URIRef('http://schema.org/EducationalOrganization'),)
+(rdflib.term.URIRef('http://schema.org/CollegeOrUniversity'),)
+(rdflib.term.URIRef('http://schema.org/HighSchool'),)
+(rdflib.term.URIRef('http://schema.org/Preschool'),)
+(rdflib.term.URIRef('http://schema.org/ElementarySchool'),)
+(rdflib.term.URIRef('http://schema.org/MiddleSchool'),)
+(rdflib.term.URIRef('http://schema.org/School'),)
+
+
+
+[ ]:
+
+
+# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX schema: <http://schema.org/>
+
+SELECT ?instance WHERE {
+ ?subclass rdfs:subClassOf* schema:Organization .
+ ?instance rdf:type ?subclass .
+}
+LIMIT 10
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row[0])
+
+
+
+
+
+
+
+
+https://ror.org/01f677e56
+
+
+
+[ ]:
+
+
+# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX schema: <http://schema.org/>
+
+SELECT (COUNT(?subject) AS ?numMales) WHERE {
+ ?subject rdf:type schema:Person .
+ ?subject schema:gender ?gender .
+ ?gender rdf:type schema:Male .
+}
+LIMIT 10
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row.numMales)
+
+
+
+
+
+
+
+
+1
+
+
+
+[ ]:
+
+
+# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX schema: <http://schema.org/>
+
+SELECT ?bday WHERE {
+ ?subject rdf:type schema:Person .
+ ?subject schema:birthDate ?bday .
+}
+LIMIT 10
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row[0])
+
+
+
+
+
+
+
+
+1987-04-23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example_person_jsonld_nb.ipynb b/example_person_jsonld_nb.ipynb
new file mode 100644
index 0000000..d4afd14
--- /dev/null
+++ b/example_person_jsonld_nb.ipynb
@@ -0,0 +1,394 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "aw_lp5wfXRSl"
+ },
+ "source": [
+ "# JSON-LD Demonstration\n",
+ "\n",
+ "In this notebook, we will explore the principles of JSON-LD using the example of a person. JSON-LD stands for \"JSON for Linking Data\" and it provides a method to enrich your JSON data with semantics.\n",
+ "\n",
+ "An operational version of this notebook can be accessed [here](https://colab.research.google.com/drive/14XqRJPWs07RUQgZmDZEu3yb2m1xGvxEQ?usp=sharing)."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "y-aalpcNb223",
+ "outputId": "565a219c-1d10-4b55-fd75-a1fcb2257022"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Requirement already satisfied: jsonschema in /usr/local/lib/python3.10/dist-packages (4.19.0)\n",
+ "Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (23.1.0)\n",
+ "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (2023.7.1)\n",
+ "Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.30.2)\n",
+ "Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.10.2)\n",
+ "Collecting rdflib\n",
+ " Downloading rdflib-7.0.0-py3-none-any.whl (531 kB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m531.9/531.9 kB\u001b[0m \u001b[31m6.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hCollecting isodate<0.7.0,>=0.6.0 (from rdflib)\n",
+ " Downloading isodate-0.6.1-py2.py3-none-any.whl (41 kB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m41.7/41.7 kB\u001b[0m \u001b[31m4.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hRequirement already satisfied: pyparsing<4,>=2.1.0 in /usr/local/lib/python3.10/dist-packages (from rdflib) (3.1.1)\n",
+ "Requirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from isodate<0.7.0,>=0.6.0->rdflib) (1.16.0)\n",
+ "Installing collected packages: isodate, rdflib\n",
+ "Successfully installed isodate-0.6.1 rdflib-7.0.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Install the required library for JSON schema validation\n",
+ "!pip install jsonschema\n",
+ "!pip install rdflib"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "tNjkjGNEXJXP"
+ },
+ "outputs": [],
+ "source": [
+ "import jsonschema\n",
+ "from jsonschema import validate\n",
+ "import json\n",
+ "import rdflib\n",
+ "\n",
+ "# Regular JSON representation of a person\n",
+ "person_data = {\n",
+ " \"@context\": {\n",
+ " \"schema\": \"https://schema.org/\",\n",
+ " \"firstName\": \"schema:givenName\",\n",
+ " \"lastName\": \"schema:lastName\",\n",
+ " \"birthdate\": \"schema:birthDate\",\n",
+ " \"institute\": \"schema:affiliation\",\n",
+ " \"name\": \"schema:name\",\n",
+ " \"street\": \"schema:streetAddress\",\n",
+ " \"city\": \"schema:locality\",\n",
+ " \"zip\": \"schema:postalCode\"\n",
+ " },\n",
+ " \"@id\": \"https://www.example.com/SimonClark\",\n",
+ " \"@type\": \"schema:Person\",\n",
+ " \"firstName\": \"Simon\",\n",
+ " \"lastName\": \"Clark\",\n",
+ " \"birthdate\": \"1987-04-23\",\n",
+ " \"institute\": {\n",
+ " \"@id\": \"https://www.example.com/SINTEF\",\n",
+ " \"@type\": \"schema:ResearchOrganization\",\n",
+ " \"name\": \"SINTEF\",\n",
+ " \"street\": \"Strindvegen 4\",\n",
+ " \"city\": \"Trondheim\",\n",
+ " \"zip\": \"7034\"\n",
+ " }\n",
+ "}\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "K221MAoHa3Nx"
+ },
+ "source": [
+ "In the JSON-LD example, we added an `@context` that maps terms in our JSON data to their semantic meanings, using URIs (typically from established vocabularies, like schema.org). This allows machines to understand the semantics behind the data.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "ZmQfOeFyieo9"
+ },
+ "outputs": [],
+ "source": [
+ "# Regular JSON representation of a person\n",
+ "person_data = {\n",
+ " \"@context\": \"https://schema.org/\",\n",
+ " \"@id\": \"https://orcid.org/0000-0002-8758-6109\",\n",
+ " \"@type\": \"Person\",\n",
+ " \"firstName\": \"Simon\",\n",
+ " \"lastName\": \"Clark\",\n",
+ " \"gender\": {\"@type\": \"Male\"},\n",
+ " \"birthDate\": \"1987-04-23\",\n",
+ " \"affiliation\": {\n",
+ " \"@id\": \"https://ror.org/01f677e56\",\n",
+ " \"@type\": \"ResearchOrganization\"\n",
+ " }\n",
+ "}\n",
+ "\n",
+ "# email to: simon.clark@sintef.no"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "HDHJuV62bTby",
+ "outputId": "d5537f6e-4325-40ef-dfa4-c7d55159623f"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "JSON data is valid according to the schema.\n"
+ ]
+ }
+ ],
+ "source": [
+ "person_schema = {\n",
+ " \"type\": \"object\",\n",
+ " \"properties\": {\n",
+ " \"firstName\": {\n",
+ " \"type\": \"string\"\n",
+ " },\n",
+ " \"lastName\": {\n",
+ " \"type\": \"string\",\n",
+ " \"minLength\": 1\n",
+ " },\n",
+ " \"birthDate\": { # Replacing age with birthdate\n",
+ " \"type\": \"string\",\n",
+ " \"format\": \"date\",\n",
+ " \"pattern\": \"^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$\"\n",
+ " },\n",
+ " \"gender\": {\n",
+ " \"type\": \"object\"\n",
+ " },\n",
+ " \"affiliation\": {\n",
+ " \"type\": \"object\"\n",
+ " }\n",
+ " },\n",
+ " \"required\": [\"firstName\", \"lastName\", \"birthDate\", \"affiliation\"] # Updated age to birthdate\n",
+ "}\n",
+ "\n",
+ "# Function to validate JSON data against the schema\n",
+ "def validate_json(data, schema):\n",
+ " try:\n",
+ " validate(instance=data, schema=schema)\n",
+ " return True, \"JSON data is valid according to the schema.\"\n",
+ " except jsonschema.exceptions.ValidationError as ve:\n",
+ " return False, ve.message\n",
+ "\n",
+ "# Validate the sample JSON data\n",
+ "is_valid, message = validate_json(person_data, person_schema)\n",
+ "print(message)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "R-mO4FGtbr-L",
+ "outputId": "c0ae5e87-6ade-4ef8-a639-02bf287071a9"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "(rdflib.term.URIRef('http://schema.org/Organization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/PerformingGroup'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/TheaterGroup'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/MusicGroup'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/DanceGroup'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/OnlineBusiness'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/OnlineStore'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/SportsOrganization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/SportsTeam'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/Airline'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/SearchRescueOrganization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/FundingScheme'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/NewsMediaOrganization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/EducationalOrganization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/CollegeOrUniversity'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/HighSchool'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/Preschool'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/ElementarySchool'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/MiddleSchool'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/School'),)\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Create a new graph\n",
+ "g = rdflib.Graph()\n",
+ "\n",
+ "# Load schema.org vocabulary into the graph\n",
+ "g.parse(\"https://schema.org/version/latest/schemaorg-current-http.jsonld\", format=\"json-ld\")\n",
+ "\n",
+ "person_data_str = json.dumps(person_data)\n",
+ "g.parse(data=person_data_str, format=\"json-ld\")\n",
+ "\n",
+ "# Define and execute a SPARQL query for all instances of Organization\n",
+ "sparql_query = \"\"\"\n",
+ "PREFIX schema: \n",
+ "SELECT DISTINCT ?type WHERE {\n",
+ " ?type rdfs:subClassOf* schema:Organization .\n",
+ "}\n",
+ "LIMIT 20\n",
+ "\"\"\"\n",
+ "\n",
+ "# Execute the SPARQL query\n",
+ "results = g.query(sparql_query)\n",
+ "\n",
+ "# Print the results\n",
+ "for row in results:\n",
+ " print(row)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "h4vvw5hNhih2",
+ "outputId": "77828fc9-bafe-414b-f6f6-65fb117aabc5"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "https://ror.org/01f677e56\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Define and execute a SPARQL query for all instances of Organization\n",
+ "sparql_query = \"\"\"\n",
+ "PREFIX rdf: \n",
+ "PREFIX rdfs: \n",
+ "PREFIX schema: \n",
+ "\n",
+ "SELECT ?instance WHERE {\n",
+ " ?subclass rdfs:subClassOf* schema:Organization .\n",
+ " ?instance rdf:type ?subclass .\n",
+ "}\n",
+ "LIMIT 10\n",
+ "\"\"\"\n",
+ "\n",
+ "# Execute the SPARQL query\n",
+ "results = g.query(sparql_query)\n",
+ "\n",
+ "# Print the results\n",
+ "for row in results:\n",
+ " print(row[0])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "e_-Qa3Hgh2kg",
+ "outputId": "2b9fafa4-fca4-426f-e768-6ef561921b14"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "1\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Define and execute a SPARQL query for all instances of Organization\n",
+ "sparql_query = \"\"\"\n",
+ "PREFIX rdf: \n",
+ "PREFIX rdfs: \n",
+ "PREFIX schema: \n",
+ "\n",
+ "SELECT (COUNT(?subject) AS ?numMales) WHERE {\n",
+ " ?subject rdf:type schema:Person .\n",
+ " ?subject schema:gender ?gender .\n",
+ " ?gender rdf:type schema:Male .\n",
+ "}\n",
+ "LIMIT 10\n",
+ "\"\"\"\n",
+ "\n",
+ "# Execute the SPARQL query\n",
+ "results = g.query(sparql_query)\n",
+ "\n",
+ "# Print the results\n",
+ "for row in results:\n",
+ " print(row.numMales)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "HJfpCj4-sww3",
+ "outputId": "c4ba6b30-7d7e-45d9-c3e4-b0d311e0fdd0"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "1987-04-23\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Define and execute a SPARQL query for all instances of Organization\n",
+ "sparql_query = \"\"\"\n",
+ "PREFIX rdf: \n",
+ "PREFIX rdfs: \n",
+ "PREFIX schema: \n",
+ "\n",
+ "SELECT ?bday WHERE {\n",
+ " ?subject rdf:type schema:Person .\n",
+ " ?subject schema:birthDate ?bday .\n",
+ "}\n",
+ "LIMIT 10\n",
+ "\"\"\"\n",
+ "\n",
+ "# Execute the SPARQL query\n",
+ "results = g.query(sparql_query)\n",
+ "\n",
+ "# Print the results\n",
+ "for row in results:\n",
+ " print(row[0])"
+ ]
+ }
+ ],
+ "metadata": {
+ "colab": {
+ "provenance": []
+ },
+ "kernelspec": {
+ "display_name": "Python 3",
+ "name": "python3"
+ },
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/example_zinc_electrode.html b/example_zinc_electrode.html
index afe7b5f..f25d9a7 100644
--- a/example_zinc_electrode.html
+++ b/example_zinc_electrode.html
@@ -44,6 +44,7 @@
+
@@ -483,7 +484,7 @@ Zinc Electrode
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_zinc_powder.html b/example_zinc_powder.html
index 4823d3d..b648375 100644
--- a/example_zinc_powder.html
+++ b/example_zinc_powder.html
@@ -44,6 +44,7 @@
+
@@ -455,7 +456,7 @@ Zinc Powder
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/examples.html b/examples.html
index 23566c8..702f9b4 100644
--- a/examples.html
+++ b/examples.html
@@ -44,6 +44,7 @@
+
@@ -506,7 +507,7 @@ Examples
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/faq.html b/faq.html
index cfb115a..704305a 100644
--- a/faq.html
+++ b/faq.html
@@ -44,12 +44,13 @@
+
-
+
@@ -406,12 +407,12 @@ FAQ Page
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
StateOfCharge
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/contribute.html b/contribute.html
index e957e2d..ba393dd 100644
--- a/contribute.html
+++ b/contribute.html
@@ -44,6 +44,7 @@
+
@@ -471,7 +472,7 @@ Propose additions/deletion of elements
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_alkaline_electrochemical_cell.html b/example_alkaline_electrochemical_cell.html
index e98b2b4..4916f39 100644
--- a/example_alkaline_electrochemical_cell.html
+++ b/example_alkaline_electrochemical_cell.html
@@ -44,6 +44,7 @@
+
@@ -446,7 +447,7 @@ Alkaline Electrochemical Cell
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_aqueous_electrolyte_KOH.html b/example_aqueous_electrolyte_KOH.html
index 99e8003..70368de 100644
--- a/example_aqueous_electrolyte_KOH.html
+++ b/example_aqueous_electrolyte_KOH.html
@@ -44,6 +44,7 @@
+
@@ -470,7 +471,7 @@ Aqueous KOH Electrolyte
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_cyclic_voltammetry.html b/example_cyclic_voltammetry.html
index 613013b..d720ec5 100644
--- a/example_cyclic_voltammetry.html
+++ b/example_cyclic_voltammetry.html
@@ -44,6 +44,7 @@
+
@@ -495,7 +496,7 @@ Cyclic Voltammetry Data
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_eis_nyquist.html b/example_eis_nyquist.html
index 024f9d1..dbea6be 100644
--- a/example_eis_nyquist.html
+++ b/example_eis_nyquist.html
@@ -44,6 +44,7 @@
+
@@ -492,7 +493,7 @@ Cyclic Voltammetry Data
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_person_jsonld_nb.html b/example_person_jsonld_nb.html
new file mode 100644
index 0000000..e7758d8
--- /dev/null
+++ b/example_person_jsonld_nb.html
@@ -0,0 +1,791 @@
+
+
+
+
+
+
+
+
+
+
+
+ JSON-LD Demonstration — BattInfo documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Skip to main content
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+JSON-LD Demonstration#
+In this notebook, we will explore the principles of JSON-LD using the example of a person. JSON-LD stands for “JSON for Linking Data” and it provides a method to enrich your JSON data with semantics.
+An operational version of this notebook can be accessed here.
+
+[ ]:
+
+
+# Install the required library for JSON schema validation
+!pip install jsonschema
+!pip install rdflib
+
+
+
+
+
+
+
+
+Requirement already satisfied: jsonschema in /usr/local/lib/python3.10/dist-packages (4.19.0)
+Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (23.1.0)
+Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (2023.7.1)
+Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.30.2)
+Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.10.2)
+Collecting rdflib
+ Downloading rdflib-7.0.0-py3-none-any.whl (531 kB)
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 531.9/531.9 kB 6.6 MB/s eta 0:00:00
+Collecting isodate<0.7.0,>=0.6.0 (from rdflib)
+ Downloading isodate-0.6.1-py2.py3-none-any.whl (41 kB)
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.7/41.7 kB 4.3 MB/s eta 0:00:00
+Requirement already satisfied: pyparsing<4,>=2.1.0 in /usr/local/lib/python3.10/dist-packages (from rdflib) (3.1.1)
+Requirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from isodate<0.7.0,>=0.6.0->rdflib) (1.16.0)
+Installing collected packages: isodate, rdflib
+Successfully installed isodate-0.6.1 rdflib-7.0.0
+
+
+
+[ ]:
+
+
+import jsonschema
+from jsonschema import validate
+import json
+import rdflib
+
+# Regular JSON representation of a person
+person_data = {
+ "@context": {
+ "schema": "https://schema.org/",
+ "firstName": "schema:givenName",
+ "lastName": "schema:lastName",
+ "birthdate": "schema:birthDate",
+ "institute": "schema:affiliation",
+ "name": "schema:name",
+ "street": "schema:streetAddress",
+ "city": "schema:locality",
+ "zip": "schema:postalCode"
+ },
+ "@id": "https://www.example.com/SimonClark",
+ "@type": "schema:Person",
+ "firstName": "Simon",
+ "lastName": "Clark",
+ "birthdate": "1987-04-23",
+ "institute": {
+ "@id": "https://www.example.com/SINTEF",
+ "@type": "schema:ResearchOrganization",
+ "name": "SINTEF",
+ "street": "Strindvegen 4",
+ "city": "Trondheim",
+ "zip": "7034"
+ }
+}
+
+
+
+In the JSON-LD example, we added an @context
that maps terms in our JSON data to their semantic meanings, using URIs (typically from established vocabularies, like schema.org). This allows machines to understand the semantics behind the data.
+
+[ ]:
+
+
+# Regular JSON representation of a person
+person_data = {
+ "@context": "https://schema.org/",
+ "@id": "https://orcid.org/0000-0002-8758-6109",
+ "@type": "Person",
+ "firstName": "Simon",
+ "lastName": "Clark",
+ "gender": {"@type": "Male"},
+ "birthDate": "1987-04-23",
+ "affiliation": {
+ "@id": "https://ror.org/01f677e56",
+ "@type": "ResearchOrganization"
+ }
+}
+
+# email to: simon.clark@sintef.no
+
+
+
+
+[ ]:
+
+
+person_schema = {
+ "type": "object",
+ "properties": {
+ "firstName": {
+ "type": "string"
+ },
+ "lastName": {
+ "type": "string",
+ "minLength": 1
+ },
+ "birthDate": { # Replacing age with birthdate
+ "type": "string",
+ "format": "date",
+ "pattern": "^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$"
+ },
+ "gender": {
+ "type": "object"
+ },
+ "affiliation": {
+ "type": "object"
+ }
+ },
+ "required": ["firstName", "lastName", "birthDate", "affiliation"] # Updated age to birthdate
+}
+
+# Function to validate JSON data against the schema
+def validate_json(data, schema):
+ try:
+ validate(instance=data, schema=schema)
+ return True, "JSON data is valid according to the schema."
+ except jsonschema.exceptions.ValidationError as ve:
+ return False, ve.message
+
+# Validate the sample JSON data
+is_valid, message = validate_json(person_data, person_schema)
+print(message)
+
+
+
+
+
+
+
+
+JSON data is valid according to the schema.
+
+
+
+[ ]:
+
+
+# Create a new graph
+g = rdflib.Graph()
+
+# Load schema.org vocabulary into the graph
+g.parse("https://schema.org/version/latest/schemaorg-current-http.jsonld", format="json-ld")
+
+person_data_str = json.dumps(person_data)
+g.parse(data=person_data_str, format="json-ld")
+
+# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX schema: <http://schema.org/>
+SELECT DISTINCT ?type WHERE {
+ ?type rdfs:subClassOf* schema:Organization .
+}
+LIMIT 20
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row)
+
+
+
+
+
+
+
+
+(rdflib.term.URIRef('http://schema.org/Organization'),)
+(rdflib.term.URIRef('http://schema.org/PerformingGroup'),)
+(rdflib.term.URIRef('http://schema.org/TheaterGroup'),)
+(rdflib.term.URIRef('http://schema.org/MusicGroup'),)
+(rdflib.term.URIRef('http://schema.org/DanceGroup'),)
+(rdflib.term.URIRef('http://schema.org/OnlineBusiness'),)
+(rdflib.term.URIRef('http://schema.org/OnlineStore'),)
+(rdflib.term.URIRef('http://schema.org/SportsOrganization'),)
+(rdflib.term.URIRef('http://schema.org/SportsTeam'),)
+(rdflib.term.URIRef('http://schema.org/Airline'),)
+(rdflib.term.URIRef('http://schema.org/SearchRescueOrganization'),)
+(rdflib.term.URIRef('http://schema.org/FundingScheme'),)
+(rdflib.term.URIRef('http://schema.org/NewsMediaOrganization'),)
+(rdflib.term.URIRef('http://schema.org/EducationalOrganization'),)
+(rdflib.term.URIRef('http://schema.org/CollegeOrUniversity'),)
+(rdflib.term.URIRef('http://schema.org/HighSchool'),)
+(rdflib.term.URIRef('http://schema.org/Preschool'),)
+(rdflib.term.URIRef('http://schema.org/ElementarySchool'),)
+(rdflib.term.URIRef('http://schema.org/MiddleSchool'),)
+(rdflib.term.URIRef('http://schema.org/School'),)
+
+
+
+[ ]:
+
+
+# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX schema: <http://schema.org/>
+
+SELECT ?instance WHERE {
+ ?subclass rdfs:subClassOf* schema:Organization .
+ ?instance rdf:type ?subclass .
+}
+LIMIT 10
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row[0])
+
+
+
+
+
+
+
+
+https://ror.org/01f677e56
+
+
+
+[ ]:
+
+
+# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX schema: <http://schema.org/>
+
+SELECT (COUNT(?subject) AS ?numMales) WHERE {
+ ?subject rdf:type schema:Person .
+ ?subject schema:gender ?gender .
+ ?gender rdf:type schema:Male .
+}
+LIMIT 10
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row.numMales)
+
+
+
+
+
+
+
+
+1
+
+
+
+[ ]:
+
+
+# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX schema: <http://schema.org/>
+
+SELECT ?bday WHERE {
+ ?subject rdf:type schema:Person .
+ ?subject schema:birthDate ?bday .
+}
+LIMIT 10
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row[0])
+
+
+
+
+
+
+
+
+1987-04-23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example_person_jsonld_nb.ipynb b/example_person_jsonld_nb.ipynb
new file mode 100644
index 0000000..d4afd14
--- /dev/null
+++ b/example_person_jsonld_nb.ipynb
@@ -0,0 +1,394 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "aw_lp5wfXRSl"
+ },
+ "source": [
+ "# JSON-LD Demonstration\n",
+ "\n",
+ "In this notebook, we will explore the principles of JSON-LD using the example of a person. JSON-LD stands for \"JSON for Linking Data\" and it provides a method to enrich your JSON data with semantics.\n",
+ "\n",
+ "An operational version of this notebook can be accessed [here](https://colab.research.google.com/drive/14XqRJPWs07RUQgZmDZEu3yb2m1xGvxEQ?usp=sharing)."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "y-aalpcNb223",
+ "outputId": "565a219c-1d10-4b55-fd75-a1fcb2257022"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Requirement already satisfied: jsonschema in /usr/local/lib/python3.10/dist-packages (4.19.0)\n",
+ "Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (23.1.0)\n",
+ "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (2023.7.1)\n",
+ "Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.30.2)\n",
+ "Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.10.2)\n",
+ "Collecting rdflib\n",
+ " Downloading rdflib-7.0.0-py3-none-any.whl (531 kB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m531.9/531.9 kB\u001b[0m \u001b[31m6.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hCollecting isodate<0.7.0,>=0.6.0 (from rdflib)\n",
+ " Downloading isodate-0.6.1-py2.py3-none-any.whl (41 kB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m41.7/41.7 kB\u001b[0m \u001b[31m4.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hRequirement already satisfied: pyparsing<4,>=2.1.0 in /usr/local/lib/python3.10/dist-packages (from rdflib) (3.1.1)\n",
+ "Requirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from isodate<0.7.0,>=0.6.0->rdflib) (1.16.0)\n",
+ "Installing collected packages: isodate, rdflib\n",
+ "Successfully installed isodate-0.6.1 rdflib-7.0.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Install the required library for JSON schema validation\n",
+ "!pip install jsonschema\n",
+ "!pip install rdflib"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "tNjkjGNEXJXP"
+ },
+ "outputs": [],
+ "source": [
+ "import jsonschema\n",
+ "from jsonschema import validate\n",
+ "import json\n",
+ "import rdflib\n",
+ "\n",
+ "# Regular JSON representation of a person\n",
+ "person_data = {\n",
+ " \"@context\": {\n",
+ " \"schema\": \"https://schema.org/\",\n",
+ " \"firstName\": \"schema:givenName\",\n",
+ " \"lastName\": \"schema:lastName\",\n",
+ " \"birthdate\": \"schema:birthDate\",\n",
+ " \"institute\": \"schema:affiliation\",\n",
+ " \"name\": \"schema:name\",\n",
+ " \"street\": \"schema:streetAddress\",\n",
+ " \"city\": \"schema:locality\",\n",
+ " \"zip\": \"schema:postalCode\"\n",
+ " },\n",
+ " \"@id\": \"https://www.example.com/SimonClark\",\n",
+ " \"@type\": \"schema:Person\",\n",
+ " \"firstName\": \"Simon\",\n",
+ " \"lastName\": \"Clark\",\n",
+ " \"birthdate\": \"1987-04-23\",\n",
+ " \"institute\": {\n",
+ " \"@id\": \"https://www.example.com/SINTEF\",\n",
+ " \"@type\": \"schema:ResearchOrganization\",\n",
+ " \"name\": \"SINTEF\",\n",
+ " \"street\": \"Strindvegen 4\",\n",
+ " \"city\": \"Trondheim\",\n",
+ " \"zip\": \"7034\"\n",
+ " }\n",
+ "}\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "K221MAoHa3Nx"
+ },
+ "source": [
+ "In the JSON-LD example, we added an `@context` that maps terms in our JSON data to their semantic meanings, using URIs (typically from established vocabularies, like schema.org). This allows machines to understand the semantics behind the data.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "ZmQfOeFyieo9"
+ },
+ "outputs": [],
+ "source": [
+ "# Regular JSON representation of a person\n",
+ "person_data = {\n",
+ " \"@context\": \"https://schema.org/\",\n",
+ " \"@id\": \"https://orcid.org/0000-0002-8758-6109\",\n",
+ " \"@type\": \"Person\",\n",
+ " \"firstName\": \"Simon\",\n",
+ " \"lastName\": \"Clark\",\n",
+ " \"gender\": {\"@type\": \"Male\"},\n",
+ " \"birthDate\": \"1987-04-23\",\n",
+ " \"affiliation\": {\n",
+ " \"@id\": \"https://ror.org/01f677e56\",\n",
+ " \"@type\": \"ResearchOrganization\"\n",
+ " }\n",
+ "}\n",
+ "\n",
+ "# email to: simon.clark@sintef.no"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "HDHJuV62bTby",
+ "outputId": "d5537f6e-4325-40ef-dfa4-c7d55159623f"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "JSON data is valid according to the schema.\n"
+ ]
+ }
+ ],
+ "source": [
+ "person_schema = {\n",
+ " \"type\": \"object\",\n",
+ " \"properties\": {\n",
+ " \"firstName\": {\n",
+ " \"type\": \"string\"\n",
+ " },\n",
+ " \"lastName\": {\n",
+ " \"type\": \"string\",\n",
+ " \"minLength\": 1\n",
+ " },\n",
+ " \"birthDate\": { # Replacing age with birthdate\n",
+ " \"type\": \"string\",\n",
+ " \"format\": \"date\",\n",
+ " \"pattern\": \"^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$\"\n",
+ " },\n",
+ " \"gender\": {\n",
+ " \"type\": \"object\"\n",
+ " },\n",
+ " \"affiliation\": {\n",
+ " \"type\": \"object\"\n",
+ " }\n",
+ " },\n",
+ " \"required\": [\"firstName\", \"lastName\", \"birthDate\", \"affiliation\"] # Updated age to birthdate\n",
+ "}\n",
+ "\n",
+ "# Function to validate JSON data against the schema\n",
+ "def validate_json(data, schema):\n",
+ " try:\n",
+ " validate(instance=data, schema=schema)\n",
+ " return True, \"JSON data is valid according to the schema.\"\n",
+ " except jsonschema.exceptions.ValidationError as ve:\n",
+ " return False, ve.message\n",
+ "\n",
+ "# Validate the sample JSON data\n",
+ "is_valid, message = validate_json(person_data, person_schema)\n",
+ "print(message)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "R-mO4FGtbr-L",
+ "outputId": "c0ae5e87-6ade-4ef8-a639-02bf287071a9"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "(rdflib.term.URIRef('http://schema.org/Organization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/PerformingGroup'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/TheaterGroup'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/MusicGroup'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/DanceGroup'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/OnlineBusiness'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/OnlineStore'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/SportsOrganization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/SportsTeam'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/Airline'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/SearchRescueOrganization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/FundingScheme'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/NewsMediaOrganization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/EducationalOrganization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/CollegeOrUniversity'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/HighSchool'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/Preschool'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/ElementarySchool'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/MiddleSchool'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/School'),)\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Create a new graph\n",
+ "g = rdflib.Graph()\n",
+ "\n",
+ "# Load schema.org vocabulary into the graph\n",
+ "g.parse(\"https://schema.org/version/latest/schemaorg-current-http.jsonld\", format=\"json-ld\")\n",
+ "\n",
+ "person_data_str = json.dumps(person_data)\n",
+ "g.parse(data=person_data_str, format=\"json-ld\")\n",
+ "\n",
+ "# Define and execute a SPARQL query for all instances of Organization\n",
+ "sparql_query = \"\"\"\n",
+ "PREFIX schema: \n",
+ "SELECT DISTINCT ?type WHERE {\n",
+ " ?type rdfs:subClassOf* schema:Organization .\n",
+ "}\n",
+ "LIMIT 20\n",
+ "\"\"\"\n",
+ "\n",
+ "# Execute the SPARQL query\n",
+ "results = g.query(sparql_query)\n",
+ "\n",
+ "# Print the results\n",
+ "for row in results:\n",
+ " print(row)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "h4vvw5hNhih2",
+ "outputId": "77828fc9-bafe-414b-f6f6-65fb117aabc5"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "https://ror.org/01f677e56\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Define and execute a SPARQL query for all instances of Organization\n",
+ "sparql_query = \"\"\"\n",
+ "PREFIX rdf: \n",
+ "PREFIX rdfs: \n",
+ "PREFIX schema: \n",
+ "\n",
+ "SELECT ?instance WHERE {\n",
+ " ?subclass rdfs:subClassOf* schema:Organization .\n",
+ " ?instance rdf:type ?subclass .\n",
+ "}\n",
+ "LIMIT 10\n",
+ "\"\"\"\n",
+ "\n",
+ "# Execute the SPARQL query\n",
+ "results = g.query(sparql_query)\n",
+ "\n",
+ "# Print the results\n",
+ "for row in results:\n",
+ " print(row[0])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "e_-Qa3Hgh2kg",
+ "outputId": "2b9fafa4-fca4-426f-e768-6ef561921b14"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "1\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Define and execute a SPARQL query for all instances of Organization\n",
+ "sparql_query = \"\"\"\n",
+ "PREFIX rdf: \n",
+ "PREFIX rdfs: \n",
+ "PREFIX schema: \n",
+ "\n",
+ "SELECT (COUNT(?subject) AS ?numMales) WHERE {\n",
+ " ?subject rdf:type schema:Person .\n",
+ " ?subject schema:gender ?gender .\n",
+ " ?gender rdf:type schema:Male .\n",
+ "}\n",
+ "LIMIT 10\n",
+ "\"\"\"\n",
+ "\n",
+ "# Execute the SPARQL query\n",
+ "results = g.query(sparql_query)\n",
+ "\n",
+ "# Print the results\n",
+ "for row in results:\n",
+ " print(row.numMales)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "HJfpCj4-sww3",
+ "outputId": "c4ba6b30-7d7e-45d9-c3e4-b0d311e0fdd0"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "1987-04-23\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Define and execute a SPARQL query for all instances of Organization\n",
+ "sparql_query = \"\"\"\n",
+ "PREFIX rdf: \n",
+ "PREFIX rdfs: \n",
+ "PREFIX schema: \n",
+ "\n",
+ "SELECT ?bday WHERE {\n",
+ " ?subject rdf:type schema:Person .\n",
+ " ?subject schema:birthDate ?bday .\n",
+ "}\n",
+ "LIMIT 10\n",
+ "\"\"\"\n",
+ "\n",
+ "# Execute the SPARQL query\n",
+ "results = g.query(sparql_query)\n",
+ "\n",
+ "# Print the results\n",
+ "for row in results:\n",
+ " print(row[0])"
+ ]
+ }
+ ],
+ "metadata": {
+ "colab": {
+ "provenance": []
+ },
+ "kernelspec": {
+ "display_name": "Python 3",
+ "name": "python3"
+ },
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/example_zinc_electrode.html b/example_zinc_electrode.html
index afe7b5f..f25d9a7 100644
--- a/example_zinc_electrode.html
+++ b/example_zinc_electrode.html
@@ -44,6 +44,7 @@
+
@@ -483,7 +484,7 @@ Zinc Electrode
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_zinc_powder.html b/example_zinc_powder.html
index 4823d3d..b648375 100644
--- a/example_zinc_powder.html
+++ b/example_zinc_powder.html
@@ -44,6 +44,7 @@
+
@@ -455,7 +456,7 @@ Zinc Powder
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/examples.html b/examples.html
index 23566c8..702f9b4 100644
--- a/examples.html
+++ b/examples.html
@@ -44,6 +44,7 @@
+
@@ -506,7 +507,7 @@ Examples
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/faq.html b/faq.html
index cfb115a..704305a 100644
--- a/faq.html
+++ b/faq.html
@@ -44,12 +44,13 @@
+
-
+
@@ -406,12 +407,12 @@ FAQ Page
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
Alkaline Electrochemical Cell
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_aqueous_electrolyte_KOH.html b/example_aqueous_electrolyte_KOH.html
index 99e8003..70368de 100644
--- a/example_aqueous_electrolyte_KOH.html
+++ b/example_aqueous_electrolyte_KOH.html
@@ -44,6 +44,7 @@
+
@@ -470,7 +471,7 @@ Aqueous KOH Electrolyte
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_cyclic_voltammetry.html b/example_cyclic_voltammetry.html
index 613013b..d720ec5 100644
--- a/example_cyclic_voltammetry.html
+++ b/example_cyclic_voltammetry.html
@@ -44,6 +44,7 @@
+
@@ -495,7 +496,7 @@ Cyclic Voltammetry Data
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_eis_nyquist.html b/example_eis_nyquist.html
index 024f9d1..dbea6be 100644
--- a/example_eis_nyquist.html
+++ b/example_eis_nyquist.html
@@ -44,6 +44,7 @@
+
@@ -492,7 +493,7 @@ Cyclic Voltammetry Data
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_person_jsonld_nb.html b/example_person_jsonld_nb.html
new file mode 100644
index 0000000..e7758d8
--- /dev/null
+++ b/example_person_jsonld_nb.html
@@ -0,0 +1,791 @@
+
+
+
+
+
+
+
+
+
+
+
+ JSON-LD Demonstration — BattInfo documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Skip to main content
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+JSON-LD Demonstration#
+In this notebook, we will explore the principles of JSON-LD using the example of a person. JSON-LD stands for “JSON for Linking Data” and it provides a method to enrich your JSON data with semantics.
+An operational version of this notebook can be accessed here.
+
+[ ]:
+
+
+# Install the required library for JSON schema validation
+!pip install jsonschema
+!pip install rdflib
+
+
+
+
+
+
+
+
+Requirement already satisfied: jsonschema in /usr/local/lib/python3.10/dist-packages (4.19.0)
+Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (23.1.0)
+Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (2023.7.1)
+Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.30.2)
+Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.10.2)
+Collecting rdflib
+ Downloading rdflib-7.0.0-py3-none-any.whl (531 kB)
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 531.9/531.9 kB 6.6 MB/s eta 0:00:00
+Collecting isodate<0.7.0,>=0.6.0 (from rdflib)
+ Downloading isodate-0.6.1-py2.py3-none-any.whl (41 kB)
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.7/41.7 kB 4.3 MB/s eta 0:00:00
+Requirement already satisfied: pyparsing<4,>=2.1.0 in /usr/local/lib/python3.10/dist-packages (from rdflib) (3.1.1)
+Requirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from isodate<0.7.0,>=0.6.0->rdflib) (1.16.0)
+Installing collected packages: isodate, rdflib
+Successfully installed isodate-0.6.1 rdflib-7.0.0
+
+
+
+[ ]:
+
+
+import jsonschema
+from jsonschema import validate
+import json
+import rdflib
+
+# Regular JSON representation of a person
+person_data = {
+ "@context": {
+ "schema": "https://schema.org/",
+ "firstName": "schema:givenName",
+ "lastName": "schema:lastName",
+ "birthdate": "schema:birthDate",
+ "institute": "schema:affiliation",
+ "name": "schema:name",
+ "street": "schema:streetAddress",
+ "city": "schema:locality",
+ "zip": "schema:postalCode"
+ },
+ "@id": "https://www.example.com/SimonClark",
+ "@type": "schema:Person",
+ "firstName": "Simon",
+ "lastName": "Clark",
+ "birthdate": "1987-04-23",
+ "institute": {
+ "@id": "https://www.example.com/SINTEF",
+ "@type": "schema:ResearchOrganization",
+ "name": "SINTEF",
+ "street": "Strindvegen 4",
+ "city": "Trondheim",
+ "zip": "7034"
+ }
+}
+
+
+
+In the JSON-LD example, we added an @context
that maps terms in our JSON data to their semantic meanings, using URIs (typically from established vocabularies, like schema.org). This allows machines to understand the semantics behind the data.
+
+[ ]:
+
+
+# Regular JSON representation of a person
+person_data = {
+ "@context": "https://schema.org/",
+ "@id": "https://orcid.org/0000-0002-8758-6109",
+ "@type": "Person",
+ "firstName": "Simon",
+ "lastName": "Clark",
+ "gender": {"@type": "Male"},
+ "birthDate": "1987-04-23",
+ "affiliation": {
+ "@id": "https://ror.org/01f677e56",
+ "@type": "ResearchOrganization"
+ }
+}
+
+# email to: simon.clark@sintef.no
+
+
+
+
+[ ]:
+
+
+person_schema = {
+ "type": "object",
+ "properties": {
+ "firstName": {
+ "type": "string"
+ },
+ "lastName": {
+ "type": "string",
+ "minLength": 1
+ },
+ "birthDate": { # Replacing age with birthdate
+ "type": "string",
+ "format": "date",
+ "pattern": "^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$"
+ },
+ "gender": {
+ "type": "object"
+ },
+ "affiliation": {
+ "type": "object"
+ }
+ },
+ "required": ["firstName", "lastName", "birthDate", "affiliation"] # Updated age to birthdate
+}
+
+# Function to validate JSON data against the schema
+def validate_json(data, schema):
+ try:
+ validate(instance=data, schema=schema)
+ return True, "JSON data is valid according to the schema."
+ except jsonschema.exceptions.ValidationError as ve:
+ return False, ve.message
+
+# Validate the sample JSON data
+is_valid, message = validate_json(person_data, person_schema)
+print(message)
+
+
+
+
+
+
+
+
+JSON data is valid according to the schema.
+
+
+
+[ ]:
+
+
+# Create a new graph
+g = rdflib.Graph()
+
+# Load schema.org vocabulary into the graph
+g.parse("https://schema.org/version/latest/schemaorg-current-http.jsonld", format="json-ld")
+
+person_data_str = json.dumps(person_data)
+g.parse(data=person_data_str, format="json-ld")
+
+# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX schema: <http://schema.org/>
+SELECT DISTINCT ?type WHERE {
+ ?type rdfs:subClassOf* schema:Organization .
+}
+LIMIT 20
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row)
+
+
+
+
+
+
+
+
+(rdflib.term.URIRef('http://schema.org/Organization'),)
+(rdflib.term.URIRef('http://schema.org/PerformingGroup'),)
+(rdflib.term.URIRef('http://schema.org/TheaterGroup'),)
+(rdflib.term.URIRef('http://schema.org/MusicGroup'),)
+(rdflib.term.URIRef('http://schema.org/DanceGroup'),)
+(rdflib.term.URIRef('http://schema.org/OnlineBusiness'),)
+(rdflib.term.URIRef('http://schema.org/OnlineStore'),)
+(rdflib.term.URIRef('http://schema.org/SportsOrganization'),)
+(rdflib.term.URIRef('http://schema.org/SportsTeam'),)
+(rdflib.term.URIRef('http://schema.org/Airline'),)
+(rdflib.term.URIRef('http://schema.org/SearchRescueOrganization'),)
+(rdflib.term.URIRef('http://schema.org/FundingScheme'),)
+(rdflib.term.URIRef('http://schema.org/NewsMediaOrganization'),)
+(rdflib.term.URIRef('http://schema.org/EducationalOrganization'),)
+(rdflib.term.URIRef('http://schema.org/CollegeOrUniversity'),)
+(rdflib.term.URIRef('http://schema.org/HighSchool'),)
+(rdflib.term.URIRef('http://schema.org/Preschool'),)
+(rdflib.term.URIRef('http://schema.org/ElementarySchool'),)
+(rdflib.term.URIRef('http://schema.org/MiddleSchool'),)
+(rdflib.term.URIRef('http://schema.org/School'),)
+
+
+
+[ ]:
+
+
+# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX schema: <http://schema.org/>
+
+SELECT ?instance WHERE {
+ ?subclass rdfs:subClassOf* schema:Organization .
+ ?instance rdf:type ?subclass .
+}
+LIMIT 10
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row[0])
+
+
+
+
+
+
+
+
+https://ror.org/01f677e56
+
+
+
+[ ]:
+
+
+# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX schema: <http://schema.org/>
+
+SELECT (COUNT(?subject) AS ?numMales) WHERE {
+ ?subject rdf:type schema:Person .
+ ?subject schema:gender ?gender .
+ ?gender rdf:type schema:Male .
+}
+LIMIT 10
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row.numMales)
+
+
+
+
+
+
+
+
+1
+
+
+
+[ ]:
+
+
+# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX schema: <http://schema.org/>
+
+SELECT ?bday WHERE {
+ ?subject rdf:type schema:Person .
+ ?subject schema:birthDate ?bday .
+}
+LIMIT 10
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row[0])
+
+
+
+
+
+
+
+
+1987-04-23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example_person_jsonld_nb.ipynb b/example_person_jsonld_nb.ipynb
new file mode 100644
index 0000000..d4afd14
--- /dev/null
+++ b/example_person_jsonld_nb.ipynb
@@ -0,0 +1,394 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "aw_lp5wfXRSl"
+ },
+ "source": [
+ "# JSON-LD Demonstration\n",
+ "\n",
+ "In this notebook, we will explore the principles of JSON-LD using the example of a person. JSON-LD stands for \"JSON for Linking Data\" and it provides a method to enrich your JSON data with semantics.\n",
+ "\n",
+ "An operational version of this notebook can be accessed [here](https://colab.research.google.com/drive/14XqRJPWs07RUQgZmDZEu3yb2m1xGvxEQ?usp=sharing)."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "y-aalpcNb223",
+ "outputId": "565a219c-1d10-4b55-fd75-a1fcb2257022"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Requirement already satisfied: jsonschema in /usr/local/lib/python3.10/dist-packages (4.19.0)\n",
+ "Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (23.1.0)\n",
+ "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (2023.7.1)\n",
+ "Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.30.2)\n",
+ "Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.10.2)\n",
+ "Collecting rdflib\n",
+ " Downloading rdflib-7.0.0-py3-none-any.whl (531 kB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m531.9/531.9 kB\u001b[0m \u001b[31m6.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hCollecting isodate<0.7.0,>=0.6.0 (from rdflib)\n",
+ " Downloading isodate-0.6.1-py2.py3-none-any.whl (41 kB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m41.7/41.7 kB\u001b[0m \u001b[31m4.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hRequirement already satisfied: pyparsing<4,>=2.1.0 in /usr/local/lib/python3.10/dist-packages (from rdflib) (3.1.1)\n",
+ "Requirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from isodate<0.7.0,>=0.6.0->rdflib) (1.16.0)\n",
+ "Installing collected packages: isodate, rdflib\n",
+ "Successfully installed isodate-0.6.1 rdflib-7.0.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Install the required library for JSON schema validation\n",
+ "!pip install jsonschema\n",
+ "!pip install rdflib"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "tNjkjGNEXJXP"
+ },
+ "outputs": [],
+ "source": [
+ "import jsonschema\n",
+ "from jsonschema import validate\n",
+ "import json\n",
+ "import rdflib\n",
+ "\n",
+ "# Regular JSON representation of a person\n",
+ "person_data = {\n",
+ " \"@context\": {\n",
+ " \"schema\": \"https://schema.org/\",\n",
+ " \"firstName\": \"schema:givenName\",\n",
+ " \"lastName\": \"schema:lastName\",\n",
+ " \"birthdate\": \"schema:birthDate\",\n",
+ " \"institute\": \"schema:affiliation\",\n",
+ " \"name\": \"schema:name\",\n",
+ " \"street\": \"schema:streetAddress\",\n",
+ " \"city\": \"schema:locality\",\n",
+ " \"zip\": \"schema:postalCode\"\n",
+ " },\n",
+ " \"@id\": \"https://www.example.com/SimonClark\",\n",
+ " \"@type\": \"schema:Person\",\n",
+ " \"firstName\": \"Simon\",\n",
+ " \"lastName\": \"Clark\",\n",
+ " \"birthdate\": \"1987-04-23\",\n",
+ " \"institute\": {\n",
+ " \"@id\": \"https://www.example.com/SINTEF\",\n",
+ " \"@type\": \"schema:ResearchOrganization\",\n",
+ " \"name\": \"SINTEF\",\n",
+ " \"street\": \"Strindvegen 4\",\n",
+ " \"city\": \"Trondheim\",\n",
+ " \"zip\": \"7034\"\n",
+ " }\n",
+ "}\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "K221MAoHa3Nx"
+ },
+ "source": [
+ "In the JSON-LD example, we added an `@context` that maps terms in our JSON data to their semantic meanings, using URIs (typically from established vocabularies, like schema.org). This allows machines to understand the semantics behind the data.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "ZmQfOeFyieo9"
+ },
+ "outputs": [],
+ "source": [
+ "# Regular JSON representation of a person\n",
+ "person_data = {\n",
+ " \"@context\": \"https://schema.org/\",\n",
+ " \"@id\": \"https://orcid.org/0000-0002-8758-6109\",\n",
+ " \"@type\": \"Person\",\n",
+ " \"firstName\": \"Simon\",\n",
+ " \"lastName\": \"Clark\",\n",
+ " \"gender\": {\"@type\": \"Male\"},\n",
+ " \"birthDate\": \"1987-04-23\",\n",
+ " \"affiliation\": {\n",
+ " \"@id\": \"https://ror.org/01f677e56\",\n",
+ " \"@type\": \"ResearchOrganization\"\n",
+ " }\n",
+ "}\n",
+ "\n",
+ "# email to: simon.clark@sintef.no"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "HDHJuV62bTby",
+ "outputId": "d5537f6e-4325-40ef-dfa4-c7d55159623f"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "JSON data is valid according to the schema.\n"
+ ]
+ }
+ ],
+ "source": [
+ "person_schema = {\n",
+ " \"type\": \"object\",\n",
+ " \"properties\": {\n",
+ " \"firstName\": {\n",
+ " \"type\": \"string\"\n",
+ " },\n",
+ " \"lastName\": {\n",
+ " \"type\": \"string\",\n",
+ " \"minLength\": 1\n",
+ " },\n",
+ " \"birthDate\": { # Replacing age with birthdate\n",
+ " \"type\": \"string\",\n",
+ " \"format\": \"date\",\n",
+ " \"pattern\": \"^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$\"\n",
+ " },\n",
+ " \"gender\": {\n",
+ " \"type\": \"object\"\n",
+ " },\n",
+ " \"affiliation\": {\n",
+ " \"type\": \"object\"\n",
+ " }\n",
+ " },\n",
+ " \"required\": [\"firstName\", \"lastName\", \"birthDate\", \"affiliation\"] # Updated age to birthdate\n",
+ "}\n",
+ "\n",
+ "# Function to validate JSON data against the schema\n",
+ "def validate_json(data, schema):\n",
+ " try:\n",
+ " validate(instance=data, schema=schema)\n",
+ " return True, \"JSON data is valid according to the schema.\"\n",
+ " except jsonschema.exceptions.ValidationError as ve:\n",
+ " return False, ve.message\n",
+ "\n",
+ "# Validate the sample JSON data\n",
+ "is_valid, message = validate_json(person_data, person_schema)\n",
+ "print(message)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "R-mO4FGtbr-L",
+ "outputId": "c0ae5e87-6ade-4ef8-a639-02bf287071a9"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "(rdflib.term.URIRef('http://schema.org/Organization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/PerformingGroup'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/TheaterGroup'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/MusicGroup'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/DanceGroup'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/OnlineBusiness'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/OnlineStore'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/SportsOrganization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/SportsTeam'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/Airline'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/SearchRescueOrganization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/FundingScheme'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/NewsMediaOrganization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/EducationalOrganization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/CollegeOrUniversity'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/HighSchool'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/Preschool'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/ElementarySchool'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/MiddleSchool'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/School'),)\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Create a new graph\n",
+ "g = rdflib.Graph()\n",
+ "\n",
+ "# Load schema.org vocabulary into the graph\n",
+ "g.parse(\"https://schema.org/version/latest/schemaorg-current-http.jsonld\", format=\"json-ld\")\n",
+ "\n",
+ "person_data_str = json.dumps(person_data)\n",
+ "g.parse(data=person_data_str, format=\"json-ld\")\n",
+ "\n",
+ "# Define and execute a SPARQL query for all instances of Organization\n",
+ "sparql_query = \"\"\"\n",
+ "PREFIX schema: \n",
+ "SELECT DISTINCT ?type WHERE {\n",
+ " ?type rdfs:subClassOf* schema:Organization .\n",
+ "}\n",
+ "LIMIT 20\n",
+ "\"\"\"\n",
+ "\n",
+ "# Execute the SPARQL query\n",
+ "results = g.query(sparql_query)\n",
+ "\n",
+ "# Print the results\n",
+ "for row in results:\n",
+ " print(row)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "h4vvw5hNhih2",
+ "outputId": "77828fc9-bafe-414b-f6f6-65fb117aabc5"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "https://ror.org/01f677e56\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Define and execute a SPARQL query for all instances of Organization\n",
+ "sparql_query = \"\"\"\n",
+ "PREFIX rdf: \n",
+ "PREFIX rdfs: \n",
+ "PREFIX schema: \n",
+ "\n",
+ "SELECT ?instance WHERE {\n",
+ " ?subclass rdfs:subClassOf* schema:Organization .\n",
+ " ?instance rdf:type ?subclass .\n",
+ "}\n",
+ "LIMIT 10\n",
+ "\"\"\"\n",
+ "\n",
+ "# Execute the SPARQL query\n",
+ "results = g.query(sparql_query)\n",
+ "\n",
+ "# Print the results\n",
+ "for row in results:\n",
+ " print(row[0])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "e_-Qa3Hgh2kg",
+ "outputId": "2b9fafa4-fca4-426f-e768-6ef561921b14"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "1\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Define and execute a SPARQL query for all instances of Organization\n",
+ "sparql_query = \"\"\"\n",
+ "PREFIX rdf: \n",
+ "PREFIX rdfs: \n",
+ "PREFIX schema: \n",
+ "\n",
+ "SELECT (COUNT(?subject) AS ?numMales) WHERE {\n",
+ " ?subject rdf:type schema:Person .\n",
+ " ?subject schema:gender ?gender .\n",
+ " ?gender rdf:type schema:Male .\n",
+ "}\n",
+ "LIMIT 10\n",
+ "\"\"\"\n",
+ "\n",
+ "# Execute the SPARQL query\n",
+ "results = g.query(sparql_query)\n",
+ "\n",
+ "# Print the results\n",
+ "for row in results:\n",
+ " print(row.numMales)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "HJfpCj4-sww3",
+ "outputId": "c4ba6b30-7d7e-45d9-c3e4-b0d311e0fdd0"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "1987-04-23\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Define and execute a SPARQL query for all instances of Organization\n",
+ "sparql_query = \"\"\"\n",
+ "PREFIX rdf: \n",
+ "PREFIX rdfs: \n",
+ "PREFIX schema: \n",
+ "\n",
+ "SELECT ?bday WHERE {\n",
+ " ?subject rdf:type schema:Person .\n",
+ " ?subject schema:birthDate ?bday .\n",
+ "}\n",
+ "LIMIT 10\n",
+ "\"\"\"\n",
+ "\n",
+ "# Execute the SPARQL query\n",
+ "results = g.query(sparql_query)\n",
+ "\n",
+ "# Print the results\n",
+ "for row in results:\n",
+ " print(row[0])"
+ ]
+ }
+ ],
+ "metadata": {
+ "colab": {
+ "provenance": []
+ },
+ "kernelspec": {
+ "display_name": "Python 3",
+ "name": "python3"
+ },
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/example_zinc_electrode.html b/example_zinc_electrode.html
index afe7b5f..f25d9a7 100644
--- a/example_zinc_electrode.html
+++ b/example_zinc_electrode.html
@@ -44,6 +44,7 @@
+
@@ -483,7 +484,7 @@ Zinc Electrode
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_zinc_powder.html b/example_zinc_powder.html
index 4823d3d..b648375 100644
--- a/example_zinc_powder.html
+++ b/example_zinc_powder.html
@@ -44,6 +44,7 @@
+
@@ -455,7 +456,7 @@ Zinc Powder
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/examples.html b/examples.html
index 23566c8..702f9b4 100644
--- a/examples.html
+++ b/examples.html
@@ -44,6 +44,7 @@
+
@@ -506,7 +507,7 @@ Examples
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/faq.html b/faq.html
index cfb115a..704305a 100644
--- a/faq.html
+++ b/faq.html
@@ -44,12 +44,13 @@
+
-
+
@@ -406,12 +407,12 @@ FAQ Page
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
Cyclic Voltammetry Data
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_eis_nyquist.html b/example_eis_nyquist.html
index 024f9d1..dbea6be 100644
--- a/example_eis_nyquist.html
+++ b/example_eis_nyquist.html
@@ -44,6 +44,7 @@
+
@@ -492,7 +493,7 @@ Cyclic Voltammetry Data
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_person_jsonld_nb.html b/example_person_jsonld_nb.html
new file mode 100644
index 0000000..e7758d8
--- /dev/null
+++ b/example_person_jsonld_nb.html
@@ -0,0 +1,791 @@
+
+
+
+
+
+
+
+
+
+
+
+ JSON-LD Demonstration — BattInfo documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Skip to main content
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+JSON-LD Demonstration#
+In this notebook, we will explore the principles of JSON-LD using the example of a person. JSON-LD stands for “JSON for Linking Data” and it provides a method to enrich your JSON data with semantics.
+An operational version of this notebook can be accessed here.
+
+[ ]:
+
+
+# Install the required library for JSON schema validation
+!pip install jsonschema
+!pip install rdflib
+
+
+
+
+
+
+
+
+Requirement already satisfied: jsonschema in /usr/local/lib/python3.10/dist-packages (4.19.0)
+Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (23.1.0)
+Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (2023.7.1)
+Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.30.2)
+Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.10.2)
+Collecting rdflib
+ Downloading rdflib-7.0.0-py3-none-any.whl (531 kB)
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 531.9/531.9 kB 6.6 MB/s eta 0:00:00
+Collecting isodate<0.7.0,>=0.6.0 (from rdflib)
+ Downloading isodate-0.6.1-py2.py3-none-any.whl (41 kB)
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.7/41.7 kB 4.3 MB/s eta 0:00:00
+Requirement already satisfied: pyparsing<4,>=2.1.0 in /usr/local/lib/python3.10/dist-packages (from rdflib) (3.1.1)
+Requirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from isodate<0.7.0,>=0.6.0->rdflib) (1.16.0)
+Installing collected packages: isodate, rdflib
+Successfully installed isodate-0.6.1 rdflib-7.0.0
+
+
+
+[ ]:
+
+
+import jsonschema
+from jsonschema import validate
+import json
+import rdflib
+
+# Regular JSON representation of a person
+person_data = {
+ "@context": {
+ "schema": "https://schema.org/",
+ "firstName": "schema:givenName",
+ "lastName": "schema:lastName",
+ "birthdate": "schema:birthDate",
+ "institute": "schema:affiliation",
+ "name": "schema:name",
+ "street": "schema:streetAddress",
+ "city": "schema:locality",
+ "zip": "schema:postalCode"
+ },
+ "@id": "https://www.example.com/SimonClark",
+ "@type": "schema:Person",
+ "firstName": "Simon",
+ "lastName": "Clark",
+ "birthdate": "1987-04-23",
+ "institute": {
+ "@id": "https://www.example.com/SINTEF",
+ "@type": "schema:ResearchOrganization",
+ "name": "SINTEF",
+ "street": "Strindvegen 4",
+ "city": "Trondheim",
+ "zip": "7034"
+ }
+}
+
+
+
+In the JSON-LD example, we added an @context
that maps terms in our JSON data to their semantic meanings, using URIs (typically from established vocabularies, like schema.org). This allows machines to understand the semantics behind the data.
+
+[ ]:
+
+
+# Regular JSON representation of a person
+person_data = {
+ "@context": "https://schema.org/",
+ "@id": "https://orcid.org/0000-0002-8758-6109",
+ "@type": "Person",
+ "firstName": "Simon",
+ "lastName": "Clark",
+ "gender": {"@type": "Male"},
+ "birthDate": "1987-04-23",
+ "affiliation": {
+ "@id": "https://ror.org/01f677e56",
+ "@type": "ResearchOrganization"
+ }
+}
+
+# email to: simon.clark@sintef.no
+
+
+
+
+[ ]:
+
+
+person_schema = {
+ "type": "object",
+ "properties": {
+ "firstName": {
+ "type": "string"
+ },
+ "lastName": {
+ "type": "string",
+ "minLength": 1
+ },
+ "birthDate": { # Replacing age with birthdate
+ "type": "string",
+ "format": "date",
+ "pattern": "^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$"
+ },
+ "gender": {
+ "type": "object"
+ },
+ "affiliation": {
+ "type": "object"
+ }
+ },
+ "required": ["firstName", "lastName", "birthDate", "affiliation"] # Updated age to birthdate
+}
+
+# Function to validate JSON data against the schema
+def validate_json(data, schema):
+ try:
+ validate(instance=data, schema=schema)
+ return True, "JSON data is valid according to the schema."
+ except jsonschema.exceptions.ValidationError as ve:
+ return False, ve.message
+
+# Validate the sample JSON data
+is_valid, message = validate_json(person_data, person_schema)
+print(message)
+
+
+
+
+
+
+
+
+JSON data is valid according to the schema.
+
+
+
+[ ]:
+
+
+# Create a new graph
+g = rdflib.Graph()
+
+# Load schema.org vocabulary into the graph
+g.parse("https://schema.org/version/latest/schemaorg-current-http.jsonld", format="json-ld")
+
+person_data_str = json.dumps(person_data)
+g.parse(data=person_data_str, format="json-ld")
+
+# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX schema: <http://schema.org/>
+SELECT DISTINCT ?type WHERE {
+ ?type rdfs:subClassOf* schema:Organization .
+}
+LIMIT 20
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row)
+
+
+
+
+
+
+
+
+(rdflib.term.URIRef('http://schema.org/Organization'),)
+(rdflib.term.URIRef('http://schema.org/PerformingGroup'),)
+(rdflib.term.URIRef('http://schema.org/TheaterGroup'),)
+(rdflib.term.URIRef('http://schema.org/MusicGroup'),)
+(rdflib.term.URIRef('http://schema.org/DanceGroup'),)
+(rdflib.term.URIRef('http://schema.org/OnlineBusiness'),)
+(rdflib.term.URIRef('http://schema.org/OnlineStore'),)
+(rdflib.term.URIRef('http://schema.org/SportsOrganization'),)
+(rdflib.term.URIRef('http://schema.org/SportsTeam'),)
+(rdflib.term.URIRef('http://schema.org/Airline'),)
+(rdflib.term.URIRef('http://schema.org/SearchRescueOrganization'),)
+(rdflib.term.URIRef('http://schema.org/FundingScheme'),)
+(rdflib.term.URIRef('http://schema.org/NewsMediaOrganization'),)
+(rdflib.term.URIRef('http://schema.org/EducationalOrganization'),)
+(rdflib.term.URIRef('http://schema.org/CollegeOrUniversity'),)
+(rdflib.term.URIRef('http://schema.org/HighSchool'),)
+(rdflib.term.URIRef('http://schema.org/Preschool'),)
+(rdflib.term.URIRef('http://schema.org/ElementarySchool'),)
+(rdflib.term.URIRef('http://schema.org/MiddleSchool'),)
+(rdflib.term.URIRef('http://schema.org/School'),)
+
+
+
+[ ]:
+
+
+# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX schema: <http://schema.org/>
+
+SELECT ?instance WHERE {
+ ?subclass rdfs:subClassOf* schema:Organization .
+ ?instance rdf:type ?subclass .
+}
+LIMIT 10
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row[0])
+
+
+
+
+
+
+
+
+https://ror.org/01f677e56
+
+
+
+[ ]:
+
+
+# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX schema: <http://schema.org/>
+
+SELECT (COUNT(?subject) AS ?numMales) WHERE {
+ ?subject rdf:type schema:Person .
+ ?subject schema:gender ?gender .
+ ?gender rdf:type schema:Male .
+}
+LIMIT 10
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row.numMales)
+
+
+
+
+
+
+
+
+1
+
+
+
+[ ]:
+
+
+# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX schema: <http://schema.org/>
+
+SELECT ?bday WHERE {
+ ?subject rdf:type schema:Person .
+ ?subject schema:birthDate ?bday .
+}
+LIMIT 10
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row[0])
+
+
+
+
+
+
+
+
+1987-04-23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example_person_jsonld_nb.ipynb b/example_person_jsonld_nb.ipynb
new file mode 100644
index 0000000..d4afd14
--- /dev/null
+++ b/example_person_jsonld_nb.ipynb
@@ -0,0 +1,394 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "aw_lp5wfXRSl"
+ },
+ "source": [
+ "# JSON-LD Demonstration\n",
+ "\n",
+ "In this notebook, we will explore the principles of JSON-LD using the example of a person. JSON-LD stands for \"JSON for Linking Data\" and it provides a method to enrich your JSON data with semantics.\n",
+ "\n",
+ "An operational version of this notebook can be accessed [here](https://colab.research.google.com/drive/14XqRJPWs07RUQgZmDZEu3yb2m1xGvxEQ?usp=sharing)."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "y-aalpcNb223",
+ "outputId": "565a219c-1d10-4b55-fd75-a1fcb2257022"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Requirement already satisfied: jsonschema in /usr/local/lib/python3.10/dist-packages (4.19.0)\n",
+ "Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (23.1.0)\n",
+ "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (2023.7.1)\n",
+ "Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.30.2)\n",
+ "Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.10.2)\n",
+ "Collecting rdflib\n",
+ " Downloading rdflib-7.0.0-py3-none-any.whl (531 kB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m531.9/531.9 kB\u001b[0m \u001b[31m6.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hCollecting isodate<0.7.0,>=0.6.0 (from rdflib)\n",
+ " Downloading isodate-0.6.1-py2.py3-none-any.whl (41 kB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m41.7/41.7 kB\u001b[0m \u001b[31m4.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hRequirement already satisfied: pyparsing<4,>=2.1.0 in /usr/local/lib/python3.10/dist-packages (from rdflib) (3.1.1)\n",
+ "Requirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from isodate<0.7.0,>=0.6.0->rdflib) (1.16.0)\n",
+ "Installing collected packages: isodate, rdflib\n",
+ "Successfully installed isodate-0.6.1 rdflib-7.0.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Install the required library for JSON schema validation\n",
+ "!pip install jsonschema\n",
+ "!pip install rdflib"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "tNjkjGNEXJXP"
+ },
+ "outputs": [],
+ "source": [
+ "import jsonschema\n",
+ "from jsonschema import validate\n",
+ "import json\n",
+ "import rdflib\n",
+ "\n",
+ "# Regular JSON representation of a person\n",
+ "person_data = {\n",
+ " \"@context\": {\n",
+ " \"schema\": \"https://schema.org/\",\n",
+ " \"firstName\": \"schema:givenName\",\n",
+ " \"lastName\": \"schema:lastName\",\n",
+ " \"birthdate\": \"schema:birthDate\",\n",
+ " \"institute\": \"schema:affiliation\",\n",
+ " \"name\": \"schema:name\",\n",
+ " \"street\": \"schema:streetAddress\",\n",
+ " \"city\": \"schema:locality\",\n",
+ " \"zip\": \"schema:postalCode\"\n",
+ " },\n",
+ " \"@id\": \"https://www.example.com/SimonClark\",\n",
+ " \"@type\": \"schema:Person\",\n",
+ " \"firstName\": \"Simon\",\n",
+ " \"lastName\": \"Clark\",\n",
+ " \"birthdate\": \"1987-04-23\",\n",
+ " \"institute\": {\n",
+ " \"@id\": \"https://www.example.com/SINTEF\",\n",
+ " \"@type\": \"schema:ResearchOrganization\",\n",
+ " \"name\": \"SINTEF\",\n",
+ " \"street\": \"Strindvegen 4\",\n",
+ " \"city\": \"Trondheim\",\n",
+ " \"zip\": \"7034\"\n",
+ " }\n",
+ "}\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "K221MAoHa3Nx"
+ },
+ "source": [
+ "In the JSON-LD example, we added an `@context` that maps terms in our JSON data to their semantic meanings, using URIs (typically from established vocabularies, like schema.org). This allows machines to understand the semantics behind the data.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "ZmQfOeFyieo9"
+ },
+ "outputs": [],
+ "source": [
+ "# Regular JSON representation of a person\n",
+ "person_data = {\n",
+ " \"@context\": \"https://schema.org/\",\n",
+ " \"@id\": \"https://orcid.org/0000-0002-8758-6109\",\n",
+ " \"@type\": \"Person\",\n",
+ " \"firstName\": \"Simon\",\n",
+ " \"lastName\": \"Clark\",\n",
+ " \"gender\": {\"@type\": \"Male\"},\n",
+ " \"birthDate\": \"1987-04-23\",\n",
+ " \"affiliation\": {\n",
+ " \"@id\": \"https://ror.org/01f677e56\",\n",
+ " \"@type\": \"ResearchOrganization\"\n",
+ " }\n",
+ "}\n",
+ "\n",
+ "# email to: simon.clark@sintef.no"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "HDHJuV62bTby",
+ "outputId": "d5537f6e-4325-40ef-dfa4-c7d55159623f"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "JSON data is valid according to the schema.\n"
+ ]
+ }
+ ],
+ "source": [
+ "person_schema = {\n",
+ " \"type\": \"object\",\n",
+ " \"properties\": {\n",
+ " \"firstName\": {\n",
+ " \"type\": \"string\"\n",
+ " },\n",
+ " \"lastName\": {\n",
+ " \"type\": \"string\",\n",
+ " \"minLength\": 1\n",
+ " },\n",
+ " \"birthDate\": { # Replacing age with birthdate\n",
+ " \"type\": \"string\",\n",
+ " \"format\": \"date\",\n",
+ " \"pattern\": \"^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$\"\n",
+ " },\n",
+ " \"gender\": {\n",
+ " \"type\": \"object\"\n",
+ " },\n",
+ " \"affiliation\": {\n",
+ " \"type\": \"object\"\n",
+ " }\n",
+ " },\n",
+ " \"required\": [\"firstName\", \"lastName\", \"birthDate\", \"affiliation\"] # Updated age to birthdate\n",
+ "}\n",
+ "\n",
+ "# Function to validate JSON data against the schema\n",
+ "def validate_json(data, schema):\n",
+ " try:\n",
+ " validate(instance=data, schema=schema)\n",
+ " return True, \"JSON data is valid according to the schema.\"\n",
+ " except jsonschema.exceptions.ValidationError as ve:\n",
+ " return False, ve.message\n",
+ "\n",
+ "# Validate the sample JSON data\n",
+ "is_valid, message = validate_json(person_data, person_schema)\n",
+ "print(message)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "R-mO4FGtbr-L",
+ "outputId": "c0ae5e87-6ade-4ef8-a639-02bf287071a9"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "(rdflib.term.URIRef('http://schema.org/Organization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/PerformingGroup'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/TheaterGroup'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/MusicGroup'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/DanceGroup'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/OnlineBusiness'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/OnlineStore'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/SportsOrganization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/SportsTeam'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/Airline'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/SearchRescueOrganization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/FundingScheme'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/NewsMediaOrganization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/EducationalOrganization'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/CollegeOrUniversity'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/HighSchool'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/Preschool'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/ElementarySchool'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/MiddleSchool'),)\n",
+ "(rdflib.term.URIRef('http://schema.org/School'),)\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Create a new graph\n",
+ "g = rdflib.Graph()\n",
+ "\n",
+ "# Load schema.org vocabulary into the graph\n",
+ "g.parse(\"https://schema.org/version/latest/schemaorg-current-http.jsonld\", format=\"json-ld\")\n",
+ "\n",
+ "person_data_str = json.dumps(person_data)\n",
+ "g.parse(data=person_data_str, format=\"json-ld\")\n",
+ "\n",
+ "# Define and execute a SPARQL query for all instances of Organization\n",
+ "sparql_query = \"\"\"\n",
+ "PREFIX schema: \n",
+ "SELECT DISTINCT ?type WHERE {\n",
+ " ?type rdfs:subClassOf* schema:Organization .\n",
+ "}\n",
+ "LIMIT 20\n",
+ "\"\"\"\n",
+ "\n",
+ "# Execute the SPARQL query\n",
+ "results = g.query(sparql_query)\n",
+ "\n",
+ "# Print the results\n",
+ "for row in results:\n",
+ " print(row)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "h4vvw5hNhih2",
+ "outputId": "77828fc9-bafe-414b-f6f6-65fb117aabc5"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "https://ror.org/01f677e56\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Define and execute a SPARQL query for all instances of Organization\n",
+ "sparql_query = \"\"\"\n",
+ "PREFIX rdf: \n",
+ "PREFIX rdfs: \n",
+ "PREFIX schema: \n",
+ "\n",
+ "SELECT ?instance WHERE {\n",
+ " ?subclass rdfs:subClassOf* schema:Organization .\n",
+ " ?instance rdf:type ?subclass .\n",
+ "}\n",
+ "LIMIT 10\n",
+ "\"\"\"\n",
+ "\n",
+ "# Execute the SPARQL query\n",
+ "results = g.query(sparql_query)\n",
+ "\n",
+ "# Print the results\n",
+ "for row in results:\n",
+ " print(row[0])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "e_-Qa3Hgh2kg",
+ "outputId": "2b9fafa4-fca4-426f-e768-6ef561921b14"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "1\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Define and execute a SPARQL query for all instances of Organization\n",
+ "sparql_query = \"\"\"\n",
+ "PREFIX rdf: \n",
+ "PREFIX rdfs: \n",
+ "PREFIX schema: \n",
+ "\n",
+ "SELECT (COUNT(?subject) AS ?numMales) WHERE {\n",
+ " ?subject rdf:type schema:Person .\n",
+ " ?subject schema:gender ?gender .\n",
+ " ?gender rdf:type schema:Male .\n",
+ "}\n",
+ "LIMIT 10\n",
+ "\"\"\"\n",
+ "\n",
+ "# Execute the SPARQL query\n",
+ "results = g.query(sparql_query)\n",
+ "\n",
+ "# Print the results\n",
+ "for row in results:\n",
+ " print(row.numMales)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "HJfpCj4-sww3",
+ "outputId": "c4ba6b30-7d7e-45d9-c3e4-b0d311e0fdd0"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "1987-04-23\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Define and execute a SPARQL query for all instances of Organization\n",
+ "sparql_query = \"\"\"\n",
+ "PREFIX rdf: \n",
+ "PREFIX rdfs: \n",
+ "PREFIX schema: \n",
+ "\n",
+ "SELECT ?bday WHERE {\n",
+ " ?subject rdf:type schema:Person .\n",
+ " ?subject schema:birthDate ?bday .\n",
+ "}\n",
+ "LIMIT 10\n",
+ "\"\"\"\n",
+ "\n",
+ "# Execute the SPARQL query\n",
+ "results = g.query(sparql_query)\n",
+ "\n",
+ "# Print the results\n",
+ "for row in results:\n",
+ " print(row[0])"
+ ]
+ }
+ ],
+ "metadata": {
+ "colab": {
+ "provenance": []
+ },
+ "kernelspec": {
+ "display_name": "Python 3",
+ "name": "python3"
+ },
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/example_zinc_electrode.html b/example_zinc_electrode.html
index afe7b5f..f25d9a7 100644
--- a/example_zinc_electrode.html
+++ b/example_zinc_electrode.html
@@ -44,6 +44,7 @@
+
@@ -483,7 +484,7 @@ Zinc Electrode
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_zinc_powder.html b/example_zinc_powder.html
index 4823d3d..b648375 100644
--- a/example_zinc_powder.html
+++ b/example_zinc_powder.html
@@ -44,6 +44,7 @@
+
@@ -455,7 +456,7 @@ Zinc Powder
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/examples.html b/examples.html
index 23566c8..702f9b4 100644
--- a/examples.html
+++ b/examples.html
@@ -44,6 +44,7 @@
+
@@ -506,7 +507,7 @@ Examples
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/faq.html b/faq.html
index cfb115a..704305a 100644
--- a/faq.html
+++ b/faq.html
@@ -44,12 +44,13 @@
+
-
+
@@ -406,12 +407,12 @@ FAQ Page
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
JSON-LD Demonstration#
+In this notebook, we will explore the principles of JSON-LD using the example of a person. JSON-LD stands for “JSON for Linking Data” and it provides a method to enrich your JSON data with semantics.
+An operational version of this notebook can be accessed here.
+[ ]:
+
# Install the required library for JSON schema validation
+!pip install jsonschema
+!pip install rdflib
+
+Requirement already satisfied: jsonschema in /usr/local/lib/python3.10/dist-packages (4.19.0)
+Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (23.1.0)
+Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (2023.7.1)
+Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.30.2)
+Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema) (0.10.2)
+Collecting rdflib
+ Downloading rdflib-7.0.0-py3-none-any.whl (531 kB)
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 531.9/531.9 kB 6.6 MB/s eta 0:00:00
+Collecting isodate<0.7.0,>=0.6.0 (from rdflib)
+ Downloading isodate-0.6.1-py2.py3-none-any.whl (41 kB)
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.7/41.7 kB 4.3 MB/s eta 0:00:00
+Requirement already satisfied: pyparsing<4,>=2.1.0 in /usr/local/lib/python3.10/dist-packages (from rdflib) (3.1.1)
+Requirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from isodate<0.7.0,>=0.6.0->rdflib) (1.16.0)
+Installing collected packages: isodate, rdflib
+Successfully installed isodate-0.6.1 rdflib-7.0.0
+
[ ]:
+
import jsonschema
+from jsonschema import validate
+import json
+import rdflib
+
+# Regular JSON representation of a person
+person_data = {
+ "@context": {
+ "schema": "https://schema.org/",
+ "firstName": "schema:givenName",
+ "lastName": "schema:lastName",
+ "birthdate": "schema:birthDate",
+ "institute": "schema:affiliation",
+ "name": "schema:name",
+ "street": "schema:streetAddress",
+ "city": "schema:locality",
+ "zip": "schema:postalCode"
+ },
+ "@id": "https://www.example.com/SimonClark",
+ "@type": "schema:Person",
+ "firstName": "Simon",
+ "lastName": "Clark",
+ "birthdate": "1987-04-23",
+ "institute": {
+ "@id": "https://www.example.com/SINTEF",
+ "@type": "schema:ResearchOrganization",
+ "name": "SINTEF",
+ "street": "Strindvegen 4",
+ "city": "Trondheim",
+ "zip": "7034"
+ }
+}
+
In the JSON-LD example, we added an @context
that maps terms in our JSON data to their semantic meanings, using URIs (typically from established vocabularies, like schema.org). This allows machines to understand the semantics behind the data.
[ ]:
+
# Regular JSON representation of a person
+person_data = {
+ "@context": "https://schema.org/",
+ "@id": "https://orcid.org/0000-0002-8758-6109",
+ "@type": "Person",
+ "firstName": "Simon",
+ "lastName": "Clark",
+ "gender": {"@type": "Male"},
+ "birthDate": "1987-04-23",
+ "affiliation": {
+ "@id": "https://ror.org/01f677e56",
+ "@type": "ResearchOrganization"
+ }
+}
+
+# email to: simon.clark@sintef.no
+
[ ]:
+
person_schema = {
+ "type": "object",
+ "properties": {
+ "firstName": {
+ "type": "string"
+ },
+ "lastName": {
+ "type": "string",
+ "minLength": 1
+ },
+ "birthDate": { # Replacing age with birthdate
+ "type": "string",
+ "format": "date",
+ "pattern": "^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$"
+ },
+ "gender": {
+ "type": "object"
+ },
+ "affiliation": {
+ "type": "object"
+ }
+ },
+ "required": ["firstName", "lastName", "birthDate", "affiliation"] # Updated age to birthdate
+}
+
+# Function to validate JSON data against the schema
+def validate_json(data, schema):
+ try:
+ validate(instance=data, schema=schema)
+ return True, "JSON data is valid according to the schema."
+ except jsonschema.exceptions.ValidationError as ve:
+ return False, ve.message
+
+# Validate the sample JSON data
+is_valid, message = validate_json(person_data, person_schema)
+print(message)
+
+JSON data is valid according to the schema.
+
[ ]:
+
# Create a new graph
+g = rdflib.Graph()
+
+# Load schema.org vocabulary into the graph
+g.parse("https://schema.org/version/latest/schemaorg-current-http.jsonld", format="json-ld")
+
+person_data_str = json.dumps(person_data)
+g.parse(data=person_data_str, format="json-ld")
+
+# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX schema: <http://schema.org/>
+SELECT DISTINCT ?type WHERE {
+ ?type rdfs:subClassOf* schema:Organization .
+}
+LIMIT 20
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row)
+
+(rdflib.term.URIRef('http://schema.org/Organization'),)
+(rdflib.term.URIRef('http://schema.org/PerformingGroup'),)
+(rdflib.term.URIRef('http://schema.org/TheaterGroup'),)
+(rdflib.term.URIRef('http://schema.org/MusicGroup'),)
+(rdflib.term.URIRef('http://schema.org/DanceGroup'),)
+(rdflib.term.URIRef('http://schema.org/OnlineBusiness'),)
+(rdflib.term.URIRef('http://schema.org/OnlineStore'),)
+(rdflib.term.URIRef('http://schema.org/SportsOrganization'),)
+(rdflib.term.URIRef('http://schema.org/SportsTeam'),)
+(rdflib.term.URIRef('http://schema.org/Airline'),)
+(rdflib.term.URIRef('http://schema.org/SearchRescueOrganization'),)
+(rdflib.term.URIRef('http://schema.org/FundingScheme'),)
+(rdflib.term.URIRef('http://schema.org/NewsMediaOrganization'),)
+(rdflib.term.URIRef('http://schema.org/EducationalOrganization'),)
+(rdflib.term.URIRef('http://schema.org/CollegeOrUniversity'),)
+(rdflib.term.URIRef('http://schema.org/HighSchool'),)
+(rdflib.term.URIRef('http://schema.org/Preschool'),)
+(rdflib.term.URIRef('http://schema.org/ElementarySchool'),)
+(rdflib.term.URIRef('http://schema.org/MiddleSchool'),)
+(rdflib.term.URIRef('http://schema.org/School'),)
+
[ ]:
+
# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX schema: <http://schema.org/>
+
+SELECT ?instance WHERE {
+ ?subclass rdfs:subClassOf* schema:Organization .
+ ?instance rdf:type ?subclass .
+}
+LIMIT 10
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row[0])
+
+https://ror.org/01f677e56
+
[ ]:
+
# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX schema: <http://schema.org/>
+
+SELECT (COUNT(?subject) AS ?numMales) WHERE {
+ ?subject rdf:type schema:Person .
+ ?subject schema:gender ?gender .
+ ?gender rdf:type schema:Male .
+}
+LIMIT 10
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row.numMales)
+
+1
+
[ ]:
+
# Define and execute a SPARQL query for all instances of Organization
+sparql_query = """
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX schema: <http://schema.org/>
+
+SELECT ?bday WHERE {
+ ?subject rdf:type schema:Person .
+ ?subject schema:birthDate ?bday .
+}
+LIMIT 10
+"""
+
+# Execute the SPARQL query
+results = g.query(sparql_query)
+
+# Print the results
+for row in results:
+ print(row[0])
+
+1987-04-23
+
Zinc Electrode
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/example_zinc_powder.html b/example_zinc_powder.html
index 4823d3d..b648375 100644
--- a/example_zinc_powder.html
+++ b/example_zinc_powder.html
@@ -44,6 +44,7 @@
+
@@ -455,7 +456,7 @@ Zinc Powder
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/examples.html b/examples.html
index 23566c8..702f9b4 100644
--- a/examples.html
+++ b/examples.html
@@ -44,6 +44,7 @@
+
@@ -506,7 +507,7 @@ Examples
- © Copyright 2021-2023.
+ © Copyright 2021-2024.
diff --git a/faq.html b/faq.html
index cfb115a..704305a 100644
--- a/faq.html
+++ b/faq.html
@@ -44,12 +44,13 @@
+
-
+
@@ -406,12 +407,12 @@ FAQ Page
- © Copyright 2021-2023.
+ © Copyright 2021-2024.