开发者

Retrieving a DBpedia resource by its string name with SPARQL

I am trying to get the resource describing country Romania by the country name with this query:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX : <http://dbpedia.org/resource/>

SELECT DISTINCT ?x WHERE {
     ?x foaf:name 'Romania'
}

SPARQL results

However, it does not retrieve anything. How can I get the resource http://dbpedia.org/resource/Romania (:Romania) by the string 'Romania'. If I want to retrieve the nam开发者_StackOverflow中文版e of the country by the country resource I use the following query which works fine:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX : <http://dbpedia.org/resource/>

SELECT DISTINCT ?x WHERE {
     :Romania foaf:name ?x
}

SPARQL results


This ought to do it:

SELECT ?c
WHERE {
  ?c a dbo:Country ;
     foaf:name "Romania"@en .
  FILTER NOT EXISTS { ?c dbo:dissolutionYear ?y }
}

SPARQL results

The critical quirk here is that "Romania" with no language tag is different from "Romania"@en. And then you also have a bunch of historical states that were also called Romania, so we filter out any of those that have years of dissolution. DBpedia's data-completeness for years of dissolution isn't terrific, but all the Romanian ones, at least, are marked.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜