Un cas d'usage avec l'ontologie foaf.
-
L'ontologie foaf
Recopiée de http://xmlns.com/foaf/spec/index.rdf
jean-francois-5:DBPedia jfp$ sh pellet.sh classify
foaf.index.rdf.xml
Classifying 20 elements
Classifying: 100% complete in 00:00
Classifying finished in 00:00
owl:Thing
terms:Agent = foaf:Agent
foaf:Group
foaf:Organization
foaf:Person
rdfs:Class
contact:Person
foaf:Person
wgs84_pos:SpatialThing
foaf:Person
core:Concept
foaf:Document
foaf:Image
foaf:PersonalProfileDocument
foaf:LabelProperty
foaf:OnlineAccount
foaf:OnlineChatAccount
foaf:OnlineEcommerceAccount
foaf:OnlineGamingAccount
foaf:Project
On veut exploiter les hiérarchies Agent > Person
et Document
> Image
.
-
Avec Pellet
- Pour entrer dans le format des exécutions de
pellet.sh
, qui exige qu'on lui donne un ficher-source en argument,
importation de l'ontologie foaf dans la microbase ExWiki
vue comme une A-box : fichier ExWikiU.rdf
<?xml version="1.0" ?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:rss="http://purl.org/rss/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:owl="http://www.w3.org/2002/07/owl#">
<owl:Ontology rdf:about="">
<owl:imports>
<owl:Ontology
rdf:about="http://xmlns.com/foaf/spec/index.rdf"/>
</owl:imports>
</owl:Ontology>
<foaf:Person
rdf:about="http://example.net/Paul_Dupont">
<foaf:name>Paul
Dupont</foaf:name>
<foaf:img
rdf:resource="http://example.net/Paul_Dupont.jpg"/>
<foaf:knows
rdf:resource="http://example.net/Pierre_Dumoulin"/>
</foaf:Person>
<foaf:Person
rdf:about="http://example.net/Pierre_Dumoulin">
<foaf:name>Pierre
Dumoulin</foaf:name>
<foaf:img
rdf:resource="http://example.net/Pierre_Dumoulin.jpg"/>
</foaf:Person>
<foaf:Image
rdf:about="http://example.net/Paul_Dupont.jpg">
<dc:description>Photo
d'identité de Paul Dupont</dc:description>
</foaf:Image>
<foaf:Image
rdf:about="http://example.net/Pierre_Dumoulin.jpg">
<dc:description>Photo
d'identité de Pierre Dumoulin</dc:description>
</foaf:Image>
</rdf:RDF>
- Suppression du champ
FROM
de la requête et modification de types : fichier reqFoafLoc.txt
PREFIX rdf:
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?nom ?image ?description
#FROM
<http://pagesperso-systeme.lip6.fr/Jean-Francois.Perrot/inalco/XML/RDF/ExWiki.rdf>
WHERE {
?personne rdf:type foaf:Agent .
?personne foaf:name ?nom .
?image rdf:type foaf:Document .
?personne foaf:img ?image .
?image dc:description ?description
}
- Exécution : Ça marche !
jean-francois-5:EssaiFoaf jfp$ sh pellet.sh query
-q reqFoafLoc.txt -o XML ExWikiU.rdf
10 mars 2014 22:53:03
org.mindswap.pellet.jena.graph.loader.DefaultGraphLoader
addUnsupportedFeature
ATTENTION: Unsupported axiom: Ignoring subproperty axiom between
http://xmlns.com/foaf/0.1/name (DatatypeProperty) and
http://www.w3.org/2000/01/rdf-schema#label (AnnotationProperty)
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="nom"/>
<variable name="image"/>
<variable name="description"/>
</head>
<results>
<result>
<binding name="nom">
<literal>Paul
Dupont</literal>
</binding>
<binding name="image">
<uri>http://example.net/Paul_Dupont.jpg</uri>
</binding>
<binding name="description">
<literal>Photo
d'identité de Paul Dupont</literal>
</binding>
</result>
<result>
<binding name="nom">
<literal>Pierre
Dumoulin</literal>
</binding>
<binding name="image">
<uri>http://example.net/Pierre_Dumoulin.jpg</uri>
</binding>
<binding name="description">
<literal>Photo
d'identité de Pierre Dumoulin</literal>
</binding>
</result>
</results>
</sparql>
jean-francois-5:EssaiFoaf jfp$
-
Le point d'entrée SPARQLer ne fait pas de déduction ontologique
Essai de la même requête avec champ FROM
:
PREFIX rdf:
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?nom ?image ?description
FROM
<http://pagesperso-systeme.lip6.fr/Jean-Francois.Perrot/inalco/XML/RDF/ExWikiU.rdf>
WHERE {
?personne rdf:type foaf:Agent .
?personne foaf:name ?nom .
?image rdf:type foaf:Document .
?personne foaf:img ?image .
?image dc:description ?description
}