【发布时间】:2021-02-20 11:18:06
【问题描述】:
我正在尝试在 DBPedia 的公共端点上运行以下 SPARQL 查询:
select distinct ?o ?olabel where {
{ select distinct ?s where {
?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>/<http://www.w3.org/2000/01/rdf-schema#subClassOf>{,6} <http://dbpedia.org/ontology/FictionalCharacter>
. ?s <http://dbpedia.org/property/creator> ?oo } limit 100000 }
. ?s <http://dbpedia.org/property/creator> ?o
MINUS { ?o <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>/<http://www.w3.org/2000/01/rdf-schema#subClassOf>{,6} <http://dbpedia.org/class/yago/Communicator109610660>}
# MINUS { ?o <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>/<http://www.w3.org/2000/01/rdf-schema#subClassOf>{,6} <http://dbpedia.org/class/yago/Creator109614315>}
. ?o <http://www.w3.org/2000/01/rdf-schema#label> ?olabel . FILTER (lang(?olabel)=''||lang(?olabel)='en')
} LIMIT 100
它工作正常。 但后来我取消注释注释行。 然后查询失败。
据我了解,SPARQL 中授权了多个 MINUS 子句。
谁能给我一些建议来重写我的查询,以便 DBPedia 考虑多个 MINUS 子句?
【问题讨论】:
-
查询可在以下位置编辑:api.triplydb.com/s/bNkV72PZg
-
查询没有失败。无论如何,您也可以通过一个包含两个图形模式的 UNION 的单个 MINUS 来“合并”两个 MINUS 子句
-
MINUS { { ?o <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>/<http://www.w3.org/2000/01/rdf-schema#subClassOf>{,6} <http://dbpedia.org/class/yago/Communicator109610660>} UNION {?o <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>/<http://www.w3.org/2000/01/rdf-schema#subClassOf>{,6} <http://dbpedia.org/class/yago/Creator109614315>} } -
或使用 VALUES 子句:
MINUS { VALUES ?type {<http://dbpedia.org/class/yago/Creator109614315> <http://dbpedia.org/class/yago/Communicator109610660>} ?o <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>/<http://www.w3.org/2000/01/rdf-schema#subClassOf>{,6} ?type }
标签: sparql