I am trying to extract the hierarchy of Wikipedia category or Yago classification for DBpedia resources using the SPARQL endpoint. For instance, I would like to find out all the possible categories and classes in hierarchical form of entity, say, http://dbpedia.org/resource/Nokia, like Thing → Organization → Company → … → Nokia.
相关问题
- Creating a SPARQL parameterized query using append
- Getting list of persons using SPARQL dbpedia
- Getting list of persons using SPARQL dbpedia
- How can I optimize a SPARQL query that returns opt
- Calculate the depth of subclass in the OWL ontolog
相关文章
- The difference between blank nodes and variables i
- How to display alert box when no json value is giv
- How to turn a SPARQL/SPIN query/rule into an RDF s
- Meaning of owl:hasValue?
- boundary for arbitrary property path in SPARQL 1.1
- boundary for arbitrary property path in SPARQL 1.1
- sparql complete tree from subject
- Jena Fuseki assembler file + TDB + OWL reasoner
A simple SPARQL select can retrieve the information that you're interested in, though it won't be arranged hierarchically. You're interested in getting all the types of a resource, as well as the
rdfs:subClassOf
relations between them. Here's a very simple query for Nokia that can be run on the DBpedia SPARQL endpointSPARQL results
If you treat each pair of classes in that result set as a directed edge and perform a topological sort , then you'll see the hierarchy of the classes to which the Nokia resource belongs. In fact, since it is probably convenient to treat this as a graph, you can get it in the form of an RDF graph by using a SPARQL construct query.
SPARQL results
The construct query produces this graph (in N3 format):
Remarks
The queries above retrieve the
rdf:type
hierarchy for Nokia. In the question, you also mention Wikipedia categories. DBpedia resources are associated with the Wikipedia categories to which their corresponding articles belong by thedcterms:subject
property. Those Wikipedia categories are then structured hierarchically byskos:broader
. These really are not types for the individuals though. For instance, the data contain:While it probably makes sense to say that Nokia is a Finnish_brand, it makes much less sense to say that Nokia is a Brand_by_country.