Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SPARQL query returns no data

Tags:

sparql

dbpedia

Why does this SPARQL query return no data?

 PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
 PREFIX dbpedia: <http://dbpedia.org/resource/>

SELECT *
WHERE { 
    <http://dbpedia.org/resource/Louis,_Prince_of_Condé_(1530–1569)> dbpedia-owl:abstract ?abstract            
}
LIMIT 1

If you look at the DBpedia page, it shows the person has an abstract. Is it to do with the brackets in the URL? If so, how can I get round this?

like image 778
Rob Sedgwick Avatar asked Feb 15 '26 13:02

Rob Sedgwick


2 Answers

This URI does not lead to the same result as the DBpedia page - for what ever reason. You can see this with

PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dbpedia: <http://dbpedia.org/resource/>
SELECT *
WHERE { 
    <http://dbpedia.org/resource/Louis,_Prince_of_Condé_(1530–1569)> ?p ?o          
}
LIMIT 100

But it has an owl:sameAs relation to http://dbpedia.org/resource/Louis,_Prince_of_Cond%C3%A9_(1530%E2%80%931569)

That means if you use this URI in your query, it should work as expected. But you should indeed apply a FILTER on the language, e.g. 'en' for English abstracts.

like image 73
UninformedUser Avatar answered Feb 19 '26 20:02

UninformedUser


As AKSW mentions, the resource actually doesn't have many properties, but is connected to the "canonical" version by an owl:sameAs link. You can keep using the IRI that you're using now, follow owl:sameAs in either direction to any of its equal resources (let's call them ?s), and then ask for the abstract of ?s. (And then it's not a bad idea to filter by language, if that's applicable.) You can do this with a query like this (note that the current DBpedia endpoint uses dbo:, now, not the older dbpedia-owl:):

select ?abstract where {
   <http://dbpedia.org/resource/Louis,_Prince_of_Condé_(1530–1569)> (owl:sameAs|^owl:sameAs)* ?s .
   ?s dbo:abstract ?abstract .

  filter langMatches(lang(?abstract),'en')
}
like image 45
Joshua Taylor Avatar answered Feb 19 '26 20:02

Joshua Taylor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!