1 of 41

RESOURCES DESCRIPTION FRAMEWORK (RDF)

Hala Skaf-Molli, Prof

Responsable ALMA

Hala.Skaf@univ-nantes.fr

http://pagesperso.ls2n.fr/~skaf-h

Responsable GDD

Gestion de données distribuées

LS2N, Bât 34, Bureau 403

1

2 of 41

Open Knowledge Graphs

and Semantic Web

2

Knowledge representation model

Semantic Web Stack

Query language to retrieve information from KGs.

3 of 41

Uniform Resource Identifier (URI)

  • Entities uniquely identified, worldwide
  • The same entity can have multiple identifiers, but the same identifier shall always mean the same entity

3

Nantes

Nantes

Nantes City

4 of 41

  • A Uniform Resource Identifier (URI) is a string of characters (ASCII) used to identify a resource on the Internet
  • A URI can take the form of a URL

4

URI Standard

5 of 41

  • An Internationalized Resource Identifier is a generalization of a URI that allows a much wider range of characters Unicode (including accents, non-Latin alphabets, etc.)

5

IRI Standard

Script

IRI (human-readable)

URI

Latin

http://dbpedia.org/resource/Nantes

http://dbpedia.org/resource/Nantes

Arabic

http://مثال.إختبار/نانت|

http://xn--mgbh0fb.xn--kgbechtv/%D9%86%D8%A7%D9%86%D8%AA

Chinese

http://例子.测试/南特

http://xn--fsqu00a.xn--0zwm56d/%E5%8D%97%E7%89%B9

6 of 41

  • World Wide Web Consortium (W3C) Recommendation since 1998
  • RDF is a data model
    • Originally used for metadata for web resources, then generalized
    • Basic unit is triple.

6

Resource Description Framework

for Knowledge Representation

7 of 41

Resource Description Framework

for Knowledge Representation

7

Facts are stored in triple format (subject predicate object).

Semantic Web Stack

8 of 41

An RDF Triple has a subject, a predicate and an object.

8

Nantes

identifies

identifies

the relationship between two resources

identifies

Pays de la Loire

What is an RDF triple ?

9 of 41

  • Subject : URI or blank node (unnamed individual)
  • Predicate (property, relationship): URI
    • locatedIn”, “birthPlace”, “written by”, “age”, “title”, etc.
  • Object : URI, blank node or Literals

9

Nantes

identifies

identifies

locatedIn

“Pays de la Loire”

What is an RDF triple?

10 of 41

  • An RDF triple asserts a property of a resource
  • In English: Nantes is located in Pays de la Loire
  • In Logic: locatedIn(Nantes,Pays de la Loire)

10

identifies

identifies

identifies

locatedIn

Pays de la Loire

Nantes

What is an RDF triple ?

11 of 41

  • An RDF graph is a set of RDF triples
  • RDF Graph is labeled directed graph:
    • Subject and object of a triple correspond to nodes
    • Predicate corresponds to directed edge from subject to object with a label given by the predicate.

11

locatedIn

What is an RDF graph ?

12 of 41

12

Nantes

Pays de La Loire

locatedIn

Example of an RDF Graph

13 of 41

13

Nantes

Pays de La Loire

locatedIn

44109

inseeCode

France

283025

population

hasMayor

Johanna Rolland

47.218100

latitude

locatedIn

14 of 41

14

14

Nantes

Pays de La Loire

locatedIn

44109

inseeCode

France

locatedIn

283025

population

hasMayor

Johanna Rolland

47.218100

latitude

15 of 41

15

15

Nantes

Pays de La Loire

locatedIn

44109

inseeCode

France

locatedIn

283025

population

hasMayor

Johanna Rolland

47.218100

latitude

Jules Verne

Nantes

birthPlace

Voyage au centre de la terre

is birthPlace Of

wrote

RDF Data set

16 of 41

16

16

Nantes

Pays de La Loire

locatedIn

44109

inseeCode

France

locatedIn

283025

population

hasMayor

Johanna Rolland

47.218100

latitude

Jules Verne

Nantes

birthPlace

Voyage au centre de la terre

is birthPlace Of

wrote

Owl:sameAS

17 of 41

17

Linked Open Data knowledge Graph

18 of 41

18

19 of 41

19

20 of 41

These principles have been coined by Tim Berners-Lee in the design issue note Linked Data. The principles are:

    • Use URIs as names for things
    • Use HTTP URIs so that people can look up those names.
    • When someone looks up a URI, provide useful information.
    • Include links to other URIs. so that they can discover more things.

Source: https://www.w3.org/wiki/LinkedData

20

Linked Data Principles

21 of 41

21

22 of 41

22

23 of 41

  • Turtle
  • RDF/XML
  • N-Quads
  • N-Triples
  • JSON-LD
  • RDFa (RDF in HTML)

23

RDF can be serialized in different ways

24 of 41

  • A namespace prefix is an abbreviation for the prefix of a URI.

@prefix city : http://dbpedia.org/resource/

@prefix location: http://lodpaddle.org/

@prefix region: http://region.org/

24

city:Nantes location:locatedIn region:Paysdelaloire

Namespace Prefixes

25 of 41

  • The default namespace prefix is just a colon.

@prefix :< http://dbpedia.org/resource/>.

@prefix location: <http://lodpaddle.org/rdf/pred#>.

@prefix region: <http://region.org/>.

25

:Nantes location:locatedIn region:Paysdelaloire

Default Prefix

26 of 41

RDF Turtle:

@prefix : <http://lodpaddle.org/> .

@prefix admin: <http://admin.org/>.

:Nantes :population “283025” .

:Nantes admin:hasMoyer :JohannaRolland.

:Nantes :locatedIn <http://region.org/PaysdeLaLoire> .

26

Nantes

Pays de La Loire

locatedIn

283025

population

hasMayor

Johanna Rolland

RDF Turtle

27 of 41

Turtle

@prefix foaf: <http://xmlns.com/foaf/0.1/> .

@prefix ex: <http://example.org/> .

ex:Alice a foaf:Person ;

foaf:name "Alice" ;

foaf:knows ex:Bob .

ex:Bob a foaf:Person ;

foaf:name "Bob" .

27

JSON-LD

JSON-LD : JavaScript Object Notation for Linked Data (compact)

{

"@context": {

"foaf": "http://xmlns.com/foaf/0.1/",

"name": "foaf:name",

"knows": "foaf:knows",

"type": "@type"

},

"@id": "http://example.org/Alice",

"type": "foaf:Person",

"name": "Alice",

"knows": {

"@id": "http://example.org/Bob",

"type": "foaf:Person",

"name": "Bob"

}

}

28 of 41

  • RDF can also be stored in XML format

<?xml version="1.0"?>

<rdf:RDF

xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

xmlns:prop=“http://lodpaddle.org/” >

<rdf:Description rdf:about=“http://lodpadlle.org/Nantes”>

<prop:location rdf:resource=“http://region.org/paysdelaloire” />

</rdf:Description>

</rdf:RDF>

28

Properties of X are listed inside an rdf:Description about=X

Namespaces become XML namespaces

RDF/XML Syntax

29 of 41

List of triples, easy to download and to parse.

<http://lodpaddle.org/Nantes> <http://admin.org/population> “283025” .

<http://lodpaddle.org/Nantes> <http://admin.org/hasMoyer> <http://admin.org/JohannaRolland .

29

Nantes

283025

population

hasMayor

Johanna Rolland

RDF N-Triples

30 of 41

A triple <s,p,o> is interpreted as a First Order Logic fact p(s,o).

locatedIn(Nantes,Pays de la Loire)

hasMayor(Nantes, Johanna Rolland)

population(Nantes,”283025”)

30

Nantes

Pays de La Loire

locatedIn

283025

population

hasMayor

Johanna Rolland

RDF Semantics

31 of 41

  • First order logic(FOL): A triple <s p o> without blank node is interpreted as P(s,o) : grounded atomic formula
  • Blank nodes in subject or object are interpreted as existential variables
  • Example:

      • :Pierre foaf:knows _:p .
      • _:p foaf:name “John Smith” .
      • _:p dc:wrote _:b .
      • _:b dc:title “Introduction to Java” .

31

RDF Semantics

32 of 41

@prefix p: <http://lodpaddle.or/> .

@prefix rdf: <http://w3c.org/1999/02/22-rdf-syntax-ns#>.

@prefix xsd: <http://www.w3c.org/2001/XMLSchema# >.

p:Nantes p:poplulation “283025”^^xsd:integer ;

p:hasMoyer p:JohannaRolland ;

rdf:type p:City .

P:Rennes p:population “208022”^^xsd:integer;

p:hasMayor p:NatalieAppéré .

32

Use XML types

33 of 41

The predicate rdf:type relates resources to their classes

@prefix p: <http://lodpaddle.or/> .

@prefix rdf: <http://w3c.org/1999/02/22-rdf-syntax-ns#>.

@prefix xsd: <http://www.w3c.org/2001/XMLSchema# >.

p:Nantes p:poplulation “283025”^^xsd:integer ;

p:hasMoyer p:JohannaRolland ;

rdf:type p:City .

33

Type of a resource

34 of 41

@prefix book: <http://example.org/>

book:42 book:title    ’’Life Questions@en’’ .

book:42 book:title   ’’Questions sur la vie@fr’’ .

34

Identifier the language of a value

35 of 41

35

Identifier the language of a value

36 of 41

  • A named Graph gives a context for a set of triples
  • Identifier a set of triples by an URI
  • Two formats : TriG and N-Quads

36

Named Graph

37 of 41

TriG: extension of Turtle

@prefix foaf : <http://xmlns.com/foaf/0.1/> .

GRAPH <http://example.org/bob>

{

_:b foaf:name ‘’Bob’’ .

}

GRAPH <http://example.org/alice>

{

_:a foaf:name ‘’Alice’’ .

}

37

Named Graph in TriG

38 of 41

N-quads statements are a sequence of RDF terms representing the subject, predicate, object and graph label of an RDF Triple

@prefix foaf : <http://xmlns.com/foaf/0.1/> .

_:b foaf:name ‘’Bob’’ <http://example.org/bob >.

_:a foaf:name ‘’Alice’’ <http://example.org/alice> .

38

Named Graph in N-Quads

39 of 41

RDF is flexible, schema-free to represent knowledge as triples (subject predicate object)

39

dbr:Jules_Verne rdf:type schema:Person;

dbo:birthPlace dbr:Nantes;

dbo:birthDate "1828-02-08";

dbo:author dbr:Around_the_World_in_Eighty_Days,

dbr:From_the_Earth_to_the_Moon;

dbp:nationality "French";

owl:sameAs wikidata:Jules_Verne.

……..

@prefix dbr:<http://dbpedia.org/resource/> .

@prefix rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

@prefix schema: <http://www.schema.org/>.

@prefix dbo:<http://dbpedia.org/ontology/>.

@prefix owl: <http://www.w3.org/2002/07/owl#> .

URI: <http://dbpedia.org/resource/Jules_Verne>

40 of 41

  • RDF is domain-independent
  • RDF is bottom-up
  • RDF has a graph-based data model
  • RDF has a decentralized philosophy and allows incremental building of knowledge, and its sharing and reuse
  • Linked data is a giant, global data graph defined in RDF

40

RDF Advantages

41 of 41

  • TD RDF (OLD)
  • Sujet Projet Dana
  • SPARQL

41

TD/Project and Next lecture