在 SPARQL 1.1 中筛选 属性 路径
Filter for property path in SPARQL 1.1
有什么方法可以过滤像
这样的查询吗
select ?x ?y where {?x <http://relationship.com/wasRevisionOf>+ ?y }";
所提供数据集的输出如下:
http://article.com/2-3 http://article.com/2-2
http://article.com/2-3 http://article.com/2-1
http://article.com/2-4 http://article.com/2-3
http://article.com/2-4 http://article.com/2-2
http://article.com/2-4 http://article.com/2-1
http://article.com/2-2 http://article.com/2-1
http://article.com/1-3 http://article.com/1-2
http://article.com/1-3 http://article.com/1-1
http://article.com/1-2 http://article.com/1-1
我们如何过滤查询,以便我们删除所有结果中的 ?x 值等于另一个结果中的 ?y 值。这样,我们将得到
http://article.com/2-4 http://article.com/2-3
http://article.com/2-4 http://article.com/2-2
http://article.com/2-4 http://article.com/2-1
因为所有其他结果的 ?x 值在另一个结果中作为 ?y 值出现。
这是数据集:
<http://article.com/1-3> <http://relationship.com/wasGeneratedBy> <http://edit.com/comment1-2> .
<http://article.com/1-3> <http://relationship.com/wasRevisionOf> <http://article.com/1-2> .
<http://edit.com/comment1-2> <http://relationship.com/used> <http://article.com/1-2> .
<http://edit.com/comment1-2> <http://relationship.com/wasAssociatedWith> <http://editor.com/user1-1> .
<http://article.com/1-2> <http://relationship.com/wasGeneratedBy> <http://edit.com/comment1-1> .
<http://article.com/1-2> <http://relationship.com/wasRevisionOf> <http://article.com/1-1> .
<http://edit.com/comment1-1> <http://relationship.com/used> <http://article.com/1-1> .
<http://edit.com/comment1-1> <http://relationship.com/wasAssociatedWith> <http://editor.com/user1-1> .
<http://article.com/2-4> <http://relationship.com/wasGeneratedBy> <http://edit.com/comment2-3> .
<http://article.com/2-4> <http://relationship.com/wasRevisionOf> <http://article.com/2-3> .
<http://edit.com/comment2-3> <http://relationship.com/used> <http://article.com/2-3> .
<http://edit.com/comment2-3> <http://relationship.com/wasAssociatedWith> <http://editor.com/user2-3> .
<http://article.com/2-3> <http://relationship.com/wasGeneratedBy> <http://edit.com/comment2-2> .
<http://article.com/2-3> <http://relationship.com/wasRevisionOf> <http://article.com/2-2> .
<http://edit.com/comment2-2> <http://relationship.com/used> <http://article.com/2-2> .
<http://edit.com/comment2-2> <http://relationship.com/wasAssociatedWith> <http://editor.com/user2-2> .
<http://article.com/2-2> <http://relationship.com/wasGeneratedBy> <http://edit.com/comment2-1> .
<http://article.com/2-2> <http://relationship.com/wasRevisionOf> <http://article.com/2-1> .
<http://edit.com/comment2-1> <http://relationship.com/used> <http://article.com/2-1> .
<http://edit.com/comment2-1> <http://relationship.com/wasAssociatedWith> <http://editor.com/user2-1> .
select ?x ?y where {?x <http://relationship.com/wasRevisionOf>+ ?y }
How can we filter the query, such that we remove all the results with
a ?x value that equals to a ?y value in another result.
如果一行中的 ?x 值是另一行中的 ?y 值,则表示 ?x 是 wasRevisionOf [=20 上某个三元组的对象=].您可以简单地过滤掉那些:
select ?x ?y where {
?x <http://relationship.com/wasRevisionOf>+ ?y
filter not exists {
?something <http://relationship.com/wasRevisionOf> ?x
}
}
这确保了 ?x 的每个值都是链的 "the beginning"。
有什么方法可以过滤像
这样的查询吗select ?x ?y where {?x <http://relationship.com/wasRevisionOf>+ ?y }";
所提供数据集的输出如下:
http://article.com/2-3 http://article.com/2-2
http://article.com/2-3 http://article.com/2-1
http://article.com/2-4 http://article.com/2-3
http://article.com/2-4 http://article.com/2-2
http://article.com/2-4 http://article.com/2-1
http://article.com/2-2 http://article.com/2-1
http://article.com/1-3 http://article.com/1-2
http://article.com/1-3 http://article.com/1-1
http://article.com/1-2 http://article.com/1-1
我们如何过滤查询,以便我们删除所有结果中的 ?x 值等于另一个结果中的 ?y 值。这样,我们将得到
http://article.com/2-4 http://article.com/2-3
http://article.com/2-4 http://article.com/2-2
http://article.com/2-4 http://article.com/2-1
因为所有其他结果的 ?x 值在另一个结果中作为 ?y 值出现。
这是数据集:
<http://article.com/1-3> <http://relationship.com/wasGeneratedBy> <http://edit.com/comment1-2> .
<http://article.com/1-3> <http://relationship.com/wasRevisionOf> <http://article.com/1-2> .
<http://edit.com/comment1-2> <http://relationship.com/used> <http://article.com/1-2> .
<http://edit.com/comment1-2> <http://relationship.com/wasAssociatedWith> <http://editor.com/user1-1> .
<http://article.com/1-2> <http://relationship.com/wasGeneratedBy> <http://edit.com/comment1-1> .
<http://article.com/1-2> <http://relationship.com/wasRevisionOf> <http://article.com/1-1> .
<http://edit.com/comment1-1> <http://relationship.com/used> <http://article.com/1-1> .
<http://edit.com/comment1-1> <http://relationship.com/wasAssociatedWith> <http://editor.com/user1-1> .
<http://article.com/2-4> <http://relationship.com/wasGeneratedBy> <http://edit.com/comment2-3> .
<http://article.com/2-4> <http://relationship.com/wasRevisionOf> <http://article.com/2-3> .
<http://edit.com/comment2-3> <http://relationship.com/used> <http://article.com/2-3> .
<http://edit.com/comment2-3> <http://relationship.com/wasAssociatedWith> <http://editor.com/user2-3> .
<http://article.com/2-3> <http://relationship.com/wasGeneratedBy> <http://edit.com/comment2-2> .
<http://article.com/2-3> <http://relationship.com/wasRevisionOf> <http://article.com/2-2> .
<http://edit.com/comment2-2> <http://relationship.com/used> <http://article.com/2-2> .
<http://edit.com/comment2-2> <http://relationship.com/wasAssociatedWith> <http://editor.com/user2-2> .
<http://article.com/2-2> <http://relationship.com/wasGeneratedBy> <http://edit.com/comment2-1> .
<http://article.com/2-2> <http://relationship.com/wasRevisionOf> <http://article.com/2-1> .
<http://edit.com/comment2-1> <http://relationship.com/used> <http://article.com/2-1> .
<http://edit.com/comment2-1> <http://relationship.com/wasAssociatedWith> <http://editor.com/user2-1> .
select ?x ?y where {?x <http://relationship.com/wasRevisionOf>+ ?y }
How can we filter the query, such that we remove all the results with a ?x value that equals to a ?y value in another result.
如果一行中的 ?x 值是另一行中的 ?y 值,则表示 ?x 是 wasRevisionOf [=20 上某个三元组的对象=].您可以简单地过滤掉那些:
select ?x ?y where {
?x <http://relationship.com/wasRevisionOf>+ ?y
filter not exists {
?something <http://relationship.com/wasRevisionOf> ?x
}
}
这确保了 ?x 的每个值都是链的 "the beginning"。