无法在 DBPedia 上执行特定的 SPARQL 查询:/
例如,在 此站点 上,采用第一个 SPARQL 查询并进行非常类似的操作:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX p: <http://dbpedia.org/property/>
SELECT *
WHERE {
?name p:name <http://dbpedia.org/resource/Olivier_Theyskens> .
}
尝试执行它:<一href="http://dbpedia.org/snorql/?query=%20%20%20%20PREFIX%20rdf%3a%20%3Chttp://www.w3.org/19 99/02/22-rdf-syntax-ns#%3E%0D%0A%20%20%20%20PREFIX%20p%3a%20%3Chttp://dbpedia.org/property/%3 E%0D%0A%20%20%20%20SELECT%20%2a%0D%0A%20%20%20%20WHERE%20%7B%0D%0A%20%20%20%20%20%20% 20%20?na我%20p%3aname%20%3Chttp://dbpedia.org/resource/Olivier_ Theyskens%3E%20.%0D%0A%20%20%20%20%7D" rel="nofollow">这里
我没有得到任何结果。但是,将查询修改为以下内容:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX p: <http://dbpedia.org/property/>
SELECT *
WHERE {
?name p:name ?otherthing.
}
我得到了结果,即使它们不是我想要的结果。
为什么第一个查询不起作用——我做错了什么? :/
On this site, for example, take the first SPARQL query and make something very similar:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX p: <http://dbpedia.org/property/>
SELECT *
WHERE {
?name p:name <http://dbpedia.org/resource/Olivier_Theyskens> .
}
Try to execute it: here
And I get no results. However, modify the query to the following:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX p: <http://dbpedia.org/property/>
SELECT *
WHERE {
?name p:name ?otherthing.
}
And I get results, even though they're not the results I want.
Why doesn't the first query work -- what am I doing wrong? :/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在这种情况下,我认为这是因为您将查询语句向后排序。
DBpedia 资源 (
) 是实体或主题 (?s
),属性 (p:name
) 是属性 或 谓词 (?p
),该属性的值 (?name
) 是值或对象 (<强>?o
)。SPARQL 期望所有语句均为
{ ?s ?p ?o }
,但您的语句似乎写为{ ?o ?p ?s }
...总而言之,如果您尝试此查询 --
-- 您将得到 我认为您想要的结果。
In this case, I think it's because you're ordering your query statement backwards.
The DBpedia resource (
<http://dbpedia.org/resource/Olivier_Theyskens>
) is the Entity or Subject (?s
), the property (p:name
) is the Attribute or Predicate (?p
), and the value of that property (?name
) is the Value or Object (?o
).SPARQL expects all statements to be
{ ?s ?p ?o }
, but yours seems to be written as{ ?o ?p ?s }
...To sum up, if you try this query --
-- you'll get the results I think you want.
您的第一个查询的问题是
p:name
链接到 Literal 并且您尝试匹配 URI。如果您希望第一个查询能够工作,则必须使用链接到 URI 而不是文字的属性
http://dbpedia.org/ontology/artist
:请注意property
此命名空间包含ontology
而不是property
-ontology 是使用的对于对象属性。
The problem with your first query is that
p:name
links to Literal and you try to match a URI.If you want your first query to work you have to to use the property
http://dbpedia.org/ontology/artist
that links to the URI and not the literal:Notice the different name space for the property
<http://dbpedia.org/ontology/artist>
this namespace containsontology
instead ofproperty
-ontology
is the one used for object properties.