kroissma
kroissma

Reputation: 21

How to query dbpedia.org with sparql

I'm very new in OpenData and try to write a query in SPARQL.

My goal is to get data for following set of criteria: - Category: Home_automation - select all items from type "Thing" - with at least one entry in "is Product of" - that have a picture-url with a German description

I tried the following:

PREFIX cat:  <http://dbpedia.org/resource/Category:>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT *
WHERE {
  cat:Home_automation skos:broader ?x
}

But now I don't know how to add the other filters to the where clause. I tried to user broader:... to get the items, but I think that was the wrong direction.

I tested the queries with: https://dbpedia.org/sparql

The result should be:

|         (label)          | (url) 
|--------------------------|-----------------------------------
|"Kurzzeitwecker"@de       | urls to the picture of the device 
|"Staubsauger"@de          | -||-
|"Waschmaschine"@de        | -||-
|"Geschirrspülmaschine"@de | -||-

Does anyone have some tips please?

UPDATE: new query:

PREFIX cat: <http://dbpedia.org/resource/Category:>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?s ?label WHERE {
  ?s ?p cat:Home_automation .
  ?s rdf:type owl:Thing .
  ?s rdfs:label ?label
  FILTER (LANG(?label)='de')
}
order by ?p

Upvotes: 1

Views: 1847

Answers (1)

Median Hilal
Median Hilal

Reputation: 1531

It is not clear what you want. You must first know what exact related information dbpedia contains and how they are structured.

However, you can try discovering what types of relationships cat:Home_automation is involved in, thus, you may know better what you want.

I suggest starting by generic queries, to specify how cat:Home_automation occurs in dbpedia, then, you might be able to go more specific, and pose further queries.

A query to list triples where cat:Home_automation is an subject:

PREFIX cat:  <http://dbpedia.org/resource/Category:>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT ?p ?o WHERE {
   cat:Home_automation ?p ?o  
}
order by ?p

A query to list triples where cat:Home_automation is an object:

PREFIX cat:  <http://dbpedia.org/resource/Category:>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT ?s ?p WHERE {
   ?s ?p cat:Home_automation 
}
order by ?p

check the results, see what is interesting for you, and then continue with further queries.

Upvotes: 1

Related Questions