3

我在http://dbpedia.org/snorql/中执行这个查询:

询问:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>        
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX prop: <http://dbpedia.org/property/>
SELECT ?country_name ?population
WHERE {
    ?country a type:LandlockedCountries ;
             rdfs:label ?country_name ;
             prop:populationEstimate ?population .
} 

该查询查找所有陆地国家。

我不明白为什么结果中没有一些国家被归类为“/dbpedia.org/class/yago/LandlockedCountries”。例如,巴拉圭 (/dbpedia.org/page/ParaguAy) 已分类但未出现在查询结果集中。有人可以解释一下为什么吗?

4

1 回答 1

4

不幸的是,有少数内陆国家没有country_namepopulationEstimate属性中的至少一个。这就是为什么它们不会在您的查询中返回的原因。如果您运行以下查询,则会出现这些国家/地区(这两个属性设置为OPTIONAL)。

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>        
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX prop: <http://dbpedia.org/property/>
SELECT ?country ?country_name ?population
WHERE {
    ?country a type:LandlockedCountries .
    OPTIONAL {?country rdfs:label ?country_name Filter(lang(?country_name) = 'en')} .
    OPTIONAL {?country prop:populationEstimate ?population} .
}

运行查询

为了(稍微)更好的结果,由于某些国家似乎与错误的大写重复(例如ParaguAyParaguay),以下查询使用 ?country dcterms:subject category:Landlocked_countries而不是 yago 类。

运行查询

于 2013-04-21T19:42:24.953 回答