sparql过滤器不起作用

时间:2017-06-22 19:45:45

标签: filter sparql rdf dbpedia

我希望得到一个足球俱乐部的所有球员并过滤掉那些来自德国的球员,我知道没有过滤选项是可能的,但我是SPARQL的新手,似乎我不明白在这种情况下使用过滤器选项,所以如果有人能告诉我如何使其工作,我会很高兴。

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)

最好的问候阿德里安

1 个答案:

答案 0 :(得分:2)

我希望你能找到这样的东西:

SELECT distinct ?player WHERE {
    ?player a dbo:SoccerPlayer . 
    ?player dbp:currentclub dbr:Hertha_BSC . 
    ?player dbo:birthPlace/dbo:country? ?country .
    FILTER (?country = dbr:Germany)
    } 
ORDER BY ASC(?player)

或者这个:

SELECT distinct ?player WHERE {
    ?player a dbo:SoccerPlayer . 
    ?player dbp:currentclub dbr:Hertha_BSC . 
    ?player dbo:birthPlace/dbo:country? ?country .
    FILTER (?country in (dbr:Germany))
    } 
ORDER BY ASC(?player)

甚至这个:

SELECT distinct ?player WHERE {
    ?player a dbo:SoccerPlayer . 
    ?player dbp:currentclub ?club . 
    ?player dbo:birthPlace/dbo:country? ?country .
    VALUES (?club ?country) { (dbr:Hertha_BSC dbr:Germany) }
    } 
ORDER BY ASC(?player)