Finding corresponding State for POIs using skos:broader

牧云@^-^@ 提交于 2019-12-25 03:34:04

问题


I am trying to collect POIs per State in the United States. 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.

The approach did not work as I got multiple states for one 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. Is there a better approach?


回答1:


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. 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:

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)
}


来源:https://stackoverflow.com/questions/29414522/finding-corresponding-state-for-pois-using-skosbroader

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!