如何检索以"http://fr.dbpedia.org"开头的 DBPedia 页面



我有一个DBPedia资源作为

http://dbpedia.org/page/London

。我想使用SPARQL获得http://dbpedia.org/page/London的法语页面。我注意到我可以通过owl:sameAs检索这些信息。

我试图在http://dbpedia.org/sparql端点上编写此查询以检索http://fr.dbpedia.org/page/Londres页面:

prefix owl: <http://www.w3.org/2002/07/owl#>
select ?resource where {
?resource owl:sameAs "http://dbpedia.org/page/London"
FILTER strStarts (?resource, "http://fr.dbpedia.org")

我特别想使用"strStarts"属性,因为我看过这个文档:http://www.w3.org/TR/sparql11-query/#func-strstarts。这个文档说"STRSTARTS函数对应于XPath fn:starts-with函数",我想使用这个函数来检索以"http://fr.dbpedia.org"开头的三元组。

但是,从我的查询我没有得到任何结果。为什么?我哪里做错了?

您的查询有几个问题。首先,uri不是字符串,所以您需要使用<http://dbpedia.org/page/London>而不是"http://dbpedia.org/page/London"。其次,这是伦敦的错误URI。资源为<http://dbpedia.org/resource/London>。(是的,当你把它放在网页浏览器中,你会被重定向到…/page/London;但这不是资源的URI。)在公共端点上,URI可以缩写为dbpedia:London。第三,因为URI不是字符串,所以需要filter strstarts( str(?resource), … ),显式地获取URI的字符串形式。因此:

select ?resource where {
  ?resource owl:sameAs dbpedia:London
  filter strstarts(str(?resource), "http://fr.dbpedia.org")
}
SPARQL结果

最新更新