问题
Given a graph:
@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 .
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 .
}
It is a possible bug in Jena, with RDFLib in Python, True is returned
回答1:
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.
Update:
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
来源:https://stackoverflow.com/questions/43317635/sparql-path-between-two-nodes