Reputation: 99
I'm trying to extract the types and their respective levels from an entity named through DBPediaSpotlight. I already looked in forums, the documentation of the git hub and found nothing. I would like to know one way to do this extraction. Thank you!
Upvotes: 2
Views: 786
Reputation: 71
As mentioned here, you may need this in SPARQL to fetch the categories from DBpedia URI
PREFIX dbr: <http://dbpedia.org/resource/>
SELECT DISTINCT ?subject
WHERE { dbr:Semantic_Web dct:subject ?subject }
LIMIT 100
which might be retrieved in various serializations. For example in JSON
Upvotes: 1
Reputation: 9444
Given that your desired root is <http://www.w3.org/2002/07/owl#Thing>
, you're actually looking for the rdf:type
tree (not Wikipedia Categories, as such).
The typing of <http://dbpedia.org/resource/Semantic_Web>
seems a bit odd, so I've used <http://dbpedia.org/resource/Cat>
below. You'll note that the data does not always include a tree of the sort you wish.
This will get explicit rdf:type
statements --
SELECT ?type
WHERE
{ <http://dbpedia.org/resource/Cat> a ?type
}
-- and this will climb to the top of any rdf:type
trees --
SELECT ?type
WHERE
{ <http://dbpedia.org/resource/Cat> a+ ?type
}
A query to build the full tree would be rather more complex, but is entirely possible.
Upvotes: 2