added basic .ttl file
parent
eeb1fe8b4a
commit
110904af17
|
|
@ -0,0 +1,3 @@
|
||||||
|
### Autobahn Knowledge Graph
|
||||||
|
|
||||||
|
- Achtung bei der Neuabfrage der Daten der String der A60 ist mit einem Leerzeichen als Suffix abgelegt "A60 ".
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,132 @@
|
||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 78,
|
||||||
|
"id": "3d4827d9",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from rdflib import Graph, URIRef, Literal, Namespace\n",
|
||||||
|
"from rdflib.namespace import RDF, RDFS, XSD, GEO\n",
|
||||||
|
"import json\n",
|
||||||
|
"\n",
|
||||||
|
"g = Graph()\n",
|
||||||
|
"thm = Namespace(\"https://th-mannheim.de/\")\n",
|
||||||
|
"thm_ont = Namespace(\"https://th-mannheim.de/ont/\")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 79,
|
||||||
|
"id": "80c6fad0",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def open_json(name : str):\n",
|
||||||
|
" with open(name, mode=\"r\", encoding=\"utf8\") as jsonfile:\n",
|
||||||
|
" return json.loads(jsonfile.read())"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 80,
|
||||||
|
"id": "21dac562",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"roads = open_json(\"data/autobahn.json\")\n",
|
||||||
|
"chargings = open_json(\"data/chargingstations.json\")\n",
|
||||||
|
"parkings = open_json(\"data/parkinglorries.json\")\n",
|
||||||
|
"roadworks = open_json(\"data/roadworks.json\")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 81,
|
||||||
|
"id": "cecd4a23",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"autobahn_urls = {}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "72ac9b11",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"for autobahn in roads[\"roads\"]:\n",
|
||||||
|
" autobahn_url = thm[f\"autobahn/{autobahn}\"]\n",
|
||||||
|
" autobahn_urls[autobahn] = autobahn_url\n",
|
||||||
|
"\n",
|
||||||
|
" for parking in parkings[autobahn][\"parking_lorry\"]:\n",
|
||||||
|
"\n",
|
||||||
|
" parking_url = thm[f\"parkings/{parking[\"identifier\"]}\"]\n",
|
||||||
|
" geometry_url = thm_ont[f\"geometry/{parking[\"identifier\"]}\"]\n",
|
||||||
|
"\n",
|
||||||
|
" # Grundlegende Daten\n",
|
||||||
|
" g.add((parking_url, RDF.type, thm_ont.Parking))\n",
|
||||||
|
" g.add((parking_url, thm_ont.title, Literal(parking[\"title\"], lang=\"de\")))\n",
|
||||||
|
" g.add((parking_url, thm_ont.subtitle, Literal(parking[\"subtitle\"], lang=\"de\")))\n",
|
||||||
|
" g.add((parking_url, thm_ont.description, Literal(parking[\"subtitle\"], lang=\"de\")))\n",
|
||||||
|
"\n",
|
||||||
|
" # Zuordnung zur Autobahn\n",
|
||||||
|
" g.add((parking_url, thm.belongs, autobahn_urls[autobahn]))\n",
|
||||||
|
"\n",
|
||||||
|
" # Koordinaten\n",
|
||||||
|
" g.add((parking_url, GEO.hasGeometry, geometry_url))\n",
|
||||||
|
" g.add((parking_url, GEO.asWKT, Literal(f\"POINT({parking[\"coordinate\"][\"long\"]} {parking[\"coordinate\"][\"lat\"]})\", datatype=GEO.wktLiteratl)))\n",
|
||||||
|
"\n",
|
||||||
|
" # Zusätzliche Features (wenn mal Zeit ist \n",
|
||||||
|
" # kann man die auch in Objekte überführen, anstatt Literale zu verwenden)\n",
|
||||||
|
" for features in parking[\"lorryParkingFeatureIcons\"]:\n",
|
||||||
|
" g.add((parking_url, thm_ont.has_feature, Literal(features[\"description\"], lang=\"de\")))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 83,
|
||||||
|
"id": "a8ae8a6f",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"<Graph identifier=Nfd9dbadf281b46dbbae0fa147c9bb242 (<class 'rdflib.graph.Graph'>)>"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 83,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"g.serialize(\"autobahn.ttl\", format=\"turtle\")"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "venv (3.14.4)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.14.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,340 @@
|
||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "50d618ab-93a9-4b52-a7ed-6ff74d3298fc",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# Knowledge Graphs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "860a67d8-30cc-493d-a343-7e6436afd557",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## Data"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 7,
|
||||||
|
"id": "a45c467f-39de-4510-80e8-bbd597f78160",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"city_source = [\n",
|
||||||
|
" {\n",
|
||||||
|
" \"name\": \"Mannheim\",\n",
|
||||||
|
" \"lat\": 49.4891,\n",
|
||||||
|
" \"long\": 8.4673,\n",
|
||||||
|
" \"einwohner\": 318035\n",
|
||||||
|
" },\n",
|
||||||
|
" {\n",
|
||||||
|
" \"name\": \"Berlin\",\n",
|
||||||
|
" \"lat\": 52.52,\n",
|
||||||
|
" \"long\": 13.405,\n",
|
||||||
|
" \"einwohner\": 3850809 \n",
|
||||||
|
" },\n",
|
||||||
|
" {\n",
|
||||||
|
" \"name\": \"Ulm\",\n",
|
||||||
|
" \"lat\": 48.4,\n",
|
||||||
|
" \"long\": 9.983,\n",
|
||||||
|
" \"einwohner\": 129882\n",
|
||||||
|
" }\n",
|
||||||
|
"]\n",
|
||||||
|
"\n",
|
||||||
|
"person_source = [\n",
|
||||||
|
" {\n",
|
||||||
|
" \"name\": \"Peter\",\n",
|
||||||
|
" \"alter\": 25,\n",
|
||||||
|
" \"hobbies\": [\"Sport\", \"Musik\", \"PC Spiele\"],\n",
|
||||||
|
" \"stadt\": \"Mannheim\",\n",
|
||||||
|
" },\n",
|
||||||
|
" {\n",
|
||||||
|
" \"name\": \"Petra\",\n",
|
||||||
|
" \"alter\": 23,\n",
|
||||||
|
" \"hobbies\": [\"Sport\", \"Lesen\", \"Zocken\"],\n",
|
||||||
|
" \"stadt\": \"Mannheim\",\n",
|
||||||
|
" },\n",
|
||||||
|
" {\n",
|
||||||
|
" \"name\": \"Gustav\",\n",
|
||||||
|
" \"alter\": 30,\n",
|
||||||
|
" \"hobbies\": [\"Auto\", \"Lesen\", \"Gartenarbeit\"],\n",
|
||||||
|
" \"stadt\": \"Berlin\",\n",
|
||||||
|
" },\n",
|
||||||
|
" {\n",
|
||||||
|
" \"name\": \"Lena\",\n",
|
||||||
|
" \"alter\": 50,\n",
|
||||||
|
" \"hobbies\": [\"Gartenarbeit\", \"Lesen\", \"Reiten\"],\n",
|
||||||
|
" \"stadt\": \"Ulm\" \n",
|
||||||
|
" }\n",
|
||||||
|
"]"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "860e048a-c92e-48ce-a217-a5dc3bdd7eb5",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## Pipeline\n",
|
||||||
|
"RDFLib zum Erstellen und Speichern von Triplen"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 8,
|
||||||
|
"id": "22a85720-c2b3-4373-b4b8-bc7558b57626",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from rdflib import Graph, URIRef, Literal, Namespace\n",
|
||||||
|
"from rdflib.namespace import RDF, RDFS, XSD, GEO\n",
|
||||||
|
"\n",
|
||||||
|
"g = Graph()\n",
|
||||||
|
"thm = Namespace(\"https://th-mannheim.de/\")\n",
|
||||||
|
"thm_ont = Namespace(\"https://th-mannheim.de/ont/\")\n",
|
||||||
|
"cities = {}\n",
|
||||||
|
"hobbies = {}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 9,
|
||||||
|
"id": "fafc77bd-41f4-4ab1-b8f3-cb45dcb4b2c2",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"for city in city_source:\n",
|
||||||
|
" city_url = thm[f\"cities/{len(cities)}\"] \n",
|
||||||
|
" g.add((city_url, RDF.type, thm_ont.City))\n",
|
||||||
|
" g.add((city_url, RDFS.label, Literal(city[\"name\"], lang=\"de\")))\n",
|
||||||
|
" geometry_url = thm_ont[f\"geometry/{len(cities)}\"]\n",
|
||||||
|
" g.add((city_url, GEO.hasGeometry, geometry_url)) \n",
|
||||||
|
" g.add((geometry_url, GEO.asWKT, Literal(f\"POINT({city['long']} {city['lat']})\", datatype=GEO.wktLiteral)))\n",
|
||||||
|
" g.add((city_url, thm_ont.einwohner_anzahl, Literal(city[\"einwohner\"], datatype=XSD.int)))\n",
|
||||||
|
" cities[city[\"name\"]] = city_url"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "a9269936",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"cities"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 10,
|
||||||
|
"id": "64f0e718-3434-45e7-8ef1-727a3911b408",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"for id_, person in enumerate(person_source):\n",
|
||||||
|
" person_uri = thm[f\"persons/{id_}\"]\n",
|
||||||
|
" g.add((person_uri, RDF.type, thm_ont.Person))\n",
|
||||||
|
" g.add((person_uri, RDFS.label, Literal(person[\"name\"], lang=\"de\")))\n",
|
||||||
|
" g.add((person_uri, thm_ont.name, Literal(person[\"name\"], lang=\"de\")))\n",
|
||||||
|
" g.add((person_uri, thm_ont.age, Literal(person[\"alter\"], datatype=XSD.int)))\n",
|
||||||
|
"\n",
|
||||||
|
" # create city triples\n",
|
||||||
|
" if person[\"stadt\"] not in cities:\n",
|
||||||
|
" city_url = thm[f\"cities/{len(cities)}\"]\n",
|
||||||
|
" cities[person[\"stadt\"]] = city_url\n",
|
||||||
|
" g.add((city_url, RDF.type, thm_ont.City))\n",
|
||||||
|
" g.add((city_url, RDFS.label, Literal(person[\"stadt\"], lang=\"de\")))\n",
|
||||||
|
" g.add((person_uri, thm_ont.lebt_in, cities[person[\"stadt\"]]))\n",
|
||||||
|
"\n",
|
||||||
|
" # create hobby triple\n",
|
||||||
|
" for hobby in person[\"hobbies\"]:\n",
|
||||||
|
" if hobby not in hobbies:\n",
|
||||||
|
" hobby_url = thm[f\"hobbies/{len(hobbies)}\"]\n",
|
||||||
|
" hobbies[hobby] = hobby_url\n",
|
||||||
|
" g.add((hobby_url, RDF.type, thm_ont.Hobby))\n",
|
||||||
|
" g.add((hobby_url, RDFS.label, Literal(hobby, lang=\"de\")))\n",
|
||||||
|
" \n",
|
||||||
|
" g.add((person_uri, thm_ont.hobby, hobbies[hobby]))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 11,
|
||||||
|
"id": "91d6e01d-be20-4fe1-b46a-f786448db2da",
|
||||||
|
"metadata": {
|
||||||
|
"scrolled": true
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/hobbies/6'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.Literal('Gartenarbeit', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/0'), rdflib.term.URIRef('https://th-mannheim.de/ont/hobby'), rdflib.term.URIRef('https://th-mannheim.de/hobbies/0'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/0'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.Literal('Peter', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/1'), rdflib.term.URIRef('https://th-mannheim.de/ont/lebt_in'), rdflib.term.URIRef('https://th-mannheim.de/cities/0'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/ont/geometry/2'), rdflib.term.URIRef('http://www.opengis.net/ont/geosparql#asWKT'), rdflib.term.Literal('POINT(9.983 48.4)', datatype=rdflib.term.URIRef('http://www.opengis.net/ont/geosparql#wktLiteral')))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/hobbies/5'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.Literal('Auto', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/cities/1'), rdflib.term.URIRef('https://th-mannheim.de/ont/einwohner_anzahl'), rdflib.term.Literal('3850809', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#int')))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/cities/2'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.Literal('Ulm', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/hobbies/0'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.Literal('Sport', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/cities/1'), rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('https://th-mannheim.de/ont/City'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/0'), rdflib.term.URIRef('https://th-mannheim.de/ont/age'), rdflib.term.Literal('25', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#int')))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/hobbies/7'), rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('https://th-mannheim.de/ont/Hobby'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/0'), rdflib.term.URIRef('https://th-mannheim.de/ont/hobby'), rdflib.term.URIRef('https://th-mannheim.de/hobbies/2'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/hobbies/1'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.Literal('Musik', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/cities/0'), rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('https://th-mannheim.de/ont/City'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/1'), rdflib.term.URIRef('https://th-mannheim.de/ont/hobby'), rdflib.term.URIRef('https://th-mannheim.de/hobbies/4'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/2'), rdflib.term.URIRef('https://th-mannheim.de/ont/name'), rdflib.term.Literal('Gustav', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/3'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.Literal('Lena', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/1'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.Literal('Petra', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/0'), rdflib.term.URIRef('https://th-mannheim.de/ont/name'), rdflib.term.Literal('Peter', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/hobbies/3'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.Literal('Lesen', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/hobbies/0'), rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('https://th-mannheim.de/ont/Hobby'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/2'), rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('https://th-mannheim.de/ont/Person'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/0'), rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('https://th-mannheim.de/ont/Person'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/2'), rdflib.term.URIRef('https://th-mannheim.de/ont/age'), rdflib.term.Literal('30', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#int')))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/0'), rdflib.term.URIRef('https://th-mannheim.de/ont/lebt_in'), rdflib.term.URIRef('https://th-mannheim.de/cities/0'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/hobbies/2'), rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('https://th-mannheim.de/ont/Hobby'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/hobbies/5'), rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('https://th-mannheim.de/ont/Hobby'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/ont/geometry/0'), rdflib.term.URIRef('http://www.opengis.net/ont/geosparql#asWKT'), rdflib.term.Literal('POINT(8.4673 49.4891)', datatype=rdflib.term.URIRef('http://www.opengis.net/ont/geosparql#wktLiteral')))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/3'), rdflib.term.URIRef('https://th-mannheim.de/ont/hobby'), rdflib.term.URIRef('https://th-mannheim.de/hobbies/3'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/3'), rdflib.term.URIRef('https://th-mannheim.de/ont/hobby'), rdflib.term.URIRef('https://th-mannheim.de/hobbies/6'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/2'), rdflib.term.URIRef('https://th-mannheim.de/ont/lebt_in'), rdflib.term.URIRef('https://th-mannheim.de/cities/1'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/cities/2'), rdflib.term.URIRef('http://www.opengis.net/ont/geosparql#hasGeometry'), rdflib.term.URIRef('https://th-mannheim.de/ont/geometry/2'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/cities/0'), rdflib.term.URIRef('https://th-mannheim.de/ont/einwohner_anzahl'), rdflib.term.Literal('318035', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#int')))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/1'), rdflib.term.URIRef('https://th-mannheim.de/ont/hobby'), rdflib.term.URIRef('https://th-mannheim.de/hobbies/3'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/hobbies/7'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.Literal('Reiten', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/1'), rdflib.term.URIRef('https://th-mannheim.de/ont/hobby'), rdflib.term.URIRef('https://th-mannheim.de/hobbies/0'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/ont/geometry/1'), rdflib.term.URIRef('http://www.opengis.net/ont/geosparql#asWKT'), rdflib.term.Literal('POINT(13.405 52.52)', datatype=rdflib.term.URIRef('http://www.opengis.net/ont/geosparql#wktLiteral')))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/hobbies/2'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.Literal('PC Spiele', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/hobbies/1'), rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('https://th-mannheim.de/ont/Hobby'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/3'), rdflib.term.URIRef('https://th-mannheim.de/ont/name'), rdflib.term.Literal('Lena', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/1'), rdflib.term.URIRef('https://th-mannheim.de/ont/name'), rdflib.term.Literal('Petra', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/2'), rdflib.term.URIRef('https://th-mannheim.de/ont/hobby'), rdflib.term.URIRef('https://th-mannheim.de/hobbies/5'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/0'), rdflib.term.URIRef('https://th-mannheim.de/ont/hobby'), rdflib.term.URIRef('https://th-mannheim.de/hobbies/1'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/cities/2'), rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('https://th-mannheim.de/ont/City'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/3'), rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('https://th-mannheim.de/ont/Person'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/3'), rdflib.term.URIRef('https://th-mannheim.de/ont/age'), rdflib.term.Literal('50', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#int')))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/cities/1'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.Literal('Berlin', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/3'), rdflib.term.URIRef('https://th-mannheim.de/ont/hobby'), rdflib.term.URIRef('https://th-mannheim.de/hobbies/7'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/cities/2'), rdflib.term.URIRef('https://th-mannheim.de/ont/einwohner_anzahl'), rdflib.term.Literal('129882', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#int')))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/hobbies/4'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.Literal('Zocken', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/2'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.Literal('Gustav', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/cities/0'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.Literal('Mannheim', lang='de'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/cities/1'), rdflib.term.URIRef('http://www.opengis.net/ont/geosparql#hasGeometry'), rdflib.term.URIRef('https://th-mannheim.de/ont/geometry/1'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/1'), rdflib.term.URIRef('https://th-mannheim.de/ont/age'), rdflib.term.Literal('23', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#int')))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/hobbies/3'), rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('https://th-mannheim.de/ont/Hobby'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/2'), rdflib.term.URIRef('https://th-mannheim.de/ont/hobby'), rdflib.term.URIRef('https://th-mannheim.de/hobbies/3'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/2'), rdflib.term.URIRef('https://th-mannheim.de/ont/hobby'), rdflib.term.URIRef('https://th-mannheim.de/hobbies/6'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/hobbies/4'), rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('https://th-mannheim.de/ont/Hobby'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/1'), rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('https://th-mannheim.de/ont/Person'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/hobbies/6'), rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('https://th-mannheim.de/ont/Hobby'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/persons/3'), rdflib.term.URIRef('https://th-mannheim.de/ont/lebt_in'), rdflib.term.URIRef('https://th-mannheim.de/cities/2'))\n",
|
||||||
|
"(rdflib.term.URIRef('https://th-mannheim.de/cities/0'), rdflib.term.URIRef('http://www.opengis.net/ont/geosparql#hasGeometry'), rdflib.term.URIRef('https://th-mannheim.de/ont/geometry/0'))\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"for triple in g:\n",
|
||||||
|
" print(triple)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 12,
|
||||||
|
"id": "1ce05fb8-f6d2-4e38-a7bc-cb70739360d9",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"<Graph identifier=N2f617184d49f4bef87635233df5cdba1 (<class 'rdflib.graph.Graph'>)>"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 12,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"g.serialize(\"persons.ttl\", format=\"turtle\")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "24ddfbd2-c491-4077-839d-3979dcc38186",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# ttl in VS Code"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "5ed56355-8216-464d-addf-afbaaa379bee",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# Fuseki Database\n",
|
||||||
|
"- Laden von Triplen\n",
|
||||||
|
"- SPAQRL"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "raw",
|
||||||
|
"id": "df3fa6b2-0233-4d15-98de-cc6e41aff0f2",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n",
|
||||||
|
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n",
|
||||||
|
"PREFIX thm: <https://th-mannheim.de/ont/>\n",
|
||||||
|
"\n",
|
||||||
|
"SELECT * WHERE {\n",
|
||||||
|
" ?person thm:hobby ?hobby .\n",
|
||||||
|
" ?hobby rdfs:label ?hobby_name\n",
|
||||||
|
"} "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "raw",
|
||||||
|
"id": "57bb4c24-8c72-4537-a077-e9d7016048f8",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n",
|
||||||
|
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n",
|
||||||
|
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n",
|
||||||
|
"PREFIX thm: <https://th-mannheim.de/ont/>\n",
|
||||||
|
"\n",
|
||||||
|
"select ?hobby_label ?pos WHERE {\n",
|
||||||
|
" ?person thm:hobby ?hobby .\n",
|
||||||
|
" ?hobby rdfs:label ?hobby_label .\n",
|
||||||
|
" ?person thm:lebt_in ?stadt .\n",
|
||||||
|
" ?stadt geo:hasGeometry ?geo .\n",
|
||||||
|
" ?geo geo:asWKT ?pos\n",
|
||||||
|
"} "
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "venv (3.14.4)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.14.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,86 @@
|
||||||
|
@prefix geo: <http://www.opengis.net/ont/geosparql#> .
|
||||||
|
@prefix ns1: <https://th-mannheim.de/ont/> .
|
||||||
|
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
||||||
|
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/persons/0> a ns1:Person ;
|
||||||
|
rdfs:label "Peter"@de ;
|
||||||
|
ns1:age "25"^^xsd:int ;
|
||||||
|
ns1:hobby <https://th-mannheim.de/hobbies/0>,
|
||||||
|
<https://th-mannheim.de/hobbies/1>,
|
||||||
|
<https://th-mannheim.de/hobbies/2> ;
|
||||||
|
ns1:lebt_in <https://th-mannheim.de/cities/0> ;
|
||||||
|
ns1:name "Peter"@de .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/persons/1> a ns1:Person ;
|
||||||
|
rdfs:label "Petra"@de ;
|
||||||
|
ns1:age "23"^^xsd:int ;
|
||||||
|
ns1:hobby <https://th-mannheim.de/hobbies/0>,
|
||||||
|
<https://th-mannheim.de/hobbies/3>,
|
||||||
|
<https://th-mannheim.de/hobbies/4> ;
|
||||||
|
ns1:lebt_in <https://th-mannheim.de/cities/0> ;
|
||||||
|
ns1:name "Petra"@de .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/persons/2> a ns1:Person ;
|
||||||
|
rdfs:label "Gustav"@de ;
|
||||||
|
ns1:age "30"^^xsd:int ;
|
||||||
|
ns1:hobby <https://th-mannheim.de/hobbies/3>,
|
||||||
|
<https://th-mannheim.de/hobbies/5>,
|
||||||
|
<https://th-mannheim.de/hobbies/6> ;
|
||||||
|
ns1:lebt_in <https://th-mannheim.de/cities/1> ;
|
||||||
|
ns1:name "Gustav"@de .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/persons/3> a ns1:Person ;
|
||||||
|
rdfs:label "Lena"@de ;
|
||||||
|
ns1:age "50"^^xsd:int ;
|
||||||
|
ns1:hobby <https://th-mannheim.de/hobbies/3>,
|
||||||
|
<https://th-mannheim.de/hobbies/6>,
|
||||||
|
<https://th-mannheim.de/hobbies/7> ;
|
||||||
|
ns1:lebt_in <https://th-mannheim.de/cities/2> ;
|
||||||
|
ns1:name "Lena"@de .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/cities/1> a ns1:City ;
|
||||||
|
rdfs:label "Berlin"@de ;
|
||||||
|
geo:hasGeometry <https://th-mannheim.de/ont/geometry/1> ;
|
||||||
|
ns1:einwohner_anzahl "3850809"^^xsd:int .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/cities/2> a ns1:City ;
|
||||||
|
rdfs:label "Ulm"@de ;
|
||||||
|
geo:hasGeometry <https://th-mannheim.de/ont/geometry/2> ;
|
||||||
|
ns1:einwohner_anzahl "129882"^^xsd:int .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/hobbies/1> a ns1:Hobby ;
|
||||||
|
rdfs:label "Musik"@de .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/hobbies/2> a ns1:Hobby ;
|
||||||
|
rdfs:label "PC Spiele"@de .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/hobbies/4> a ns1:Hobby ;
|
||||||
|
rdfs:label "Zocken"@de .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/hobbies/5> a ns1:Hobby ;
|
||||||
|
rdfs:label "Auto"@de .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/hobbies/7> a ns1:Hobby ;
|
||||||
|
rdfs:label "Reiten"@de .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/ont/geometry/0> geo:asWKT "POINT(8.4673 49.4891)"^^geo:wktLiteral .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/ont/geometry/1> geo:asWKT "POINT(13.405 52.52)"^^geo:wktLiteral .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/ont/geometry/2> geo:asWKT "POINT(9.983 48.4)"^^geo:wktLiteral .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/cities/0> a ns1:City ;
|
||||||
|
rdfs:label "Mannheim"@de ;
|
||||||
|
geo:hasGeometry <https://th-mannheim.de/ont/geometry/0> ;
|
||||||
|
ns1:einwohner_anzahl "318035"^^xsd:int .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/hobbies/0> a ns1:Hobby ;
|
||||||
|
rdfs:label "Sport"@de .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/hobbies/6> a ns1:Hobby ;
|
||||||
|
rdfs:label "Gartenarbeit"@de .
|
||||||
|
|
||||||
|
<https://th-mannheim.de/hobbies/3> a ns1:Hobby ;
|
||||||
|
rdfs:label "Lesen"@de .
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue