2017-06-21 4 views
0

Ich bin immer in SPARQL und ich möchte eine einfache Anfrage setzen, aber es scheint, es ist nicht so einfach ...Filter birthcountry in SPARQL

Ich möchte alle Fußballspieler von einem Verein erhalten, sind in einem besonderen Land geboren.

Ich habe die Bitte, alle Spieler aus einem Club zu bekommen. Beispiel:

SELECT ?player WHERE { 
<http://dbpedia.org/resource/Hertha_BSC> dbpedia2:name ?player 
} 

Wie bekomme ich alle Spieler geboren in, z. Deutschland mit der Option Filter?

Ich versuchte es bereits auf diese Weise, aber es scheint, ich bin etwas nicht zu bekommen ...

prefix dbo:<http://dbpedia.org/ontology/> 
SELECT ?player WHERE { 
<http://dbpedia.org/resource/Hertha_BSC> dbpedia2:name ?player . 
?birth dbo:birthPlace ?player. 
filter (regex(?birth, "Germany")). 
} 

würde ich mich freuen, wenn ihr mir helfen könntet.

EDIT: Nach Median Hilal Hilfe ich versuche, es mit "Filter" zu tun, aber es ist nicht Arbeit.

SELECT distinct ?player WHERE { 
?player a <http://dbpedia.org/ontology/SoccerPlayer>. 
?player <http://dbpedia.org/property/currentclub> 
<http://dbpedia.org/resource/Hertha_BSC>. 
optional {?subject <http://dbpedia.org/ontology/birthPlace>/<http://dbpedia.org/ontology/country> ?<http://dbpedia.org/resource/Germany>. } 
filter (!bound(?subject)). 
} 
ORDER BY ASC(?player) 

Irgendwelche Vorschläge?

Antwort

3

Ihre beiden Abfragen ergeben keinen Sinn. Ich denke, das Folgende ist nützlich

SELECT distinct * WHERE { 
    ?player a <http://dbpedia.org/ontology/SoccerPlayer>. 
    #get all soccer players 
    ?player <http://dbpedia.org/property/currentclub> ?club. 
    #get the clubs, you can use <http://dbpedia.org/resource/Hertha_BSC> instead of ?club for Hertha Berlin 
    ?player <http://dbpedia.org/ontology/birthPlace>/<http://dbpedia.org/ontology/country>? <http://dbpedia.org/resource/Germany>. 
    # get birth places which are either Germany or places located in Germany 
} 
+1

Ihre Lösung macht mehr Sinn als die seltsame Verwendung von 'dbp: name' in der Frage. Ein kleiner Kommentar: Für das Ergebnis spielt es keine Rolle, aber ich würde '?' Verwenden, um den Fall * null oder eins * abzudecken, anstatt das Sternchen '*' zu verwenden, das * null oder mehr * abdeckt. – AKSW

+0

Richtig! Geändert! –

+1

Ich denke, @DaPole wurde von diesen seltsamen Tripeln von ganzem Herzen verwirrt: 'dbr: Hertha_BSC dbp: Name dbr: Valentin_Stocker' usw. - siehe http://dbpedia.org/page/Hertha_BSC –