[Pellet-users] problems with sparql rdf query and transitive property
Evren Sirin
evren at clarkparsia.com
Mon Feb 18 15:09:20 UTC 2008
On 2/13/08 6:50 PM, João Paulo Sousa wrote:
> Hi,
>
> Tanks to Evren and to Wolfgang previous previous help.
>
> Now i have this problem. When is run the above query it returns the
> fowling results:
>
> -----------------
> | contains |
> =================
> | dspac:bar |
> | dspac:theater |
> -----------------
>
> I can we see on the ontology, berlin only contains theater and the
> theater contains the bar. Why it return two results? The transitive
> property is a owl feature! Why this is happening?
>
Due to the semantics of transitive properties a contains b, b contains c
would infer a contains c and the reasoner includes this in the query
results.
> How i can exclude the transitive property?
>
You cannot. You need to change your modeling. For example, in addition
to the transitive property isPartOf (resp. contains) define an ordinary
(non-transitive) property isDirectPartOf (resp. directlyContains). Also,
define isDirectPartOf subProperyOf isPartOf. Then you need to make sure
that in your data you only use isDirectPartOf relation. If you want to
query for direct parts use this property in your query. If you want all
the parts then use the transitive property in the query. Note that, this
is a fragile solution that will break if you use the transitive property
in your data.
Cheers,
Evren
> Chears,
>
> João.
>
> PREFIX dspac: <http://icas.ipb.pt/secom/data/spatial.owl#>
> SELECT ?contains
> WHERE {
> dspac:Berlin dspac:contains ?contains .
> }
>
> <?xml version="1.0"?>
>
>
> <!DOCTYPE rdf:RDF [
> <!ENTITY owl "http://www.w3.org/2002/07/owl#" >
> <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
> <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
> <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
> ]>
>
>
> <rdf:RDF xmlns="http://icas.ipb.pt/secom/data/spatial.owl#"
> xml:base="http://icas.ipb.pt/secom/data/spatial.owl"
> xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
> xmlns:owl="http://www.w3.org/2002/07/owl#"
> xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
> <owl:Ontology rdf:about=""/>
> <Room rdf:ID="bar">
> <isPartOf rdf:resource="#theater"/>
> </Room>
> <City rdf:ID="Berlin">
> <contains rdf:resource="#theater"/>
> </City>
> <Person rdf:ID="bill">
> <hasLocation rdf:resource="#theater"/>
> </Person>
> <owl:Class rdf:ID="Building">
> <rdfs:subClassOf rdf:resource="#Spac"/>
> </owl:Class>
> <owl:Class rdf:ID="City">
> <rdfs:subClassOf rdf:resource="#Spac"/>
> </owl:Class>
> <owl:ObjectProperty rdf:ID="contains">
> <rdf:type rdf:resource="&owl;TransitiveProperty"/>
> <rdfs:domain rdf:resource="#Spac"/>
> <rdfs:range rdf:resource="#Spac"/>
> <owl:inverseOf rdf:resource="#isPartOf"/>
> </owl:ObjectProperty>
> <owl:ObjectProperty rdf:ID="hasLocation">
> <rdfs:domain rdf:resource="#Person"/>
> <rdfs:range rdf:resource="#Spac"/>
> </owl:ObjectProperty>
> <owl:ObjectProperty rdf:ID="isPartOf">
> <rdfs:domain rdf:resource="#Spac"/>
> <rdfs:range rdf:resource="#Spac"/>
> <owl:inverseOf rdf:resource="#contains"/>
> </owl:ObjectProperty>
> <owl:Class rdf:ID="Person"/>
> <owl:Class rdf:ID="Room">
> <rdfs:subClassOf rdf:resource="#Spac"/>
> </owl:Class>
> <owl:Class rdf:ID="Spac"/>
> <Person rdf:ID="steve">
> <hasLocation rdf:resource="#bar"/>
> </Person>
> <Building rdf:ID="theater">
> <isPartOf rdf:resource="#Berlin"/>
> <contains rdf:resource="#bar"/>
> </Building>
> </rdf:RDF>
>
>
> _______________________________________________
> Pellet-users mailing list
> Pellet-users at lists.owldl.com
> http://lists.owldl.com/mailman/listinfo/pellet-users
> _______________________________________________
>
> Sponsored by Clark & Parsia, LLC http://clarkparsia.com/
>
More information about the Pellet-users
mailing list