|
To answer this historical question, I want to query DBpedia for all members of the United States House of Representatives. Unfortunately, the following DBpedia query does not reach sub-categories and I get only 4 results:
How to get all representatives, including those in sub-categories? |
|
Categories are related by the skos:broader property. Until DBpedia supports SPARQL 1.1 property paths, to expand one level of sub-categories try something like:
|
|
Generally speaking, what you need is a way to traverse chains of
Unfortunately, the DBPedia endpoint does not yet support this SPARQL 1.1 construction, so this particular solution won't help you immediately. However, the DBPedia endpoint does offer the option of using additional inference rules when evaluating a SPARQL query. In this case, what you want is to have SKOS transitivity rules enabled. You can do this by adapting your query as follows:
I'm not sure the skos-trans rule works. For example, the following returns 7, even though the category higherarchy extends deeper: |
|
To use transitivity in SPARQL on a Virtuoso endpoint (who is use by Dbpedia) you can use an OPTION. Like this :
You can use the very helpfull option t_max, who is the number of jump of your recursivity. P.S : If you have a solution to make a real RDF hierarchy of categories with a CONSTRUCT query, I'm really interested by that :) |

