简体   繁体   English

查询 DBpedia 以获取纯英文描述(使用 SPARQL)

[英]Querying DBpedia for English-only description (with SPARQL)

I'm querying dbpedia.org for a description of Big Ben with this SPARQL query:我正在使用这个 SPARQL 查询查询 dbpedia.org 以获取 Big Ben 的描述:

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.这将返回至少 10 种不同语言的描述列表。 How do I specify that I only want the English language description?如何指定我只需要英文描述?

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:您需要知道的关键是 str() 和 lang() 将值的文本和语言分开,因此您可以这样做:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM