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 ?
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 }
}
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 (ie, 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, eg, dbpedia-owl:careerStation dbpedia:Ryan_Giggs__1 .)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.