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 Alam
FIZ Karlsruhe - Leibniz Institute for Information Infrastructure
AIFB - 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 Graphs
Lecture 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 Technology
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
Basic Architecture of the Web of Data
RDF communication
HTTP
WEB
of Data
reference address
URI
<3>3
[1]
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
#Lectures4Future
Resource
Description
Framework
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology [2]
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
RDF Serializations
● RDF comes with several different serialization formats:
○ N-Triples, RDF/XML, JSON, Turtle, TriG, N-Quads, RDFa, ...
N-Triples Turtle JSON-LD
RDF/XML TriG
We will use N-Quads
RDF/Turtle
extended by
support for multiple graphs
5
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
RDF Serializations
<[Link] "1824"
<[Link]
<[Link]
<[Link]
● N-Triples Notation
○ URIs/IRIs in angle brackets
○ Literals in quotation marks
○ Triple ends with a period
<[Link] <[Link] "1824" .
<[Link] <[Link]
<[Link] .
6
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
RDF Serializations
<[Link] "1824"
<[Link]
<[Link]
<[Link]
● Turtle (Terse RDF Triple Language) Notation
○ extension of N-Triples
RDF/Turtle allows
shortcurts and
@prefix dbo: <[Link] .
@base <[Link] .
abbreviations for
readability
<Greenhouse_effect> dbo:discoveredIn "1824" .
<Greenhouse_effect> dbo:discoverer <Joseph_Fourier> .
7
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
RDF/Turtle
<[Link] "1824"
<[Link]
<[Link]
<[Link]
● starting with N-Triples
<[Link] <[Link] "1824" .
<[Link] <[Link]
<[Link] .
@prefix dbo: <[Link] . @prefix directive associates prefix-label with URI
@base <[Link] .
<Greenhouse_effect> dbo:discoveredIn "1824" . @base directive provides URI to complement all
<Greenhouse_effect> dbo:discoverer <Joseph_Fourier> . relative URIs
8
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
RDF/Turtle
<[Link] "1824"
<[Link]
<[Link]
<[Link]
● Abbreviating RDF Triples in Turtle
@prefix dbo: <[Link] . semicolon indicates that subsequent
@base <[Link] . triples have the same subject
(predicate list)
<Greenhouse_effect> dbo:discoveredIn "1824" ;
dbo:discoverer <Joseph_Fourier> .
9
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
RDF/Turtle
dct:subject
[Link] [Link]
dct:subject
dct:subject [Link]
● Abbreviating RDF Triples in Turtle
[Link]
on
@prefix dct: <[Link] .
@prefix dbc: <[Link] .
comma indicates that subsequent
@base <[Link] .
triples have same subject and property
<Greenhouse_effect> dct:subject dbc:Athmosphere , (object list)
dbc:Climate_change ,
dbc:Athmospheric_radiation .
10
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
RDF/Turtle
dbo:sublimationTemperature
[Link] "-78.5"^^xsd:double
dbo:molarMass
"44.009"^^xsd:double
dbo:discovered
rdfs:label
● Typed Literals
"1640-00-00"^^xsd:date
@prefix dbo: <[Link] .
@prefix xsd: <[Link] .
@prefix rdfs: <[Link] . "Carbon Dioxide"@en
@base <[Link] .
<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 . ….@id
11
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
RDF/Turtle
dbo:discoverer
Carbon_Dioxide Jan_Baptist_van_Helmont
dbo:discoveredIn
"1640-00-00"^^xsd:date
● Multi Valued Relations dbo:discoverer
○ CO2 was discovered / rediscovered
by two scientists at different times. dbo:discoveredIn
Joseph_Black
○ How to model this in RDF?
○ Problem: unique association "1750-00-00"^^xsd:date
12
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
RDF/Turtle
dbo:discoverer
Jan_Baptist_van_Helmont
dbo:discovery
Carbon_Dioxide
dbo:discoveredIn
"1640-00-00"^^xsd:date
dbo:discovery
● Multi Valued Relations dbo:discoverer
Joseph_Black
○ Blank Nodes (Bnodes) can be
introduced to represent multi- dbo:discoveredIn
valued relationships. "1750-00-00"^^xsd:date
○ Blank Nodes can be introduced
for resources that don‘t need a
name (auxiliary nodes).
13
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
RDF/Turtle
dbo:discoverer
Jan_Baptist_van_Helmont
dbo:discoveredIn
"1640-00-00"^^xsd:date
@prefix dbo: <[Link] .
@prefix xsd: <[Link] .
@base <[Link] .
[] dbo:discoverer <Jan_Baptist_van_Helmont> ;
dbo:discoveredIn "1640-00-00"^^xsd:date .
anonymous blank node as subject
14
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
RDF/Turtle
dbo:discoverer
Jan_Baptist_van_Helmont
dbo:discovery
Carbon_Dioxide
dbo:discoveredIn
"1640-00-00"^^xsd:date
dbo:discovery
dbo:discoverer
Joseph_Black
@prefix dbo: <[Link] .
@prefix xsd: <[Link] . dbo:discoveredIn
@base <[Link] .
"1750-00-00"^^xsd:date
<Carbon_Dioxide> dbo:discovery [ dbo:discoverer <Jean_Baptist_van_Helmont> ;
dbo:discoveredIn "1640-00-00"^^xsd:date
] ,
[ dbo:discoverer <Joseph_Black> ; nested
dbo:discoveredIn "1750-00-00"^^xsd:date anonymous blank
] .
nodes
15
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
RDF/Turtle
dbo:discoverer
Jan_Baptist_van_Helmont
dbo:discovery
Carbon_Dioxide ID1
dbo:discoveredIn
"1640-00-00"^^xsd:date
dbo:discovery
dbo:discoverer
@prefix dbo: <[Link] . ID2 Joseph_Black
@prefix xsd: <[Link] .
@base <[Link] . dbo:discoveredIn
<Carbon_Dioxide> dbo:discovery _:ID1, _:ID2 . "1750-00-00"^^xsd:date
_:ID1 dbo:discoverer <Jan_Baptist_van_Helmont> ;
dbo:discoveredIn "1640-00-00"^^xsd:date .
dereferenceable blank nodes
_:ID2 dbo:discoverer <John_Black> ; can only be referenced from
dbo:discoveredIn "1750-00-00"^^xsd:date . inside a document / graph
16
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
x D a ta
o m p l e
R DF C es
r uc t u r
S t
Next Lecture...
Information Sertvice Engineering , Prof. Dr. Harald Sack & Dr. Maria Koutraki, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology
[3]
Knowledge Graphs
2. Basic Semantic Technologies / 2.3 RDF Turtle Serialization
Picture References:
● [1] Benjamin Nowack, The Semantic Web - Not a Piece of cake…, at [Link], 2009-07-08 , [CC BY 3.0]
[Link]
● [2] The Green House Effect, A loose necktie [CC BY-SA]
[Link]
● [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]
[Link]
Knowledge Graphs 2020 , Prof. Dr. Harald Sack & Dr. Mehwish Alam, FIZ Karlsruhe - Leibniz Institute for Information Infrastructure & Karlsruhe Institute of Technology