[Pellet-Users] SPARQL + realization
Ibach, Brandon L
brandon.l.ibach at lmco.com
Tue Sep 12 22:11:41 EDT 2006
Try something like the following, which looks for statements
declaring subclasses of the individual's type that are not the type
itself or owl:Nothing. The final FILTER makes the query return only
those types that have no such subclasses.
I suppose there might be a simpler way to do this, but this
seems to work on the Pellet web interface, anyway.
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX : <http://www.owl-ontologies.com/Ontology1157471786.owl#>
SELECT DISTINCT ?obj ?type ?rel
WHERE {
?obj :relatedTo ?rel.
?obj rdf:type ?type.
OPTIONAL {
?sc rdfs:subClassOf ?type.
FILTER (?sc != ?type && ?sc != owl:Nothing) }.
FILTER (!bound(?sc))
}
-Brandon :)
-----Original Message-----
From: pellet-users-bounces at lists.mindswap.org
[mailto:pellet-users-bounces at lists.mindswap.org] On Behalf Of Hugo
Ferreira
Sent: Monday, September 11, 2006 8:21 AM
To: pellet-users at lists.mindswap.org
Subject: [Pellet-Users] SPARQL + realization
Hi,
After experimenting with Jena's DIG interface and the web interface to
Pellet at http://www.mindswap.org/2003/pellet/demo.shtml to execute a
SPARQL query, I have realized that the result is not quite what I
require. I put the same question to the Jena list but did not find a
solution. I am therefore placing this question here.
Simply put I select instances based on their type but because of
inference I get multiple entries, each of which pertains to a sub-class
of the concept in question. Now I read an article on Pellet [1] and know
that this reasoner is aware of the most specific classes that an
instance belongs to (realization). I am also aware that the DIG
interface has certain limitation. I also know that Pellet itself has its
own SPARQL engine. My question is: is their any way I can execute SPARQL
queries so that I only have the most specific concepts of an instanced
returned to me. If so how? If not are their any suggestion on how to
(efficiently) filter the unwanted results?
To make thing clearer I have the query (owl source included at the end):
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX :
<http://www.owl-ontologies.com/Ontology1157471786.owl#>
SELECT DISTINCT ?obj ?type ?rel
WHERE {
?obj :relatedTo ?rel.
?obj rdf:type ?type.
}
which returns
-------------------------
| obj | type | rel |
=========================
| :d1 | :B | :f1 |
| :d1 | :D | :f1 |
| :d1 | :C | :f1 |
| :d1 | owl:Thing | :f1 |
| :d2 | :B | :f2 |
| :d2 | :D | :f2 |
| :d2 | :C | :f2 |
| :d2 | :A | :f2 |
| :d2 | owl:Thing | :f2 |
-------------------------
But require only:
--------------------
| obj | type | rel |
====================
| :d2 | :D | :f2 |
| :d1 | :D | :f1 |
--------------------
[1] Pellet: A Practical OWL-DL Reasoner
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns="http://www.owl-ontologies.com/Ontology1157471786.owl#"
xml:base="http://www.owl-ontologies.com/Ontology1157471786.owl">
<owl:Ontology rdf:about=""/>
<owl:Class rdf:ID="C">
<rdfs:subClassOf>
<owl:Class rdf:ID="B"/>
</rdfs:subClassOf>
</owl:Class>
<owl:Class rdf:ID="A">
<owl:disjointWith>
<owl:Class rdf:ID="E"/>
</owl:disjointWith>
</owl:Class>
<owl:Class rdf:about="#E">
<owl:disjointWith rdf:resource="#A"/>
</owl:Class>
<owl:Class rdf:ID="D">
<rdfs:subClassOf rdf:resource="#C"/>
</owl:Class>
<owl:Class rdf:about="#B">
<rdfs:subClassOf rdf:resource="#A"/>
</owl:Class>
<owl:Class rdf:ID="F">
<rdfs:subClassOf rdf:resource="#E"/>
</owl:Class>
<owl:ObjectProperty rdf:ID="relatedTo">
<rdfs:domain rdf:resource="#A"/>
<rdfs:range rdf:resource="#E"/>
</owl:ObjectProperty>
<owl:AllDifferent>
<owl:distinctMembers rdf:parseType="Collection"> <D rdf:ID="d1">
<relatedTo> <F rdf:ID="f1"/> </relatedTo> </D> <D rdf:ID="d2">
<relatedTo> <F rdf:ID="f2"/> </relatedTo> </D> </owl:distinctMembers>
</owl:AllDifferent> <owl:AllDifferent> <owl:distinctMembers
rdf:parseType="Collection"> <F rdf:about="#f1"/> <F rdf:about="#f2"/>
</owl:distinctMembers> </owl:AllDifferent> </rdf:RDF>
<!-- Created with Protege (with OWL Plugin 2.2, Build 331)
http://protege.stanford.edu -->
_______________________________________________
Pellet-Users mailing list
Pellet-Users at lists.mindswap.org
http://lists.mindswap.org/mailman/listinfo/pellet-users
More information about the Pellet-Users
mailing list