SPARQL 1.1 蕴含机制和使用 FROM 子句的查询

SPARQL 1.1 entailment regimes and query with FROM clause

我目前 documenting/testing 关于 SPARQL 1.1 蕴含制度,建议一再指出

The scoping graph is graph-equivalent to the active graph

但它没有指定活动图指的是什么:它是查询中使用的数据集吗?商店中所有图表的联合 ?

作为确定这一点的测试,我在带有 RDF 模式和直接类型推理存储 (v2.7.14)

的芝麻记忆存储中得到了这张图 URIed <http://www.example.org/>
@prefix ex:<http://www.example.org/> .
ex:book1 rdf:type ex:Publication .
ex:book2 rdf:type ex:Article .
ex:Article rdfs:subClassOf ex:Publication .
ex:publishes rdfs:range ex:Publication .
ex:MITPress ex:publishes ex:book3 .

我一直在尝试以下查询(这意味着使用默认图和推理引擎)

SELECT ?s WHERE { ?s a ex:Publication . }

不出所料,它 returns 我所有三个实例

<http://www.example.org/book1>
<http://www.example.org/book2>
<http://www.example.org/book3>

同时查询:

SELECT ?s FROM ex: WHERE { ?s a ex:Publication . } 

returns 仅

<http://www.example.org/book1>

在上述情况下,两者的结果不应该相同吗?

如果数据和模式在存储中的两个图之间拆分(如 <urn:rdfs-schema><urn:data>,或者甚至分散在更多图上)和查询,应该会发生什么(根据建议)在 FROM 子句中使用两个图(或模式相关图的子集)而不是默认图 ?

意思是整个商店的推理应该是全局的还是取决于查询数据集?

或者建议是否足够宽松以使其成为一个依赖于实现的问题?

谢谢你的灯,

最大

编辑 这个问题被重定向到 SPARQL 1.1 entailment regimes and query with FROM clause (follow-up)

SPARQL 1.1 标准并未指定默认图中的具体内容。特别是,请参阅 13.1 Examples of RDF Datasets 其中提到:

The definition of RDF Dataset does not restrict the relationships of named and default graphs. Information can be repeated in different graphs; relationships between graphs can be exposed. Two useful arrangements are:

  • to have information in the default graph that includes provenance information about the named graphs
  • to include the information in the named graphs in the default graph as well.

但是,通过使用 FROM 子句指定哪个图应为默认图,或使用多个 FROM 子句指定应将哪些图合并为默认图。

这就是关于 默认图表 的全部内容。 活动图 是您将在 SPARQL 1.1 规范中看到的另一个术语:

The graph that is used for matching a basic graph pattern is the active graph. In the previous sections, all queries have been shown executed against a single graph, the default graph of an RDF dataset as the active graph. The GRAPH keyword is used to make the active graph one of all of the named graphs in the dataset for part of the query.

因此,您可以使用 from(可能多次)来控制默认图,从而控制初始活动图,然后 graph { … } 在查询中更改活动图。

您的第二个查询仅 returns 仅 book1 因为在 Sesame 的 RDFS 推理器中,包含的语句插入到 default 图中,而不是命名图中(s) 蕴涵的前提从何而来。因此,所包含的结果根本不存在于您正在查询的图表中。

这种设计选择的原因至少部分是历史性的,因为芝麻 RDFS 推理引擎早于 W3C 的蕴含机制概念。当时的基本原理是,在对几个命名图进行推理的情况下(例如,一个前提来自图 A,另一个前提来自图 B),插入默认图(而不是 A 或 B,或两者)是最简单,最少的混淆。

Sesame 目前不明确支持 W3C 蕴含机制规范。但是,如果您觉得可以进行简单的改进以使其更兼容,请务必 log a feature request

(披露:Sesame 开发者)