miTzuliK
miTzuliK

Reputation: 93

How to retrieve DBPedia 'class' attribute for a given word using Sparql?

So I have a word like, for example, 'Horse', and I want to retrieve its class. That would be 'Mammal', as shown here: http://dbpedia.org/page/Horse .

I tried something, but it's not returning anything.

String queryString =  "PREFIX dbr: <http://dbpedia.org/resource/>"
                    + "PREFIX dbo: <http://dbpedia.org/ontology/>"
                    + "select ?class where {dbr:Horse dbo:?class}";

Any advices ?

Upvotes: 0

Views: 803

Answers (1)

UninformedUser
UninformedUser

Reputation: 8465

SPARQL queries make use of so-called triple patterns, your query returns only a tuple and the second part even in strange syntax. Moreover, instances are asserted to classes by rdf:type property. dbo:class on the other hand is more a property for the biological term class. Obviously, your query is ill-formed and the dbo:class part overlap with the ?class variable. I'm wondering why you didn't see that - it's too obvious...

PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?class WHERE {
  dbr:Horse dbo:class ?class
}

Upvotes: 1

Related Questions