使用 skos:broader 查找 POI 的相应州

Finding corresponding State for POIs using skos:broader

我正在尝试收集美国每个州的兴趣点。原始查询是

select distinct ?s ?state 
where { 
?s a dbpedia-owl:Place; dcterms:subject/skos:broader{,9} ?state . 
?state skos:broader  category:Buildings_and_structures_in_the_United_States_by_state . 
filter contains(str(?state),'_in_') . 
filter(!contains(str(?state),'United_States')) 
 }

过滤部分是找到美国各州(如下所示),最后我们知道每个 POI 属于哪个州。

该方法无效,因为我为一个 POI 设置了多个状态。 例如,如果我 运行 以下查询查找 Pentagon

的美国州
select distinct ?state 
where { 
dbpedia:The_Pentagon dcterms:subject/skos:broader{,9} ?state . 
?state skos:broader  category:Buildings_and_structures_in_the_United_States_by_state . 
filter contains(str(?state),'_in_') . 
filter(!contains(str(?state),'United_States'))  
}

这将导致五角大楼在所有州。我知道这是由于 skos:broader{,9} 但我怎么知道设置它的最佳级别。有更好的方法吗?

我不确定您的查询到底想达到什么目的,我无法理解它们。但根据您的描述,我认为您只需要名胜古迹及其所在州。如果是这种情况,我编写了以下查询。

SELECT distinct ?POI ?state WHERE {
    ?POI a dbpedia-owl:Place.
    ?POI dbpedia-owl:location ?location.
    ?location dbpedia-owl:country ?country.
    ?location dbpprop:state ?state.
    filter(?country =dbpedia:United_States)
}

如果你愿意,你甚至可以更进一步,将这个地方描述为建筑物,但我认为兴趣点不一定是建筑物。但是如果你想把它们命名为建筑物,那么:

SELECT distinct ?POI ?state WHERE {
    ?POI a dbpedia-owl:Place.
    ?POI a dbpedia-owl:Building.
    ?POI dbpedia-owl:location ?location.
    ?location dbpedia-owl:country ?country.
    ?location dbpprop:state ?state.
    filter(?country =dbpedia:United_States)
}

要显示用例,您可以过滤五角大楼的 ?POI:

SELECT distinct ?POI ?state WHERE {
    ?POI a dbpedia-owl:Place.
    ?POI a dbpedia-owl:Building.
    ?POI dbpedia-owl:location ?location.
    ?location dbpedia-owl:country ?country.
    ?location dbpprop:state ?state.
    filter(?country =dbpedia:United_States)
    filter(?POI=dbpedia:The_Pentagon)
}