2
1

Hi.. I have today itself jumped into DBPedia and am following the example give in the book "Semantic web Programming by John Hebeler" I came across a Query that does not give me any result in the DBPedia SPARQL end Point @ http://dbpedia.org/sparql

The code that I have tried to run is as follows:

#George Washington's Namesakes
SELECT ?location
WHERE {
?person <http://www.w3.org/2000/01/rdf-schema#label> "George Washington"@en.
?location <http://dbpedia.org/property/namedFor> ?person
}

This returns the URI's of all locations named after George Washington.

I get no result but just a table header labeled location. Can someone provide me the correct query? I suppose the URI's have been changed a lot as DBPedia evolved due to which I am unable to get the result. Kindly help and do tell me some tutorial if possible to learn how to query resources at DBPedia??

This question is marked "community wiki".

asked 05 Apr '11, 18:56

Roger's gravatar image

Roger
1.1k29
accept rate: 10%

edited 05 Apr '11, 19:53

Ryan%20Kohl's gravatar image

Ryan Kohl
2.5k310


Hmm... after a root-around, the query you're looking for is:

SELECT *
WHERE {
?location <http://dbpedia.org/property/namedFor> "George Washington"@en
}

Here are the answers.

For learning SPARQL, you should check out SPARQL by Example by Cambridge Semantics. It contains some DBPedia examples.

link
This answer is marked "community wiki".

answered 05 Apr '11, 19:06

Signified's gravatar image

Signified ♦
23.7k1623
accept rate: 37%

Woooooooww.... Loved the response time of yours... Thanks a lot!! :) can you pls let me know that how do we select the correct data Sets as in the URI's to query?? should we study the structure of them or there is some kind of documentation??

(05 Apr '11, 19:13) Roger Roger's gravatar image

One more thing what was wrong in the query I wrote?? as in mentioned in the book?

(05 Apr '11, 19:14) Roger Roger's gravatar image
1

:). With respect to the first question, knowing what endpoint/dataset to query against is very much based on experience... similarly for how the query is structured (unfortunately, there's no easy answer). With respect to the second question, the query in the book (simply put) does not follow the modelling of the data which it is querying over... my guess is that the query in the book never worked. :/

(05 Apr '11, 19:26) Signified ♦ Signified's gravatar image
1

hehehehe :) I got it!!! and it seems that the book is a good resource but a bit outdated. Thanks anyways :)

(05 Apr '11, 19:56) Roger Roger's gravatar image

The query as written in the book is what ought to be possible. It assumes that there are nodes representing people, and nodes representing places, and a "namedFor" predicate that connects them. But in fact, dbpedia doesn't have this. It has nodes representing places, and a "namedFor" predicate, but the predicate connects to untyped text strings instead of people. Signified's answer will get you only some of the data. For a little more, try this:

SELECT ?location ?person
WHERE {
  ?location <http://dbpedia.org/property/namedFor> ?person
  FILTER(regex(?person,"(^George Washington)|(George Washington$)"))
}

To see why I did that, try this:

SELECT ?location ?person
WHERE {
  ?location <http://dbpedia.org/property/namedFor> ?person
  FILTER(regex(?person,"George Washington"))
}

Ponder these for a couple minutes and you'll realize that a) you have no idea how many other permutations of George Washington's name might have been used, b) you have no way of knowing whether those "George Washington" strings all represent the first president, or nine different guys named George Washington, or some combination of those. You might then conclude that this is idiotic, and misses the point of the Semantic Web pretty much entirely.

And then you might notice that the state of Washington isn't even on this list. And then you might start to suspect, correctly, that it's generally a waste of time querying dbpedia for anything where you actually care about the answers.

link
This answer is marked "community wiki".

answered 05 Apr '11, 20:12

glenn%20mcdonald's gravatar image

glenn mcdonald
29114
accept rate: 15%

1

LOL! This is probably generally true. It takes work to get verified good data out of DBPedia. But its still a valuable resource.

(06 Apr '11, 14:56) scotthenninger ♦ scotthenninger's gravatar image

Agree with scott on this. @glenn, you're being a tad bit harsh on DBpedia... definitely for applications with critical soundness and completeness requirements, one may want to think twice about using DBpedia unsupervised. That's different from saying that it's a waste of time if you care about the answers. :P

(06 Apr '11, 15:38) Signified ♦ Signified's gravatar image

@glenn - DBpedia is far from perfect. Like its source material. One might suggest that the missing information could be added to Wikipedia (the source of most DBpedia content), and/or that some refinement might be made to the DBpedia extractors (which pull the data from Wikipedia)...

Also, remember that SPARQL and RDF universes operate under the "Open World" assumption -- that is, anything unstated is unknown. The state of Washington not being included in your result set does not mean that it was not named for President George Washington -- it means that DBpedia (Wikipedia) doesn't know.

(07 Apr '11, 12:12) TallTed TallTed's gravatar image

If that is the case where can I find data that can be used to the utmost perfection. Coz the DBPedia has some data that gets updated every now and then... The book I referred was written 2years ago and according to me two years are more than enough for a change to come. SO can you suggest me some place where I have to toil less for data coz I am a beginner and dont want to waste my time working on a query that will never run!!? :)

(07 Apr '11, 14:06) Roger Roger's gravatar image

Given this is backended by Virtuoso another query that seems to work is

SELECT *
WHERE {
?location <http://dbpedia.org/property/namedFor> ?label.
?label bif:contains '"George Washington"'
}

The bif: function is much faster than a FILTER regex.

link

answered 07 Apr '11, 12:27

Ronald%20P.%20Reck's gravatar image

Ronald P. Reck
44519
accept rate: 16%

edited 07 Apr '11, 12:30

Thanks ... I learned something new...!! :)

(07 Apr '11, 14:08) Roger Roger's gravatar image

For more fun (and faster response time), you can try using one of the built-in functions (bifs) of the Virtuoso server powering the DBpedia.org SPARQL endpoint --

SELECT DISTINCT  ?s1  AS  ?Feature 
                 ?s2  AS  ?NamedFor  
   WHERE { ?s1  a                                       <http://www.opengis.net/gml/_Feature>  . 
           ?s1  <http://dbpedia.org/property/namedFor>  ?s2                                    .
           ?s2  bif:contains                            'WASHINGTON'                           .
         } 
ORDER BY ASC (?s2) 
         ASC (?s1) 
LIMIT 100  
OFFSET 0

Results are here

link

answered 07 Apr '11, 12:44

TallTed's gravatar image

TallTed
2.1k19
accept rate: 14%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×1,266
×266
×136

Asked: 05 Apr '11, 18:56

Seen: 4,344 times

Last updated: 07 Apr '11, 14:08