How to build simple SPARQL query in the right way

2019-06-04 05:20发布

问题:

I am novice with SPARQL and DBpedia.

I would like to get knowledge of building simple SPARQL queries.

Could you please help me to build answer for such questions as: Hometown of footballer (any one), List of Artists, List of Oscar winners (any year)

回答1:

I think this question is probably too broad, but in case it's useful, it might make sense to describe how to approach this type of problem. For one of the problems, here's what I did.

List of Oscar winners (any year)

In this case, I started by visting the DBpedia entry for an Academy Award winner, Brad Pitt. There you'll see the property dcterms:subject category:Producers_who_won_the_Best_Picture_Academy_Award. That category has property skos:broader category:Best_Picture_Academy_Award_winners which, in turn, has skos:broader
category:Academy_Award_winners
. So you could look for things that have a dcterms:subject value of some category that's connected by a path of skos:broader links to the Academy_Award_winners category. That will actually turn up some things that aren't persons, because those categories are categories of articles, not classes of entities, so you'll also want to filter down to those things which are Persons. That's probably going to give you a list of Academy Award winners, though it's possible that some are just in that category because they have some other relationship to the category:

select ?person where {
  ?person a dbpedia-owl:Person ;
          dcterms:subject/skos:broader* category:Academy_Award_winners .
}

SPARQL results