How to form dbPedia iSPARQL query (for wikipedia content)

最后都变了- 提交于 2019-12-01 13:02:39

You can also query dbpedia using its SPARQL endpoint (less fancy than iSPARQL). To find out more about what queries to write, take a look at the DBpedia's datasets page. The examples there show how one can select pages based on Wikipedia categories. To select resources in the Wikipedia Mountains category, you can use the following query:

select ?mountain where {
  ?mountain a dbpedia-owl:Mountain .
}

SPARQL Results

Once you have some of these links in hand, you can look at them in a web browser and see the data associated with them. For instance the page for Mount Everest shows lots of properties. For restricting results to those pages that have an image, you might be interested in the dbpedia-owl:thumbnail property, or perhaps better yet foaf:depiction. For the introductory paragraph, you probably want something like the dbpedia-owl:abstract. Using those, we can enhance the query from before. The following query finds things in the category Stratovolcanoes with an abstract and an depiction. Since StackOverflow is an English language site, I've restricted the abstracts to those in English.

select * where {
  ?mountain a dbpedia-owl:Mountain ;
            dbpedia-owl:abstract ?abstract ;
            foaf:depiction ?depiction .
  FILTER(langMatches(lang(?abstract),"EN"))
}
LIMIT 10

SPARQL Results

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