2

I need to get all players who have ever played for football team using SPARQL query and dbpedia.org

I can get current team members using http://dbpedia.org/sparql and this query:

PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX p: <http://dbpedia.org/property/>  
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>           
SELECT * WHERE { 
      <http://dbpedia.org/resource/Manchester_United_F.C.> p:name ?player.
      ?player dbpedia-owl:birthPlace ?city;
              dbpedia-owl:birthDate ?dob.
}

How to get all players who have ever played for this football team ?

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
Dmitry Kazakov
  • 1,639
  • 3
  • 27
  • 47
  • 2
    The dot after ?city should be a semicolon I think. Otherwise your query above is not correct since the last term is missing the subject. – mschenk74 Dec 31 '14 at 13:49
  • Sure. Thanks. Could you help to get for example Hometown of any footballer using SPARQL? – Dmitry Kazakov Dec 31 '14 at 13:57
  • 1
    Since I cannot reach the sparql endpoint of dbpedia at the moment I cannot help you further. – mschenk74 Dec 31 '14 at 14:13
  • 1
    There are a few questions here: (i) does DBpedia have the data you're looking for? (ii) if it does, how is it stored? (iii) what SPARQL query will retrieve that information? Once you've answered (i) and (ii), then (iii) isn't too hard. Do you have answers for (i) and (ii) yet? You'll probably just have to browse some of the DBpedia manually until you find the information, or find that it isn't there. That's what anyone who would post an answer to this question would have to do, after all. – Joshua Taylor Dec 31 '14 at 14:23

1 Answers1

4

I'd use a query like this:

select distinct ?player ?birthPlace ?birthDate where {
  ?player dbpedia-owl:team <http://dbpedia.org/resource/Manchester_United_F.C.> ;
          a dbpedia-owl:Person ;
          dbpedia-owl:wikiPageID [] .
  optional { ?player dbpedia-owl:birthPlace ?birthPlace }
  optional { ?player dbpedia-owl:birthDate ?birthDate }
}

SPARQL results

Using optional ensures that players without listed birthplaces or birthdates can still be included in the results. Using a dbpedia-owl:Person helps remove some "dirty" data (i.e., things that have a dbpedia-owl:team property, but that aren't players). Similarly, adding dbpedia-owl:wikiPageID [] ensures that the results are things that exist as articles. If you don't include that, then you get results like Manchester_United_F.C.__Ryan_Giggs__1, which appears to be a sort of career station entity. (Note that Ryan Giggs has, e.g., dbpedia-owl:careerStation dbpedia:Ryan_Giggs__1.)

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353