8

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 name 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

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353

1 Answers1

10

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.

Peter K.
  • 8,028
  • 4
  • 48
  • 73
glenn mcdonald
  • 15,290
  • 3
  • 35
  • 40
  • @glennmcdonald Interestingly, some years later, someone has used the country infobox template on the Romania page, so the results also include [Commemorative_coins_of_Romania](http://dbpedia.org/resource/Commemorative_coins_of_Romania)! – Joshua Taylor Jun 20 '13 at 02:36
  • Even more interestingly, the `dissolutionDate` property was important in answering [this question](http://stackoverflow.com/q/6392515/1281433) as well. – Joshua Taylor Jun 21 '13 at 17:00