SPARQL variable not binding to rdf:type (with reasoning)

1 view
Skip to first unread message

Brendan Heussler

unread,
Apr 9, 2014, 1:40:21 PM4/9/14
to

If you are using reasoning, the wildcard in the predicate does capture rdf:type in the result set.

For example, I have the following data

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dbp: <http://dbpedia.org/data/> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix : <http://matonto.org/data/2014/04/inovex/> .

:spreadsheet1 dct:format dbp:Comma-separated_values .

dct:format rdfs:range dct:MediaTypeOrExtent ;

Query

select ?s ?o where {
 ?s dct:format ?o .
 ?o ?p <http://purl.org/dc/terms/MediaTypeOrExtent> .
 }

The result set is empty.

However, the following query captures the inferred rdf:type in the result set

Query

select ?s ?o where {
 ?s dct:format ?o .
 ?o a <http://purl.org/dc/terms/MediaTypeOrExtent> .
 }

Result Set

s                                                   | o
http://matonto.org/data/2014/04/inovex/spreadsheet1 | http://dbpedia.org/data/Comma-separated_values

The only difference between these two queries is that ?p is replaced with a. So it seems that the SPARQL variables cannot capture rdf:type when rdf:type is inferred.

Mike Grove

unread,
Apr 9, 2014, 1:51:30 PM4/9/14
to stardog
On Wed, Apr 9, 2014 at 1:37 PM, Brendan Heussler <bheu...@gmail.com> wrote:

If you are using reasoning, the wildcard in the predicate does capture rdf:type in the result set.

For example, I have the following data

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dbp: <http://dbpedia.org/data/> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix : <http://matonto.org/data/2014/04/inovex/> .

:spreadsheet1 dct:format dbp:Comma-separated_values .

dct:format rdfs:range dct:MediaTypeOrExtent ;

Query

select ?s ?o where {
 ?s dct:format ?o .
 ?o ?p <http://purl.org/dc/terms/MediaTypeOrExtent> .
 }

The result set is empty.

However, the following query captures the inferred rdf:type in the result set

Query

select ?s ?o where {
 ?s dct:format ?o .
 ?o a <http://purl.org/dc/terms/MediaTypeOrExtent> .
 }

Result Set

The only difference between these two queries is that ?p is replaced with a. So it seems that the SPARQL variables cannot capture rdf:type when rdf:type is inferred.

If you want rdf:type, you have to explicitly specify it, as you've noticed.  

What's happening is the entailment regimes require that variables within a query are typed when you're performing inferencing.  That is, it has to know if a variable will bind to a class, or an individual, data property, or object property.  You have not explicitly stated the type of ?p, but, we're able to infer that it is an object property given that the object of the BGP is a resource, not a literal.

So the reasoner assumes you want the inferences relevant to ?p being an object property.  Trick is, rdf:type isn't an object property.  It's not a data property either for that matter.  Since it's not a standard property type, you have to explicitly state that you want it, as you've done in your query.

Cheers,

Mike
 

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

Brendan Heussler

unread,
Apr 9, 2014, 2:22:03 PM4/9/14
to sta...@clarkparsia.com
Thank You!
Reply all
Reply to author
Forward
0 new messages