Search code examples
sparqldbpedia

How to ASK if there is any country in the United Nations called “Paris” using SPARQL


I have been trying to do this query but im not sure about how is the syntax I need. I have seen a lot of examples of how to ask in a query to check if something is larger or shorter than other thing, but I have no idea of how to ask if something is IN other thing.

This is my last (failed) try:

PREFIX : <http:/dbpedia.org/resource/>
ASK
{
 FILTER(<http:/dbpedia.org/resource/Paris> IN <http:/dbpedia.org/resource/Member_states_of_the_United_Nations>)
}

Solution

  • Part of the issue is that there's a DBpedia resource called

        http:/dbpedia.org/resource/Member_states_of_the_United_Nations

    but what you actually want, since its the value of the dct:subject property, is the category,

        http://dbpedia.org/page/Category:Member_states_of_the_United_Nations

    For instance, you can get a list of countries that are member states with a query like:

    select ?country {
      ?country a dbo:Country ; 
               dct:subject dbc:Member_states_of_the_United_Nations 
    }
    

    SPARQL results

    However, Paris isn't a country that's a member. It's a city in France, which is a member. You can check whether something is a member with an ask query like:

    ask {
      dbr:France a dbo:Country ; 
                 dct:subject dbc:Member_states_of_the_United_Nations 
    }
    

    SPARQL results (true)

    You could get a list of populated places in countries that are member with a query like:

    select ?city ?country {
      ?city a dbo:PopulatedPlace ;
            dbo:country ?country .
      ?country a dbo:Country ; 
               dct:subject dbc:Member_states_of_the_United_Nations .
    }
    

    SPARQL results (limited to 100)

    and you can modify that to be an ask query that checks for cities with specific names. E.g.:

    ask {
      ?city rdfs:label "Paris"@en ;
            a dbo:PopulatedPlace ;
            dbo:country ?country .
      ?country a dbo:Country ; 
               dct:subject dbc:Member_states_of_the_United_Nations .
    }
    

    SPARQL results (true)