Question

I'd like to query DBPedia with SPARQL to select car manufacturers (of France to start), but I have no idea how to do this.

I started with this query:

select distinct * where {
  ?carManufacturer dbpedia-owl:product <http://dbpedia.org/page/Automobile> .
  ?carManufacturer dbpprop:locationCountry "France"@en
} LIMIT 100

However, it returns an empty result set. What am I doing wrong?

Was it helpful?

Solution

You’re using the wrong URI to identify DBPedia resources. On DBPedia, http://dbpedia.org/resource/Automobile refers to the noun ‘automobile’, while http://dbpedia.org/page/Automobile refers to a page describing the noun ‘automobile’. Thus,

SELECT DISTINCT * WHERE {
  ?carManufacturer dbpedia-owl:product <http://dbpedia.org/resource/Automobile>.
  ?carManufacturer dbpprop:locationCountry "France"@en.
} LIMIT 100

works just fine.

However, if you want to be a bit more idiomatic, you can use a bit of syntactic sugar to eliminate the subject repetition in your query. DBPedia also loads http://dbpedia.org/resource/ as prefix dbpedia, so you can actually eliminate all URIs from your query entirely:

SELECT DISTINCT * WHERE {
  ?carManufacturer dbpedia-owl:product dbpedia:Automobile;
                   dbpprop:locationCountry "France"@en.
} LIMIT 100
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top