gpt4 book ai didi

rdf - CONSTRUCT 子句的实际使用(和重用)

转载 作者:行者123 更新时间:2023-12-05 00:26:59 24 4
gpt4 key购买 nike

使用时 CONSTRUCT在 sparql 查询中,输出是 single RDF graph ,又名一组三元组,本质上是新数据。但总的来说,我已经考虑过 CONSTRUCT是一种手动创建理论上应该可重用的规则的方法。

CONSTRUCT 的示例用法中,假设我想定义数据中尚未包含的内容。 Here's a good example taken from an article about CONSTRUCT .

@prefix : <http://some.site.com/ont#> .

:jane :hasParent :gene .
:gene :hasParent :pat ;
:gender :female .
:joan :hasParent :pat ;
:gender :female .
:pat :gender :male .
:mike :hasParent :joan .

“以下 CONSTRUCT 语句根据上述三元组创建新的三元组,以指定谁是祖父:”
PREFIX : <http://some.site.com/ont#>

CONSTRUCT { ?p :hasGrandfather ?g . }
WHERE {?p :hasParent ?parent .
?parent :hasParent ?g .
?g :gender :male .
}

结果:
@prefix :        <http://some.site.com/ont#> .
:jane :hasGrandfather :pat .
:mike :hasGrandfather :pat .

一旦我生成了新的三元组 CONSTRUCT查询,这是否意味着我必须获取该数据,并将其输入回数据库才能开始使用/重用 :hasGrandfather ?或者我可以像引用 SQL 中的动态表一样引用生成的 RDF 图吗?

是否有其他有用的方法可以与使用 CONSTRUCT 生成的三元组进行交互? ?

最佳答案

如果您使用的是 SPARQL 1.1,并且您正在查询一个三元组,您通常会使用 INSERT 将这些三元组添加到存储中(到同一个图或不同的图)。查看来自 SPARQL 1.1 Update 的第 3.1 节:

3.1 Graph Update

Graph update operations change existing graphs in the Graph Store but do not explicitly delete nor create them. Non-empty inserts into non-existing graphs will, however, implicitly create those graphs, i.e., an implementation fulfilling an update request should silently an automatically create graphs that do not exist before triples are inserted into them, and must return with failure if it fails to do so for any reason. (For example, the implementation may have insufficient resources, or an implementation may only provide an update service over a fixed set of graphs and the implicitly created graph is not within this fixed set). An implementation may remove graphs that are left empty after triples are removed from them.

SPARQL 1.1 Update provides these graph update operations: …

  • The fundamental pattern-based actions for graph updates are INSERT and DELETE (which can co-occur in a single DELETE/INSERT operation). These actions consist of groups of triples to be deleted and groups of triples to be added. The specification of the triples is based on query patterns. The difference between INSERT / DELETE and INSERT DATA / DELETE DATA is that INSERT DATA and DELETE DATA do not substitute bindings into a template from a pattern. The DATA forms require concrete data (triple templates containing variables within DELETE DATA and INSERT DATA operations are disallowed and blank nodes are disallowed within DELETE DATA, see Notes 8+9 in the grammar). Having specific operations for concrete data means that a request can be streamed so that large, pure-data updates can be done.


稍后在同一文档中:

Example 8:

This example copies triples from one named graph to another named graph based on a pattern:

PREFIX dc:  <http://purl.org/dc/elements/1.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

INSERT
{ GRAPH <http://example/bookStore2> { ?book ?p ?v } }
WHERE
{ GRAPH <http://example/bookStore>
{ ?book dc:date ?date .
FILTER ( ?date > "1970-01-01T00:00:00-02:00"^^xsd:dateTime )
?book ?p ?v
} }

关于rdf - CONSTRUCT 子句的实际使用(和重用),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21464503/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com