SPARQL两个节点之间的路径 [英] SPARQL Path between two nodes

查看:408
本文介绍了SPARQL两个节点之间的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出一个图形:

@prefix da:    <http://example.com/data/> .
@prefix on:    <http://example.com/on/> .

da:Shenaz  on:husband  da:Javed .

da:Rita  on:friend  da:Noor ;
        on:sister  da:Tom .

da:Noor  on:sister  da:Shenaz .

da:Javed  on:child  da:Jaabir .

da:Tom  on:sister  da:James .

da:Jaabir  on:grandFather  da:Rafick .

da:Noorda:James之间有一条路径,该路径为da:Noor ^on:friend/on:sister/on:sister da:James .,但是以下查询返回false

There is a path between da:Noor and da:James which is da:Noor ^on:friend/on:sister/on:sister da:James . but the following query is returning false

PREFIX da:    <http://example.com/data/> 
PREFIX on:    <http://example.com/on/> 
ASK {
  da:Noor ((<>|!<>)|^(<>|!<>))* da:James .
}

这可能是耶拿(Jena)的错误,而Python中的RDFLib会返回True(真)

It is a possible bug in Jena, with RDFLib in Python, True is returned

推荐答案

由于某些原因,属性路径未按预期进行评估.我用更简单的查询进行了尝试:

For some reason the property path is not evaluated as expected. I tried it with the more simple query:

  PREFIX  :     <http://ex.org/>
  PREFIX  da:   <http://example.com/data/>

  SELECT  ?u
  WHERE
    { da:Noor ^(:p1|!:p1) ?u }

代数看起来不错,即路径是反向的:

The algebra looks ok, i.e. the path is reversed:

(project (?u)
    (path ?u (alt <http://ex.org/p1> (notoneof <http://ex.org/p1>)) <http://example.com/data/Noor>))

看起来像个错误,但我可能确实错了.我将在耶拿邮件列表中询问,然后在此处发布答案.

Looks like a bug but I might be wrong indeed. I'll ask on the Jena mailing list and later on post the answer here.

问题在于对象本身接地时的取反-在这种情况下是由于反向运算符^引起的.根据@AndyS的评论,此错误将在Apache Jena 3.3.0中修复.参见 JENA-1317

The problem is with negations when the object itself is grounded - which is the case here due to the reverse operator ^. As per @AndyS' comment, this bug will be fixed in Apache Jena 3.3.0. See JENA-1317

这篇关于SPARQL两个节点之间的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆