dbpedia SPARQL query for finding artist properties

房东的猫 提交于 2020-01-03 15:55:22

问题


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


回答1:


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 .
}



回答2:


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.




回答3:


SELECT ?hometown 
WHERE {
dbr:Arctic_Monkeys dbo:hometown ?label.
?label rdfs:label ?hometown.
FILTER(langMatches(lang(?hometown), "en"))
}


来源:https://stackoverflow.com/questions/10245503/dbpedia-sparql-query-for-finding-artist-properties

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!