【发布时间】:2012-10-12 18:19:17
【问题描述】:
给定这样的 RDF 图:
:Matrix [rdfs:label] :The Matrix .
:Matrix [movie:id] :23 .
:Matrix [movie:actor] :Keanu Reaves .
:Matrix [movie:actor] :Laurence Fishburne .
:Die Hard 3 [rdfs:label] :Die Hard 3 .
:Die Hard 3 [movie:id] :42 .
:Die Hard 3 [movie:actor] :Bruce Willis .
:Die Hard 3 [movie:actor] :Samuel L. Jackson .
还有这样的查询:
SELECT ?id ?name ?actor
WHERE {
?instance movie:id ?id .
?instance rdfs:label ?name .
?instance movie:actor ?actor .
}
我希望得到如下结果:
id | name | actor
23 | The Matrix | Laurence Fishburne
23 | The Matrix | Keanu Reaves
42 | Die Hard 3 | Bruce Willis
42 | Die Hard 3 | Samuel L. Jackson
但我只得到:
id | name | actor
23 | The Matrix | Laurence Fishburne
42 | Die Hard 3 | Bruce Willis
这是怎么回事?
顺便说一句,当我使用这个查询时:
SELECT *
WHERE {
?instance movie:id ?id .
?instance rdfs:label "The Matrix" .
?instance movie:actor ?actor .
}
结果是(如预期的那样):
id | name | actor
23 | The Matrix | Laurence Fishburne
23 | The Matrix | Keanu Reaves
【问题讨论】:
-
sparql 端点是linkedmdb.org,它使用 D2R,我使用 python SPARQLWrapper 来查询端点。我的期望错了吗?
-
对我来说看起来不错 - 我只能建议删除 rdfs:label 三重模式和/或将其放在最后。这不应该有什么不同,但是你应该得到你期望的结果。
-
谢谢!我目前正在使用一种解决方法来获取相关数据,但我会尝试您的建议并报告是否可行。但即使它会起作用,我也会很困惑,因为在我看来,描述子图的三元组的顺序并不重要。而且我在 w3c 规范中找不到任何描述这种行为的内容。
标签: rdf sparql semantic-web linked-data