gpt4 book ai didi

filter - 如何按 BlankNode id 过滤

转载 作者:行者123 更新时间:2023-12-05 03:01:51 25 4
gpt4 key购买 nike

我正在尝试在 GraphDB 上的 SPARQL playground 中运行此查询。

select * where { 
?s content:value ?value .
FILTER REGEX(str(?value), "_:x1697BD364N0abcdd866d54")
}

?value 是 BNodes

我正在尝试过滤 BNode ID 为:_:x1697BD364N0abcdd866d54

的所有值

我尝试了几种不同的方法来按 ID 进行过滤:

  1. FILTER REGEX(str(?value), "#bnode-id")
  2. FILTER (?value), "#bnode-id")

但都没有成功。

问题:

  1. 您将如何根据 bnode id 进行过滤?
  2. 是否有可能STR(bnode)

最佳答案

  1. How would you filter based on a bnode id label?

See 标签信息。简而言之,不能依赖 SPARQL 查询中的空白节点标签:

There need not be any relation between a label _:a in the result set and a blank node in the data graph with the same label.

An application writer should not expect blank node labels in a query to refer to a particular blank node in the data.

如果在SPARQL中难以通过属性等区分空白节点,可以使用GraphDB的内部资源标识符。

PREFIX ent: <http://www.ontotext.com/owlim/entity#>
SELECT * {
?s content:value ?value .
?s ent:id ?id .
FILTER (?id = 424242)
}

PREFIX ent: <http://www.ontotext.com/owlim/entity#>
SELECT * {
?s content:value ?value
BIND (ent:id(?s) AS ?id)
FILTER (?id = 424242)
}

  1. Is it possible to STR(bnode)?

没有。来自 17.4.2.5 str :

simple literal  STR (literal ltrl)
simple literal STR (IRI rsrc)

Returns the lexical form of ltrl (a literal); returns the codepoint representation of rsrc (an IRI).

关于filter - 如何按 BlankNode id 过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55440728/

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