【问题标题】:Multiple MINUS clause in a sparql querysparql 查询中的多个 MINUS 子句
【发布时间】: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 &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt;/&lt;http://www.w3.org/2000/01/rdf-schema#subClassOf&gt;{,6} &lt;http://dbpedia.org/class/yago/Communicator109610660&gt;} UNION {?o &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt;/&lt;http://www.w3.org/2000/01/rdf-schema#subClassOf&gt;{,6} &lt;http://dbpedia.org/class/yago/Creator109614315&gt;} }
  • 或使用 VALUES 子句:MINUS { VALUES ?type {&lt;http://dbpedia.org/class/yago/Creator109614315&gt; &lt;http://dbpedia.org/class/yago/Communicator109610660&gt;} ?o &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt;/&lt;http://www.w3.org/2000/01/rdf-schema#subClassOf&gt;{,6} ?type }

标签: sparql


【解决方案1】:

标准的好处之一是我们可以在规范中查找内容,因此在查看https://www.w3.org/TR/sparql11-query/#grammar 的产品 66、56 和 54 后,我可以确认标准允许多个 MINUS 子句。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-03
    • 1970-01-01
    • 2014-05-30
    相关资源
    最近更新 更多