对于 SPARQL 属性路径,否定无法按预期工作

发布于 2025-01-10 12:02:52 字数 1162 浏览 6 评论 0原文

根据 SPARQL 属性路径,否定用运算符 表示!,即!(a|b|c|d)表示任何不属于{a, b, c, d}的关系。

根据这个定义,我发现下面的例子非常违反直觉。

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://rdf.freebase.com/ns/> 

ASK {
:m.0262dl9 
!(:type.object.type|<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>) 
:common.topic
}

上述查询返回 false,因为从 :m.0262dl9:common.topic 的唯一关系是 :type.object.type,它们被否定。但是,如果我们将 ^:type.object.type(这意味着 :type.object.type 的逆)添加到否定集合中,则答案将变为 true。换句话说,我们修改

!(:type.object.type|<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>)

!(:type.object.type|^:type.object.type|<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>)

这很奇怪,因为第一个查询为假意味着第二个查询也必须为假。我真的不确定为什么第二个查询返回 true。我是否误解了 !^ 的定义?

According to SPARQL Property Paths, negation is expressed with the operator !, i.e., !(a|b|c|d) means any relations that do not fall into {a, b, c, d}.

Based one this definition, I find the following example very counterintuitive.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://rdf.freebase.com/ns/> 

ASK {
:m.0262dl9 
!(:type.object.type|<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>) 
:common.topic
}

The above query returns false because the only relations from :m.0262dl9 to :common.topic are :type.object.type and <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, which are negated. However, if we add ^:type.object.type, which means the inverse of :type.object.type to the negated set, the answer becomes true. In other words, we modify

!(:type.object.type|<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>)

to

!(:type.object.type|^:type.object.type|<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>)

This is quite weird, since the first query is false entails that the second query must also be false. I am really not sure why the second query returns true. Am I misunderstanding the definition of ! or ^?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文