<<

Open Information Systems 2019-2020

Lecture 2: RDF and RDF(S)

Christophe Debruyne The problem

Traditional

SysA SysB SysA SysB

SysC SysD SysC SysD

SysE SysE

3/15/20 Christophe Debruyne 2 The Stack

User Interface and Applications

Trust

Proof

Unifying Logic Cryptography

Querying: Ontologies: OWL Rules: RIF/SWRL SPARQL Taxonomies: RDFS

Data Interchange: RDF

Syntax: XML

Identifiers: IRI Character Set: UNICODE

Different stacks exist, but the gist remains the same: a layered approach.

3/15/20 Christophe Debruyne 4 Resource Description Framework

We will familiarize ourselves with both the RDF/XML and serialization of RDF. The former is useful for context and terminology, while the latter is more often adopted in practice. Resource Description Framework

• RDF is not an ontology language but a data model (!!!) • RDF is a W3C Recommendation • RDF is designed to be read by computers • RDF is for describing resources on the Web • RDF uses URIs to identify and reference resources on the Web

RDF/XML is just one way of serializing RDF. Other serializations format include TURTLE and N3. NQuads and Trig even support (named) graphs.

3/15/20 Christophe Debruyne 20 Example

Christophe's Homepage Semantics RDF Namespace

ex:title Christophe's Homepage http://www.christo phedebruyne.be ex:topic Semantics

Subject Predicate Object

3/15/20 Christophe Debruyne 21 Example

Christophe's Homepage Semantics

RDF/XML

@prefix ex: . @prefix rdf: .

ex:title "Christophe's Homepage" . ex:topic "Semantics" . TURTLE

3/15/20 Christophe Debruyne 22 Example

Christophe's Homepage Semantics

RDF/XML

@prefix ex: . @prefix rdf: .

ex:title "Christophe's Homepage" ; ex:topic "Semantics" . TURTLE – more terse

3/15/20 Christophe Debruyne 23 Example

@prefix ex: . @prefix rdf: .

ex:title "Christophe's Homepage" ; ex:topic "Semantics" .

HTTP GET http://www.example.org/ont#

@base . @prefix rdf: .

<#title> a rdf:Property . <#topic> a rdf:Property .

3/15/20 Christophe Debruyne 24 RDF Triples

SUBJECT PREDICATE OBJECT RESOURCE IDENTIFIED Y Y Y WITH URI ANONYMOUS RESOURCE Y N Y (NO URI OR ) LITERAL N N Y

3/15/20 Christophe Debruyne 25 Example

Christophe's Homepage Semantics

RDF/XML

In RDF/XML • Property names must be associated with a schema • Qualify property names with a namespace prefix

3/15/20 Christophe Debruyne 26 RDF Description Elements

• rdf:about refers to an existing resource • rdf:ID creates a new resource (a named node)

3/15/20 Christophe Debruyne 27 RDF Description Elements

• rdf:about refers to an existing resource • rdf:ID creates a new resource (a named node)

used to resolve relative URIs in Christophe Debruyne a document.

3/15/20 Christophe Debruyne 28 RDF Description Elements

This notion of rdf:about and rdf:ID does not exist in TURTLE.

@prefix ex: . @prefix rdf: .

ex:name "Christophe Debruyne" .

ex:author .

Properties have a value which can be either a literal or a resource.

3/15/20 Christophe Debruyne 29 Base URIs

Relative URIs are resolved relative to the current base URI. The current base URI is the URI of the document. You can “overwrite” the base URI by providing an xml:base directive in RDF XML, or @base directive in TURTLE

RDF/XML • xml:base="http://www.example.org/example" • rdf:ID="foo" à http://www.example.org/example#foo • rdf:about="#foo" à http://www.example.org/example#foo • rdf:about="foo" à http://www.example.org/example/foo

TURTLE • @base . • <#foo> à http://www.example.org/example#foo • à http://www.example.org/example/foo

3/15/20 Christophe Debruyne 30 RDF Property Elements

Christophe's Homepage Semantics

Christophe's Homepage ß Blank Node! (See later) Christophe Debruyne Can somebody see something strange in this example?

3/15/20 Christophe Debruyne 31 RDF Property Elements

@prefix ex: . "Inline declaration of @prefix rdf: . a blank node. A new blank node identifier ex:author [ ex:name "Christophe Debruyne" ] ; will be generated for ex:title "Christophe's Homepage" ; each […] pair. ex:topic "Semantics" .

@prefix ex: . Here, we declare our @prefix rdf: . own blank node identifiers, which we ex:author _:foo ; can use to refer to ex:title "Christophe's Homepage" ; blank nodes from ex:topic "Semantics" . various places in the graph. _:foo ex:name "Christophe Debruyne" .

3/15/20 Christophe Debruyne 32 Reusing nodes in RDF/XML?

@prefix ex: . ex:Victor ex:ownedBy _:foo . ex:Bettina ex:ownedBy _:foo . ex:Gaston ex:ownedBy _:foo . _:foo ex:name "Christophe" .

Christophe

3/15/20 Christophe Debruyne 33 RDF Abbreviated Syntax

• Property elements converted to attributes (only for literal values that occur once).

Christophe's Homepage Semantics

3/15/20 Christophe Debruyne 34 Declaring types of things

• Types can be declared next to properties • And things can have more than one type • Arguably "ontology-language-ish"

@prefix ex: . @prefix rdf: . rdf:type ex:Webpage .

@prefix ex: . @prefix rdf: . a ex:Webpage .

3/15/20 Christophe Debruyne 35 RDF Abbreviated Syntax

• Value of rdf:type used directly as an element name

Christophe's Homepage Semantics

Christophe's Homepage Semantics xmlns:s="http://www.example.org/ont#"

3/15/20 Christophe Debruyne 36 Plain and Typed Literals

• Two types of literals: plain and typed • Plain are strings that can have an optional language tag • Typed are strings that have a type (usually XSD) • Language tags have no meaning for typed literals

Christophe Christophe 171 Christophe

@prefix ex: . @prefix xsd: . ex:height "171"^^xsd:int ; ex:name "Christophe"^^xsd:string , "Christophe" , "Christophe"@en .

3/15/20 Christophe Debruyne 37 RDF Containers

• Are types of containers.

• Bag à An unordered group of resources or literals • Sequence à An ordered group of resources or literals • Alternative à A group of resources or literals that represent alternatives for the value of a property

Containers may contain duplicates.

3/15/20 Christophe Debruyne 38 RDF Containers

# prefixes ommitted cats:Christophe ex:adopted [ a rdf:Bag ; rdf:_1 cats:Victor ; rdf:_2 cats:Bettina ; rdf:_3 cats:Gaston ] .

3/15/20 Christophe Debruyne 39 RDF Containers

# prefixes ommitted cats:Christophe ex:adopted [ a rdf:Seq ; rdf:_1 cats:Victor ; rdf:_2 cats:Bettina ; rdf:_3 cats:Gaston ] .

3/15/20 Christophe Debruyne 40 RDF Containers

Bettina Cocotte Bouboule # prefixes omitted cats:Bettina ex:listensTo [ a rdf:Alt ; rdf:_1 "Bettina" ; rdf:_2 "Cocotte" ; rdf:_3 "Bouboule" ] .

3/15/20 Christophe Debruyne 41 RDF Collections – i.e., lists

Do the terms "first", "rest", and "nil" ring a bell? -> LISP Looks convoluted, but there is an easier way to model lists.

3/15/20 Christophe Debruyne 42 RDF Collections

In TURTLE we use parentheses @prefix ex: . for describing lists. @prefix cats: . @prefix rdf: . cats:Christophe ex:looksAfter ( cats:Victor cats:Bettina cats:Gaston ) .

3/15/20 Christophe Debruyne 43 Non-binary Relations

• RDF only supports binary relations

6.8 6.8 rdf:value cats: ex:weighs Bettina ex:unit : cats:Bettina ex:weighs [ Kilogram rdf:value "6.8" ; ex:unit ] .

3/15/20 Christophe Debruyne 44 Non-binary Relations

• RDF only supports binary relations • A predicate can only be applied on exactly one "value", a resource or a literal. If rdf:parseType="Resource" is not declared on the predicate, the parser will generate an error. • rdf:parseType="Resource" instructs the parser to generate a resource and attach all values as attributes of that resource.

3/15/20 Christophe Debruyne 45 RDF Objects and Subjects

• Subjects of one statement can be the object of another, which

creates directed labeled graphs RDF’s structure can, unlike XML, @prefix ex: . be broken down and distributed @prefix rdf: . (in the same document or @prefix dc: . pointing to another). Joining of different resources using lazy loading and the URIs ex:firstname "christophe" ; ex:workson .

dc:title "Open Semantic Cloud for Brussels" .

3/15/20 Christophe Debruyne 46 Reification

• Making statements about statements

#S1

3/15/20 Christophe Debruyne 47 Reification (II)

• Making statements about statements

@prefix ex: . @prefix rdf: . ex:Robert ex:likes ex:S1 . ex:S1 a rdf:Statement ; rdf:object ; rdf:predicate ex:performedby ; rdf:subject .

#S1

3/15/20 Christophe Debruyne 48 Reification

@prefix ex: . These two RDF @prefix rdf: . documents are ex:Robert ex:likes ex:S1 . equivalent. ex:S1 a rdf:Statement ; rdf:object ; rdf:predicate ex:performedby ; rdf:subject .

@prefix ex: . @prefix rdf: . @base . <#Robert> ex:likes <#S1> . <#S1> a rdf:Statement ; rdf:object ; rdf:predicate ex:performedby ; rdf:subject .

3/15/20 Christophe Debruyne 49 Conclusions

• RDF as a data model • Two RDF serializations being RDF/XML and TURTLE

• Resources (named, and blank nodes) • Triples: subject-predicate-object – Subject are resources (named or blank) – Predicates must have a URI – Objects are resources (named or blank) or literal values • Directed labeled-graphs and descriptions can be "scattered" within and across documents • RDF allows you to declare types, use containers and collections

• Some limitations of RDF w.r.t. reification and non-binary relationships, and how we can deal with those.

3/15/20 Christophe Debruyne 50 References

• XML Schema – https://www.w3.org/XML/Schema • RDF, RDF/XML, TURTLE – https://www.w3.org/TR/rdf-primer/ – https://www.w3.org/TR/rdf-syntax-grammar/ – https://www.w3.org/TR/turtle/ • RDF Schema – https://www.w3.org/TR/rdf-schema/ • OWL 2.0 – https://www.w3.org/TR/owl2-overview/

3/15/20 Christophe Debruyne 51