[英]Finding corresponding State for POIs using skos:broader
I am trying to collect POIs per State in the United States. 我正在尝试在美国每个州收集POI。 The original query was 原始查询为
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'))
}
The filter portion was to find the US states(shown below) such that, at the end we know each POI belongs to what state. 过滤器部分是找到美国的州(如下所示),以便最终我们知道每个POI属于哪个州。
The approach did not work as I got multiple states for one POI. 该方法不起作用,因为我为一个POI获得了多个状态。 As an example if I run the following query to find the US State for 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'))
}
It would result Pentagon being in all states. 五角大楼将处于所有州。 I know this is due skos:broader{,9}
but how do I know, the optimum level to set it for. 我知道这是由于skos:broader{,9}
但是我怎么知道设置它的最佳水平。 Is there a better approach? 有没有更好的方法?
I am not sure what exactly you are trying to achieve with your queries, I can't get my head around them. 我不确定您要通过查询实现什么目标,我无法理解。 But based on your description, I think you just need places of interest alongside the states they are in. If that is the case, I have written the following query. 但是根据您的描述,我认为您只需要关注景点和它们所在的州即可。如果是这种情况,我已经写了以下查询。
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)
}
If you want, you can even go further and describe the place as a building, but I don't think POIs are necessarily buildings. 如果需要,您甚至可以进一步将其描述为建筑物,但我认为POI不一定是建筑物。 But if you want to name them as buildings, then: 但是,如果要将它们命名为建筑物,则:
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)
}
To show the use case, you can filter the ?POI for Pentagon: 为了显示用例,您可以过滤五角大楼的?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)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.