0

如何从此查询中获取首都的值名称而不是 URI

SELECT ?capital 
WHERE { <http://dbpedia.org/resource/Germany><http://dbpedia.org/ontology/capital> ?capital}

在上面的查询中,我得到了德国首都的 URI。即 http://dbpedia.org/resource/berlin 如何获得只有柏林而不是它的 URI

4

1 回答 1

3

您想要的值实际上是 RDFS 标签属性的值。如果您使用的是公共 DBpedia SPARQL 端点,那么您可以使用如下查询:

select ?label where {
  dbpedia:Germany dbpedia-owl:capital/rdfs:label ?label .
  filter langMatches(lang(?label),"en")
}

财产路径dbpedia-owl:capital/rdfs:label意味着您获得了德国的首都,然后获得了它的标签。该filter表达式允许您仅选择资源的英文标签。当然,您可以删除此过滤器,但您会得到多个结果,因为资源具有不同语言的标签。

于 2014-04-01T18:29:27.480 回答