2 Cours RDF BE 4P
2 Cours RDF BE 4P
Plan
§ 1. Introduction à RDF
§ Vers un Web plus structuré
§ Un modèle pour représenter les métadonnées
§ Graphe RDF
§ Identification des entités/ressources – IRI
§ Littéraux et nœuds blancs
§ 2. Sérialisations RDF
§ Sérialisation RDF/XML
§ Sérialisation N-Triples
§ Sérialisation Turtle
§ 3. Agrégations en RDF 1. Introduction à RDF
§ Collections
§ Containers § Vers un Web plus structuré
§ 4. Conclusion § Un modèle pour représenter les métadonnées
§ Sémantique de RDF
§ Inférences dans RDF
§ Graphe RDF
§ Vocabulaire RDF § Identification des entités/ressources – IRI
§ Langages de requête autour de RDF : SPARQL § Littéraux et nœuds blancs
§ Intérêts et limitations de RDF
§ 5. Exemple de base RDF
§ Objectif général :
RDF
Le modèle de données
8 / 24
Nœuds blancs (1) Nœuds blancs (2)
rdf §:Les
etentités
si la(IRIs)
ressource n’a pas d’uri ?
Noeuds§ Ilblancs et les littéraux sont suffisant pour décrire un graphe RDF Les noeuds
Lesvides
noeudssont
videségalement
ou nœud blancutilisées pourutilisés
sont également grouper des informations
pour grouper des
se peut que l’on ne dispose pas d’IRI pour la ressource dont on souhaite parler. Par informations, correspondant à l’expression d’une relation n-aire
Il se peut que dans
exemple, l’onles
neréseaux
dispose pasond’uri
sociaux, pourpaslad’IRI
ne dispose ressource dont on souhaitecomme dans l’exemple ci-dessous
pour les membres.
I §Les
parler. Parentités
On crée alors (IRIs)
exemple, un noeud
dansetblanc
les
les littéraux sontnoeud
(ou noeud vide,
réseaux suffisants
sociaux, anonyme,pour
“blankdécrire
on ne dispose node”). un
pas d’uri Exemple : utilisation d’un nœud blanc pour modéliser une adresse
§graphe
Ces noeudsRDF, mais
blancs parfois
peuvent il
être vus peut
commeêtre pratique
des variables d’utiliser des noeuds
pour les membres.
Parfois le nœud à
On crée d’un
l’extrémité
alorsarc
un
est
noeud
une
vide
simple
(noeud
valeur (un
blanc,
nombre, une
noeud
date, ...),
qui ne sont pas référencés globalement : on les appelle des noeuds
anonyme, “blank node”). on utilise alors des littéraux.
blancs.
Exemple : Utilisation de nœuds blancs dans un réseau social :
I Ces noeuds blancs peuvent être vus comme des variables
Une personne de nom Toby Segaran auteur du blog kiwitobes connait une personne nommée
Jamie Taylor dont l’email est [email protected]
Une personne
Introduction à RDF -de nom
Bernard Toby
ESPINASSE - Segaran auteur du blog kiwitobes connaı̂t
15 une Introduction à RDF - Bernard ESPINASSE - 16
§ Soit le graphe G1 :
<ex:un_sujet> <ex:une_propriete> <ex:un_objet> .
Triplés associés :
§ Le graphe G2 ci-dessous est une réification de G1 :
• Triplet 1 : (#declaration, rdf:subjet, Livre)
_:xxx rdf:type rdf:Statement . • Triplet 2 : (#declaration, rdf:predicate, Titre)
• Triplet 3 : (#declaration, rdf:objet, "Le Web sémantique")
_:xxx rdf:subject <ex:un_sujet> . • Triplet 4 : (#declaration, Attribué, #Fabien)
_:xxx rdf:predicate <ex:une_propriete> . • Triplet 5 : (#declaration, rdf:type, rdf:statement)
11 / 24
2. Sérialisations RDF
§ Sérialisation RDF/XML
§ Sérialisation N-Triples Les plus connus :
• RDF/XML
§ Sérialisation Turtle • N-Triples
• Turtle
On peut passer de l’un à l’autre (http://www.easyrdf.org/converter )
3
http://www.univ-
amu.fr/cours/LIS125
http://www.univ-amu.fr/professeur genid:A62360 Sérialisation Turtle
4 genid:A62360 http://xmlns.com/foaf/0.1/name "bernard espinasse"
Utilisation de l’outil Easyrdf (http://www.easyrdf.org/converter ):
Container
§ Il est fréquent de devoir faire référence à plusieurs ressources (par
exemple : un livre écrit par plusieurs auteurs).
§ Les containers permettent de décrire des groupes
§ Les choses contenues dans un container sont appelées « membres du
groupe »
§ Il existe 3 types de containers prédéfinis :
§ rdf:Bag : liste non ordonnée de ressources ou de littéraux - multi-
ensemble de ressources ou littéraux
§ rdf:Seq : liste ordonnée de ressources ou de littéraux
3. Agrégations en RDF § rdf:Alt : liste de ressources ou de littéraux qui représentent des
alternatives pour une valeur unique
§ Containers § Pour indiquer qu’une ressource est un container, on utilise la propriété
§ Collections rdf:type
§ Remarques :
§ Les containers sont ouverts, i.e. il peut exister d’autres membres du container
que ceux indiqués par la description dont on dispose (qui s’y rajoutent …)
§ Les éléments du conteneur sont listés à l’aide de l’élément li ou _i avec (i > 0)
§ Pour le container alternative il doit y avoir au moins un élément _1 (élément par
défaut)
Container: Bag
a rdf:Bag; select ?student where {
rdf:_1 stu:Amy; crs:6.001 s:students [
rdf:_2 stu:Mohamed; rdfs:member ?student;
rdf:_3 stu:Johann; ]
rdf:_4 stu:Maria; }
rdf:_5 stu:Phuong;
].
Container: Seq
crs:6.001 s:DistributionSite
<s:students> [
s:students [ a rdf:Alt;
<rdf:Bag>
a rdf:Bag; rdf:_1 <rdf:li
<ftp://ftp.example.org>;
rdf:resource="http://example.org/students/Amy"/>
rdf:_1 stu:Amy; rdf:_2 <rdf:li
<ftp://ftp1.example.org>;
rdf:resource="http://example.org/students/Mohamed"/>
Container: Alt
rdf:_2 stu:Mohamed; rdf:_3 <rdf:li
<ftp://ftp2.example.org>;
rdf:resource="http://example.org/students/Johann"/>
rdf:_3 stu:Johann; ]. <rdf:li rdf:resource="http://example.org/students/Maria"/>
rdf:_4 stu:Maria; <rdf:li rdf:resource="http://example.org/students/Phuong"/>
rdf:_5 stu:Phuong; § Interrogation du Alt en SPARQL sur Turtle :
</rdf:Bag>
].
Figure 14 du RDF Primer
</s:students>
select ?coll ?type ?elem where {
</rdf:Description>
</rdf:RDF> ?coll ?pred [a ?type;
rdfs:member ?elem]
}
Collection
stu:MohamedL1 ).
stu:JohannL1 Ou pour le cours 6.0002 (liste2-L2) :
). crs:6.002 s:students _:v0.
_:v0
rdf:first stu:AmiL2;
rdf:rest _:v1.
_:v1
rdf:first stu:MohamedL2;
rdf:rest _:v2.
_:v2
crs:6.002 s:students _:v0. rdf:first stu:JohannL2;
rdf:rest _:nil.
_:v0
rdf:first stu:AmiL2;
Introduction à RDF - Bernard ESPINASSE - rdf:rest
35 _:v1. Introduction à RDF - Bernard ESPINASSE - 36
_:v1
rdf:first stu:MohamedL2; <?xml version="1.0"?>
rdf:rest _:v2. <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
_:v2 xmlns:s="http://example.org/students/vocab#">
rdf:first stu:JohannL2;
Collections (4): exemple
§ Collection : quand la valeur d’une propriété est une collection de valeurs :
§ Exemple : soit le cours LIS125 :
<rdf:Description rdf:about=‘http://www.amu.fr/cours/LIS125’>
<ns:staff>
<rdf:Bag>
<rdf:li>Bernard Espinasse</rdf:li>
<rdf:li>Sébastien Fournier</rdf:li>
<rdf:li>Adrian Chifu</rdf:li>
</rdf:Bag>
4. Exemple d’une base RDF
</ns:staff> § Description d’un livre et de ses auteurs
</rdf:Description>
Description RDF d'un livre et son auteur : XML Description RDF d'un livre et son auteur
§ La ressource « Livre » a pour valeur pour la propriété « Titre » le littéral ou valeur
« Dune » ce qui donne le triplet RDF (Livre, Title, Dune), en XML : Pour distinguer dans la valeur de l’auteur « Frank Herbert » le nom du
<rdf:RDF prénom :
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" Livre
xmlns:dc= "http://purl.org/dc/elements/1.1/" > Title
§ On définie la propriété « Name » et la propriété « FirstName »
<rdf:Description rdf:about="Livre">
<dc:Title>Dune</dc:Title> Dune
§ On créé un noeud blanc (anonyme) « #Auteur1 »
</rdf:Description>
</rdf:RDF> § On caractérise ce nœud anonyme par les propriétés « Name » et
« FirstName »
§ Une autre propriété « Auteur » peut être associée à la ressource Livre, avec la valeur
« Frank Herbert », on a le triplet (Livre, Creator, Frank Herbert) : § On a ainsi les 3 triplets RDF : Livre
<rdf:RDF Creator
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" (Livre, Creator, #Auteur1) Auteur1
xmlns:dc= "http://purl.org/dc/elements/1.1/" > Livre
Name FirstName
<rdf:Description rdf:about="Livre"> Creator
(#Auteur1, Name, Herbert)
<dc:Title>Dune</dc:Title> Herbert Frank
<dc:Creator>Frank Herbert</dc:Creator> Frank
(#Auteur1, FirstName, Frank)
Herbert
</rdf:Description>
Description RDF d'un livre et ses auteurs (2) : Triplets Description RDF d'un livre et ses auteurs (2) : XML
<?xml version="1.0" encoding="utf-8" ?>
Considérons le livre L’Homme de deux mondes qui est le premier roman écrit par Frank <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:ns0="http://www.monvoc.">
Herbert (disparu en 1986), en collaboration avec son fils Brian :
<rdf:Description rdf:about="http://#livre1">
<ns0:frauteur rdf:resource="http://auteur1"/>
<ns0:frtitre>Dune</ns0:frtitre>
Triplets RDF Graphe RDF </rdf:Description>
<rdf:Description rdf:about="http://#livre2">
<ns0:frauteur rdf:resource="http://auteur1"/>
(Livre, auteur, #Auteur1) <ns0:frauteur rdf:resource="http://auteur2"/>
Livre Auteur2
(Livre, auteur, #Auteur2) auteur <ns0:frtitre>L'homme de deux mondes</ns0:frtitre>
</rdf:Description>
(Livre, titre, L’homme des deux fils
mondes) auteur
nom <rdf:Description rdf:about="http://#auteur1">
prenom <ns0:frprenom>Frank</ns0:frprenom>
(#Auteur1, nom, Herbert) titre Auteur1 <ns0:frnom>Herbert</ns0:frnom>
(#Auteur1, prenom, Frank) Herbert Brian <ns0:frage rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">70</ns0:frage>
</rdf:Description>
(#Auteur2, nom, Herbert) nom
prenom age
</rdf:RDF>
<http://njh.me/Livre>
dc11:Creator <http://njh.me/Auteur1>, <http://njh.me/Auteur2> ;
dc11:Title " L’homme des deux mondes " .
<http://njh.me/#Auteur1>
ns0:orgFirstName " Frank " ;
ns0:orgName " Herbert " .
<http://njh.me/#Auteur2>
ns0:orgFirstName " Brian " ;
ns0:orgName " Herbert " ;
ns0:orgFils <http://njh.me/Auteur1> .
Description RDF d'un livre et ses auteurs (2) : Triplets Description RDF d'un livre et ses auteurs (2) :
simplifications
Triplets RDF associés (RDF Validator: https://www.w3.org/RDF/Validator/ ) :
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
Nb Subject Predicate Object
1 http://www.w3.org/RDF/Validator/run/Livre http://purl.org/dc/elements/1.1/Creator http://www.w3.org/RDF/Validator/run/Auteur1
xmlns:dc= "http://purl.org/dc/elements/1.1/"
2 http://www.w3.org/RDF/Validator/run/Livre http://purl.org/dc/elements/1.1/Creator http://www.w3.org/RDF/Validator/run/Auteur2 xmlns:ex= "http://monexemple.org.">
3 http://www.w3.org/RDF/Validator/run/Livre http://purl.org/dc/elements/1.1/Title "L’homme des deux mondes" <rdf:Description rdf:about="Livre">
http://www.w3.org/RDF/Validator/run/1569169791 <dc:auteur rdf:resource="Auteur1"/>
4 http://monexemple.orgFirstName "Frank"
477#Auteur1
http://www.w3.org/RDF/Validator/run/1569169791 <dc:auteur rdf:resource="Auteur2"/>
5 http://monexemple.orgName "Herbert"
477#Auteur1 <dc:titre> L’homme des deux mondes </dc:titre>
http://www.w3.org/RDF/Validator/run/1569169791
6
477#Auteur2
http://monexemple.orgFirstName "Brian" </rdf:Description>
http://www.w3.org/RDF/Validator/run/1569169791 <rdf:Description rdf:ID="Auteur1">
7 http://monexemple.orgName "Herbert"
477#Auteur2 <ex:prenom> Frank </ex:prenom>
http://www.w3.org/RDF/Validator/run/1569169791 http://www.w3.org/RDF/Validator/run/Aute
8
477#Auteur2
http://monexemple.orgFils
ur1
<ex:nom> Herbert </ex:nom>
</rdf:Description>
<rdf:Description rdf:ID="Auteur2">
<ex:prenom> Brian </ex:prenom>
<ex:nom> Herbert </ex:nom>
<ex:fils rdf:ressource= "Auteur1" />
</rdf:Description>
</rdf:RDF>
<http://njh.me/Livre>
dc11:auteur <http://njh.me/Auteur1>, <http://njh.me/Auteur2> ;
dc11:titre " L’homme des deux mondes " .
<http://njh.me/#Auteur1>
ns0:prenom " Frank " ; 5. Conclusion
ns0:nom " Herbert " .
§ Sémantique de RDF
<http://njh.me/#Auteur2> § Inférences dans RDF
ns0:prenom " Brian " ; § Vocabulaire RDF
ns0:nom " Herbert " ; § Langages de requête autour de RDF : SPARQL
ns0:fils <http://njh.me/Auteur1> . § Intérêts et limitations de RDF
Limitations :
§ RDF permet de définir des graphes étiquetés - Graphes RDF, en utilisant
des ressources du web sans vraiment de sémantique
§ Pour donner de la sémantique des étiquettes du graphe RDF, il faut des
vocabulaires mieux définis (méta-données)
§ Pour formaliser cette sémantique il faut utiliser des ontologies