Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
This file is licensed under the Creative Commons Attribution-NonCommercial 3.0 (CC BY-NC 3.0)
Knowledge Graphs Lecture 2 - Basic Semantic Technologies 2.3 RDF Turtle Serialization
Prof. Dr. Harald Sack & Dr. Mehwish AlamFIZ Karlsruhe - Leibniz Institute for Information InfrastructureAIFB - Karlsruhe Institute of Technology
Autumn 2020
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
Knowledge GraphsLecture 2: Basic Semantic Technologies
2.1 How to Identify and Access Things
2.2 How to Represent Simple Facts with RDF
2.3 RDF Turtle Serialization
2.4 RDF Complex Data Structures
2.5 Model Building with RDFS
2.6 Logical Inference with RDF(S)
Excursion 1: RDFa - RDF and the Web
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology3<3>
URI
HTTP
address
RDF
reference
communication
WEBof Data
Basic Architecture of the Web of Data2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
[1]
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
#Lectures4Future
[2]
Resource Description Framework
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
RDF Serializations
● RDF comes with several different serialization formats:○ N-Triples, RDF/XML, JSON, Turtle, TriG, N-Quads, RDFa, ...
RDF/XML
N-Triples JSON-LDTurtle
TriG
N-Quads
extended bysupport for multiple graphs
We will use RDF/Turtle
5
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
● N-Triples Notation○ URIs/IRIs in angle brackets○ Literals in quotation marks○ Triple ends with a period
RDF Serializations
<http://dbpedia.org/resource/Greenhouse_effect> "1824"<http://dbpedia.org/ontology/discoveredIn>
<http://dbpedia.org/resource/Joseph_Fourier><http://dbpedia.org/ontology/discoverer>
<http://dbpedia.org/resource/Greenhouse_effect> <http://dbpedia.org/ontology/discoveredIn> "1824" .
<http://dbpedia.org/resource/Greenhouse_effect> <http://dbpedia.org/ontology/discoverer><http://dbpedia.org/resource/Joseph_Fourier> .
6
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
RDF Serializations
● Turtle (Terse RDF Triple Language) Notation○ extension of N-Triples
@prefix dbo: <http://dbpedia.org/ontology/> .@base <http://dbpedia.org/resource/> .
<Greenhouse_effect> dbo:discoveredIn "1824" .
<Greenhouse_effect> dbo:discoverer <Joseph_Fourier> .
RDF/Turtle allows shortcurts and abbreviations for readability
7
<http://dbpedia.org/resource/Greenhouse_effect> "1824"<http://dbpedia.org/ontology/discoveredIn>
<http://dbpedia.org/resource/Joseph_Fourier><http://dbpedia.org/ontology/discoverer>
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
● starting with N-Triples
<http://dbpedia.org/resource/Greenhouse_effect> <http://dbpedia.org/ontology/discoveredIn> "1824" .
<http://dbpedia.org/resource/Greenhouse_effect> <http://dbpedia.org/ontology/discoverer> <http://dbpedia.org/resource/Joseph_Fourier> .
@prefix dbo: <http://dbpedia.org/ontology/> .@base <http://dbpedia.org/resource/> .
<Greenhouse_effect> dbo:discoveredIn "1824" .
<Greenhouse_effect> dbo:discoverer <Joseph_Fourier> .
@prefix directive associates prefix-label with URI
@base directive provides URI to complement all relative URIs
RDF/Turtle
8
<http://dbpedia.org/resource/Greenhouse_effect> "1824"<http://dbpedia.org/ontology/discoveredIn>
<http://dbpedia.org/resource/Joseph_Fourier><http://dbpedia.org/ontology/discoverer>
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
● Abbreviating RDF Triples in Turtle
@prefix dbo: <http://dbpedia.org/ontology/> .@base <http://dbpedia.org/resource/> .
<Greenhouse_effect> dbo:discoveredIn "1824" ; dbo:discoverer <Joseph_Fourier> .
semicolon indicates that subsequent triples have the same subject (predicate list)
RDF/Turtle
9
<http://dbpedia.org/resource/Greenhouse_effect> "1824"<http://dbpedia.org/ontology/discoveredIn>
<http://dbpedia.org/resource/Joseph_Fourier><http://dbpedia.org/ontology/discoverer>
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
● Abbreviating RDF Triples in Turtle
http://dbpedia.org/resource/Greenhouse_effect http://dbpedia.org/category/Athmospheredct:subject
@prefix dct: <http://purl.org/dc/terms/> .@prefix dbc: <http://dbpedia.org/category/> .@base <http://dbpedia.org/resource/> .
<Greenhouse_effect> dct:subject dbc:Athmosphere , dbc:Climate_change , dbc:Athmospheric_radiation .
comma indicates that subsequent triples have same subject and property (object list)
http://dbpedia.org/category/Climate_change
http://dbpedia.org/category/Athmospheric_radiation
dct:subject
dct:subject
RDF/Turtle
10
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
● Typed Literals
http://dbpedia.org/resource/Carbon_Dioxide "-78.5"^^xsd:doubledbo:sublimationTemperature
@prefix dbo: <http://dbpedia.org/ontology/> .@prefix xsd: <http://www.w3c.org/2001/XMLSchema#> .@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .@base <http://dbpedia.org/resource/> .
<Carbon_Dioxide> dbo:sublimationTemperature "-78.5"^^xsd:double ; dbo:molarMass "44.009"^^xsd:double ; dbo:discovered "1640-00-00"^^xsd:date ; rdfs:label "Carbon Dioxide"@en .
"44.009"^^xsd:double
"1640-00-00"^^xsd:date
dbo:molarMass
rdfs:label
"Carbon Dioxide"@en
dbo:discovered
RDF/Turtle
11
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
● Multi Valued Relations○ CO2 was discovered / rediscovered
by two scientists at different times.○ How to model this in RDF?
○ Problem: unique association
RDF/Turtle
12
Carbon_Dioxide Jan_Baptist_van_Helmont dbo:discoverer
"1640-00-00"^^xsd:date
dbo:discoveredIn
Joseph_Black
dbo:discoverer
dbo:discoveredIn
"1750-00-00"^^xsd:date
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
● Multi Valued Relations○ Blank Nodes (Bnodes) can be
introduced to represent multi- valued relationships.
○ Blank Nodes can be introduced for resources that don‘t need a name (auxiliary nodes).
RDF/Turtle
13
Jan_Baptist_van_Helmontdbo:discovery
"1640-00-00"^^xsd:date
Joseph_Black
dbo:discoveredIn
dbo:discovery
dbo:discoverer
"1750-00-00"^^xsd:date
Carbon_Dioxide
dbo:discoveredIn
dbo:discoverer
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
@prefix dbo: <http://dbpedia.org/ontology/> .@prefix xsd: <http://www.w3c.org/2001/XMLSchema#> .@base <http://dbpedia.org/resource/> .
[] dbo:discoverer <Jan_Baptist_van_Helmont> ; dbo:discoveredIn "1640-00-00"^^xsd:date .
anonymous blank node as subject
RDF/Turtle
14
Jan_Baptist_van_Helmont
"1640-00-00"^^xsd:date
dbo:discoveredIn
dbo:discoverer
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
@prefix dbo: <http://dbpedia.org/ontology/> .@prefix xsd: <http://www.w3c.org/2001/XMLSchema#> .@base <http://dbpedia.org/resource/> .
<Carbon_Dioxide> dbo:discovery [ dbo:discoverer <Jean_Baptist_van_Helmont> ; dbo:discoveredIn "1640-00-00"^^xsd:date ] , [ dbo:discoverer <Joseph_Black> ; dbo:discoveredIn "1750-00-00"^^xsd:date ] .
nested anonymous blank nodes
RDF/Turtle
15
Jan_Baptist_van_Helmontdbo:discovery
"1640-00-00"^^xsd:date
Joseph_Black
dbo:discoveredIn
dbo:discovery
dbo:discoverer
"1750-00-00"^^xsd:date
Carbon_Dioxide
dbo:discoveredIn
dbo:discoverer
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
@prefix dbo: <http://dbpedia.org/ontology/> .@prefix xsd: <http://www.w3c.org/2001/XMLSchema#> .@base <http://dbpedia.org/resource/> .
<Carbon_Dioxide> dbo:discovery _:ID1, _:ID2 .
_:ID1 dbo:discoverer <Jan_Baptist_van_Helmont> ; dbo:discoveredIn "1640-00-00"^^xsd:date .
_:ID2 dbo:discoverer <John_Black> ; dbo:discoveredIn "1750-00-00"^^xsd:date .
dereferenceable blank nodescan only be referenced from inside a document / graph
RDF/Turtle
16
Jan_Baptist_van_Helmontdbo:discovery
"1640-00-00"^^xsd:date
Joseph_Black
dbo:discoveredIn
dbo:discovery
dbo:discoverer
"1750-00-00"^^xsd:date
ID1Carbon_Dioxide
ID2
dbo:discoveredIn
dbo:discoverer
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
Information Sertvice Engineering , Prof. Dr. Harald Sack & Dr. Maria Koutraki, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
RDF Complex Data
Structures
Next Lecture... [3]
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
Picture References:● [1] Benjamin Nowack, The Semantic Web - Not a Piece of cake…, at bnode.org, 2009-07-08 , [CC BY 3.0]
http://bnode.org/blog/2009/07/08/the-semantic-web-not-a-piece-of-cake
● [2] The Green House Effect, A loose necktie [CC BY-SA]https://commons.wikimedia.org/wiki/File:Greenhouse-effect-t445.svg
● [3] The British Museum: the reading room under construction. Wood engraving by J. Brown after C. W. Sheeres, 1855., The Wellcome Collection, [CC-BY-4.0]https://upload.wikimedia.org/wikipedia/commons/a/ad/The_British_Museum%3B_the_reading_room_under_construction._Woo_Wellcome_V0013519.jpg
Knowledge Graphs2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization