- From: Alexandre Passant <alex@passant.org>
- Date: Wed, 11 Oct 2006 19:44:16 +0200
- To: public-sparql-dev@w3.org
Hi all,
I have some ontologies (Proton modules [1]) in a triplestore (3store
[2]), and using SPARQL, I'd like to find all properties that can exist
between 2 instances - that are also in the store.
So, what I need to do basically is - am I right btw ?:
1) find types of these instances (direct and inferred ones - as the
store do inference for instances type);
2) find all properties that have these types as domain/range
3) return all subproperties of the previous one (as I do not infer
suproperty inheritance in the store, so some properties are not
retrieved by 2)
The following query works fine:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?property
WHERE {
// 1)
<http://foobar#instance1> rdf:type ?domain .
<http://foobar#instance2> rdf:type ?range .
// 2)
_:p rdfs:domain ?domain .
_:p rdfs:range ?range .
// 3)
?property rdfs:subPropertyOf _:p .
}
(+ Union to get domain / range inverse)
Yet, in the original ontology, some subproperties got an additionnal
domain / range that conflict with the type of instances. Eg, I got
this in my ontology:
Person rdfs:subClassOf Agent
Group rdfs:subClassOf Agent
Company rdfs:subClassOf Group
hasMember rdfs:domain Group
hasMember rdfs:range Agent
hasEmployee rdfs:subPropertyOf hasMember
hasEmployee rdfs:range Person
So the query before applied to Company instances will return
hasEmployee which _shouldn't_ be applied between 2 companies (This is
what is done in Protege where hasEmployee exists only between Group
and Person, but using RDFS inference rules, it should exist ?. Maybe I
missed something here ?
What I want to do to avoid this problem is to remove from query
results the properties that got a domain / range which is not a
superclass (or the class itself) of the direct type of my instances.
First, is that the good way to do ? I can't see any other solution for
this at the moment.
To do so, my query must:
1) find direct type of these instances
2) find all types of these instances
3) find all properties that have these types as domain/range
4) find all subproperties of the previous one
5) remove subproperties where domain or range is not a parent of "1"
I make a query that works until 4, but I can see how to remove
properties I don't want, because of this:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX direct: <http://triplestore.aktors.org/direct/#>
SELECT DISTINCT ?p ?domain ?range
WHERE {
// 1)
<http://foobar#instance1> direct:type _:direct_subject_type .
<http://foobar#instance2> direct:type _:direct_object_type .
// 2)
<http://foobar#instance1> rdf:type _:subject_type .
<http://foobar#instance2> rdf:type _:subject_type .
// 3)
_:property rdfs:domain _:subject_type .
_:property rdfs:range _:object_type .
// 4)
?p rdfs:subPropertyOf _:property .
// 5)
?p rdfs:subPropertyOf ?z .
?z rdfs:domain ?domain .
?z rdfs:range ?range .
}
Then I should test ?domain / ?range regarding 5), but the problem is
that I got properties that both conflict and are OK:
}, {
"p": {"value":
"http://proton.semanticweb.org/2005/04/protont#subRegionOf", "type":
"uri" },
"domain": {"value":
"http://proton.semanticweb.org/2005/04/protons#Entity", "type": "uri"
},
"range": {"value":
"http://proton.semanticweb.org/2005/04/protont#Location", "type":
"uri" }
}, {
"p": {"value":
"http://proton.semanticweb.org/2005/04/protont#subRegionOf", "type":
"uri" },
"domain": {"value":
"http://proton.semanticweb.org/2005/04/protons#Entity", "type": "uri"
},
"range": {"value":
"http://proton.semanticweb.org/2005/04/protons#Entity", "type": "uri"
}
}, {
subRegionOf should be removed as Location is not a Parent of "Company"
(1 result), yet, Entity is (2nd), so even when adding the subClass
condition between original type and properties, I'll keep the 2nd
result, which I don't want as the 1st is false.
Any idea to solve this ? Or maybe another way to find all properties
that can exist between 2 instances ?
And thanks for those that read this mail totally :)
Best,
Alex.
[1] http://proton.semanticweb.org
[2] http://threestore.sf.net
Received on Thursday, 12 October 2006 02:16:15 UTC