0

all. I'm trying to write a simple SPARQL query generator to fetch all rdf:type relations of a specific DBPedia resource.

query = """SELECT * WHERE {{ <""" + resource """> rdfs:type ?subject.}}"""

This yields the Query

SELECT * WHERE {{ <http://dbpedia.org/page/Energy> rdfs:type ?subject.}}

But the query returns empty. What am I doing wrong? The DBPedia entry clearly has rdfs:type relations:

owl:Thing
dbo:Building
yago:Abstraction100002137
yago:Assets113329641
yago:NaturalResource113332009
yago:Possession100032613
yago:Relation100031921
yago:Resource113331778
yago:WikicatNaturalResources

Thanks in advance!

Vid Stropnik
  • 182
  • 10

1 Answers1

2

Change the energy address from page to resource, the query looks like this (in addition, I suggest you to use the a instead of therdf:type):

SELECT * WHERE {{ <http://dbpedia.org/resource/Energy> a ?subject.}}

In order to avoid this issue, chech the exact resurces addresses in a raw data format. For example, the XML triples can be reviewed with a web browser from the dbpedia webpage. http://dbpedia.org/page/Energy, in the top bar there is a button named formats.

  • This answers my question. However, I'm not always querying for `rdf:type`. How will the suggestion of using `a` compare when querying for, for example, `skos:broaderOf` or `dct:subject`? – Vid Stropnik Jul 01 '20 at 19:07
  • 1
    The use of `a` instead of `rdf:type` is for increasing the query readability, the `a` is a shorter term and it can be used without adding any preffix on the top. However, I am afraid that the rest of the URIs (preffix + concept label) does not implement this kind of syntactic sugar. Here you can find this feature explaned: https://www.w3.org/TR/rdf-sparql-query/#abbrevRdfType. Anyway as you said this is just a suggestion. – Fernando Luján Martínez Jul 02 '20 at 11:51