Module de "Web sémantique"
Série d’exercices n° 03 : Introduction à RDF
Exercice 1:
Ecrire le document RDF qui décrit les personnes : (nom, prénom, date de naissance, etc.)
Solution
D’abord le prolog XML :
<?xml version="1.0" encoding="UTF-8"?>
Ensuite les vocabulaires dont on a besoin:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:bio="http://purl.org/vocab/bio/0.1/"
xmlns:dc="http://purl.org/dc/terms/"
xmlns:lang="http://purl.org/net/inkel/rdf/schemas/lang/1.1#"
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
xmlns:doac="http://ramonantonio.net/doac/0.1/"
xmlns:menow="http://schema.peoplesdns.com/menow/"
xmlns:sioc="http://rdfs.org/sioc/ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:admin="http://webns.net/mvcb/"
xmlns:rel="http://purl.org/vocab/relationship/">
Ce qu’il faut retenir ici est qu’on besoin de FOAF mais il faut savoir que FOAF lui-même utilise
d’autres vocabulaires donc mieux tout importer.
Définir l’URI :
<foaf:Person rdf:ID="http://www.univ-annaba.dz/foaf/exercice1.rdf">
</foaf:Person>
Remplissant à présent cet élément par les informations d’une personne:
<foaf:name>Ali Mohamed</foaf:name> nom, prénom et titre
<foaf:title>M.</foaf:title>
<foaf:givenname>Ali</foaf:givenname> le prénom
<foaf:family_name>Mohamed</foaf:family_name> le nom
<foaf:nick>SnaKe</foaf:nick> le surnom ou pseudo
<foaf:mbox_sha1sum>d14930bd11472c1b9d3b5604aa7c3d231a69a030</foaf:mbox_sha1sum>
adresse email codée en SHA-1
<foaf:dateOfBirth>1987-06-19</foaf:dateOfBirth> la date de naissance
<foaf:homepage rdf:resource="http://univ-annaba.dz/" dc:title="Page
personnelle"/> la page personnlle
<foaf:weblog rdf:resource="http://blog.univ-annaba.dz/m.ali/"/> le blog
<foaf:img rdf:resource="http://www.univ-annaba.dz/foaf/AliMohamed.jpg"/> la photo
<foaf:schoolHomepage rdf:resource="http://www.univ-montp2.fr/"/> site de l’école
<foaf:gender>male</foaf:gender> le genre
Toutes ces informations doivent être entre <person> et < /person>
Refaire la même chose pour toutes les personnes qu’on veut décrire.
Une fois toutes les personnes décrites on ferme le document RDF par : </rdf:RDF>
Remarques :
Ainsi, avec toutes ces informations, on peut connaître le site personnel, la date de naissance, une photo,
le nom, le surnom, etc. l’adresse email, elle, est hachée par l'algorithme SHA-1. Mais comment interpréter
ces informations sous forme de triplets. c'est simple, voyons ça avec le nom et le site personnel.
Avec le nom :
sujet : http://www.univ-annaba.dz/foaf/exercice1.rdf ;
prédicat : foaf:name ;
objet : Ali Mohamed.
Et maintenant le site personnel :
sujet : http://www.univ-annaba.dz/foaf/exercice1.rdf ;
prédicat : foaf:homepage ;
objet : https://univ-annaba.dz.
Mais, dans ce dernier, il y a deux informations, on y trouve aussi le titre de mon site personnel, mais sous
quelle forme ?
sujet : http://www.univ-annaba.dz/foaf/exercice1.rdf ;
prédicat : dc:title ;
objet : page personnelle.
Exercice 2 :
Ici un exemple d’un document RDF avec dublin core, essayez de le décortiquer.
<?xml version=“1.0“ encoding=“UTF-8“ ?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cd="http://www.recshop.fake/cd#">
<rdf:Description
rdf:about="http://www.rechshop.fake/cd/Empire Burlesque">
<cd:artist>Bob Dylan</cd:artist>
<cd:country>USA</cd:country>
<cd:company>Columbia</cd:company>
<cd:price>10.90</cd:price>
<cd:year>1985</cd:year>
</rdf:Description>
<rdf:Description
rdf:about="http://www.rechshop.fake/cd/Hide your heart">
<cd:artist>Bonnie Tyler</cd:artist>
<cd:country>UK</cd:country>
<cd:company>CBS Records</cd:company>
<cd:price>9.90</cd:price>
<cd:year>1988</cd:year>
</rdf:Description>
<!-- more cds -->
</rdf:RDF>