SPARQL 语法更正
SPARQL Syntax correction
这是我第一次使用 SPARQL。
使用 DBpedia,我想列出 1992 年以来所有摇滚乐队的乐队名称
我已经开发的代码运行正确但给出了 0 个结果。我是否错误地过滤了日期?
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT DISTINCT ?bandname where {
?band dbo:genre dbp:Rock_music .
?band foaf:name ?bandname .
FILTER (dbo:activeYearsStartYear >= xsd:date("1992-01-01") && dbo:activeYearsStartYear <= xsd:date("1992-12-31"))
}
我希望列中只有乐队名称。
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT DISTINCT ?bandname ?date where {
?band dbo:genre dbp:Rock_music .
?band foaf:name ?bandname .
?band dbo:activeYearsStartYear ?date .
FILTER (?date >= "1992-01-01"^^xsd:dateTime && ?date <= "1992-12-31"^^xsd:dateTime)
}
这确实有效,但请注意 dbo:activeYearsStartYear 仅生成年份,因此 FILTER 未使用 day/month。
这是我第一次使用 SPARQL。 使用 DBpedia,我想列出 1992 年以来所有摇滚乐队的乐队名称
我已经开发的代码运行正确但给出了 0 个结果。我是否错误地过滤了日期?
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT DISTINCT ?bandname where {
?band dbo:genre dbp:Rock_music .
?band foaf:name ?bandname .
FILTER (dbo:activeYearsStartYear >= xsd:date("1992-01-01") && dbo:activeYearsStartYear <= xsd:date("1992-12-31"))
}
我希望列中只有乐队名称。
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT DISTINCT ?bandname ?date where {
?band dbo:genre dbp:Rock_music .
?band foaf:name ?bandname .
?band dbo:activeYearsStartYear ?date .
FILTER (?date >= "1992-01-01"^^xsd:dateTime && ?date <= "1992-12-31"^^xsd:dateTime)
}
这确实有效,但请注意 dbo:activeYearsStartYear 仅生成年份,因此 FILTER 未使用 day/month。