2

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!

Angelo Neves
  • 99
  • 1
  • 5
  • What you want to achieve is unclear (e.g., what are "respective levels" of "types" and how do these relate to "categories"?). Why you specifically want to use DBpedia Spotlight to get there is also unclear. Have you looked at any of the other interfaces to DBpedia? [SPARQL](http://dbpedia.org/sparql), [iSPARQL](http://dbpedia.org/isparql), [Facet Browser](http://dbpedia.org/fct), etc? – TallTed Dec 23 '16 at 16:31
  • Actually I'm trying to get the categories of dbpedia through a uri. For example: "What categories I could get through this URI:" http://dbpedia.org/resource/Semantic_Web. "From what I've been researching, DBPedia categories work like a tree, where the root is" Thing " So I would like to get the categories corresponding to this URI and the height of the tree. To get the categories and their level, it can be by SPARQL or DBPedia Spotlight. – Angelo Neves Dec 25 '16 at 03:47

2 Answers2

2

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.

TallTed
  • 9,069
  • 2
  • 22
  • 37
1

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

Ubaid Rana
  • 71
  • 5
  • How does this answer apply to this question? `dct:subject` does not link articles to [Wikipedia Categories](https://en.wikipedia.org/wiki/Wikipedia:Classification), nor entities to `rdf:type`s... – TallTed Feb 11 '19 at 18:46