Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Querying DBpedia for English-only description (with SPARQL)

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?

like image 466
siamii Avatar asked Jun 12 '11 23:06

siamii


People also ask

How do I query DBpedia with SPARQL?

To actually query DBpedia, you can go to dbpedia.org/sparql and submit your query to return the results in a number of formats such as HTML, JSON or CSV. You can also run SPARQL on DBpedia from within a Python application but that will be covered in my next blog.

What is SPARQL prefix?

"PREFIX", however (without the "@"), is the SPARQL instruction for a declaration of a namespace prefix. It allows you to write prefixed names in queries instead of having to use full URIs everywhere. So it's a syntax convenience mechanism for shorter, easier to read (and write) queries.

How do I find DBpedia?

You can find a deployment of the generic entity retrieval service equipped with the DBpedia Lookup index at https://lookup.dbpedia.org. Another application example can be found on the DBpedia Databus website. In this case the Lookup service provides a search over the RDF-based website content.

What is SPARQL used for?

SPARQL can be used to express queries across diverse data sources, whether the data is stored natively as RDF or viewed as RDF via middleware. SPARQL contains capabilities for querying required and optional graph patterns along with their conjunctions and disjunctions.


1 Answers

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"))
}
like image 87
glenn mcdonald Avatar answered Sep 23 '22 17:09

glenn mcdonald