Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dbpedia SPARQL query for finding artist properties

Tags:

sparql

dbpedia

I'm trying to get details about an artist via DBPedia and the SPARQL query language, however, it seems almost impossible (with my understanding) of how to get certain pieces of information.

I'm trying to get an Artist and pull information such as their Hometown. I'm guessing the query should be something similar to that of:

SELECT ?c WHERE {
  ?b <http://dbpedia.org/property/Artist> <http://dbpedia.org/resource/Arctic_Monkeys>.
  ?b <http://www.w3.org/2002/07/owl#ObjectProperty> <http://dbpedia.org/ontology/hometown>.
  ?b rdfs:label ?c.
}

If anyone could enlighten me to how it should be done, that would be amazing.

I've been trying out the queries at:

http://dbpedia.org/sparql

like image 880
Domness Avatar asked Dec 20 '22 23:12

Domness


2 Answers

If you want to find the label of their hometown, try this:

SELECT ?hometownLabel WHERE {
  <http://dbpedia.org/resource/Arctic_Monkeys> <http://dbpedia.org/ontology/hometown> ?hometown .
  ?hometown <http://www.w3.org/2000/01/rdf-schema#label> ?hometownLabel .
}
like image 90
Sam Starling Avatar answered Jan 06 '23 09:01

Sam Starling


Maybe you don't have a good understanding of SPARQL syntax. Unlike SQL, SPARQL search results by writing some triples with unknow variables in the WHERE clause. you can try:

prefix dbpedia-owl:<http://dbpedia.org/ontology/>
SELECT ?c 
WHERE {
    <http://dbpedia.org/resource/Arctic_Monkeys> dbpedia-owl:hometown ?c.
}

With this search, you will get Arctic_Monkeys' hometown.

like image 36
Zhang Avatar answered Jan 06 '23 09:01

Zhang