Querying DBpedia for English-only description (with SPARQL)

元气小坏坏 提交于 2020-01-22 17:47:05

问题


I'm querying dbpedia.org for a description of Big Ben with this SPARQL query:

select ?desc 
where {
<http://dbpedia.org/resource/Big_Ben> <http://www.w3.org/2000/01/rdf-schema#comment> ?desc
}

This returns a list of descriptions in at least 10 different languages. How do I specify that I only want the English language description?


回答1:


The keys you need to know are that str() and lang() pull apart the text and language of the value, so you can do this:

select str(?desc) 
where {
  <http://dbpedia.org/resource/Big_Ben> <http://www.w3.org/2000/01/rdf-schema#comment> ?desc
  FILTER (langMatches(lang(?desc),"en"))
}


来源:https://stackoverflow.com/questions/6325407/querying-dbpedia-for-english-only-description-with-sparql

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