0

I am using the following query :

select ?value where { <http://dbpedia.org/resource/Paris>  dbpedia-owl:wikiPageRedirects* ?value } 

in order to retrieve the wikiPageRedirects property of Paris.


Based on dbpedia Paris has more than 20 redirect links. Why am I only retrieving the first one?


Hani Goc
  • 2,371
  • 5
  • 45
  • 89

2 Answers2

3

Your direction was wrong.

select distinct *
where { 
  ?x dbpedia-owl:wikiPageRedirects <http://dbpedia.org/resource/Paris>
} 
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
Artemis
  • 3,271
  • 2
  • 20
  • 33
  • so you defined it as a label? I didn't really understand the query I am fairly new to sparql. It worked perfectly tho – Hani Goc Feb 27 '15 at 14:53
  • 1
    So when you are looking for the properties in dbpedia, it is good to look at how they are defined. If you follow the link to dbpedia-owl:wikiPageRedirects, you can see that one way it is defined is as a label. You should read the SPARQL manual, it has great examples. – Artemis Feb 27 '15 at 14:54
  • Actually, if you don't want the labels, it works without the first line as well. Your direction was wrong. I misunderstood your question, and though you needed the value of the links. – Artemis Feb 27 '15 at 14:56
  • For the label ok I get it no problem. But do you mean that I had the query upside down? – Hani Goc Feb 27 '15 at 14:59
2

Artemis's answer is right; the "direction" in the query is wrong. It's worth explaining that a bit more, though. On the DBpedia "page", you'll see lots of data like:

dbpedia-owl:area      105400000.000000 (xsd:double)  
dbpedia-owl:country   dbpedia:France  
dbpedia-owl:inseeCode 75056 (xsd:integer)  
dbpedia-owl:mayor     dbpedia:Anne_Hidalgo

These mean that DBpedia contains triples where these are the predicates and objects. That is, DBpedia contains a triple:

dbpedia:Paris dbpedia-owl:country dbpedia:France

On other hand, you'll also see things like "is … of":

is dbpedia-owl:beatifiedPlace of dbpedia:Daniel_Brottier
is dbpedia-owl:billed         of dbpedia:René_Duprée

These mean that dbpedia:Paris the object of triples with these subjects and predicates. E.g., DBpedia contains the triple

dbpedia:René_Duprée dbpedia-owl:billed dbpedia:Paris

The redirects properties that you're seeing are like this:

is dbpedia-owl:wikiPageRedirects of dbpedia:City_of_Love_(city)
                                    dbpedia:Département_de_Paris
                                    dbpedia:Departement_de_Paris
                                    dbpedia:FRPAR

That means that there are a bunch of triples of the form:

?something dbpedia-owl:wikiPageRedirects dbpedia:Paris

and that means that your query needs to be

select ?resource where {
  ?resource dbpedia-owl:wikiPageRedirects dbpedia:Paris
}

SPARQL results

Community
  • 1
  • 1
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • Really interesting Joshua. I am actually practicing on your comments with examples from bpedia.org/sparql. trying to form these relations between the triples. – Hani Goc Feb 27 '15 at 15:52
  • select * where {?x dbpedia-owl:country dbpedia:United_States} For example this will return everything where the country is the united states? – Hani Goc Feb 27 '15 at 15:53
  • one last question how about "wikiPageRedirects, wikiPageInLinkCountCleaned" these are also properties that i am also extracting but in a very complex way. First i select all the properties for a given concept then I try to search for them in the resulting query. – Hani Goc Feb 27 '15 at 15:55
  • Yes, that query will select things that have the value dbpedia:United_States as the value of dbpedia-owl:country. – Joshua Taylor Feb 27 '15 at 15:57
  • @HaniGoc I'm not sure what you're asking in your third comment, but it sounds like you might need a subquery. You should probably ask a new question about that. – Joshua Taylor Feb 27 '15 at 15:58