sparql - SPARQL 语法更正
问题描述
这是我第一次使用 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 不使用日/月。
推荐阅读
- bash - 按名称对文件进行数字排序,然后按 BASH 中的父目录排序
- python - BeautifulSoup 使用可迭代而不是字符串?
- javascript - 对象中的数组作为道具粘贴的问题
- asp.net - Asp.Net GridView - 需要在弹出窗口中添加下一个和上一个按钮
- postgresql - 有条件地选择要在 FOR LOOP 中迭代的集合
- java - 在不使用 .setFileSelectionMode 的情况下限制 JFileChooser 的允许选择
- javafx - 如何制作具有多个下拉菜单的组合框?
- julia - 在 Julia,如果我删除!字典中的键和值,它会重新分配字典吗?
- amazon-web-services - 如何在 aws cli describe-instances 输出中获取标签的值?
- javascript - jquery 出现错误,说明“idleTimeout 不是函数”