login about faq
2
1

Is there a way to get from dbpedia's virtuoso's server all instances of a type <class> and of the subclasses of this <class>. I found some documentation about transitive queries in virtuoso but not sure how to use it.

If there isn't a way to get all of that with a single sparql query, what will then be the preferred query sequence?

asked Feb 03 at 06:10

vladtn's gravatar image

vladtn
413


Let me answer the question, notice the Inference rules link at the top left corner of dbpedia's sparql endpoint. Adding a reference to the inference set you want to use (as I understand it a graph where inference has already been executed) will add inferred results to your query. For example the query:

SELECT COUNT (*)
WHERE
{
  ?s  a  <http://dbpedia.org/class/yago/Church103028079>
}

returns 1790 results. While the same query using inference (below) returns 9065 results, taking into account instances of subclasses of cy:Church103028079.

define input:inference "http://dbpedia.org/resource/inference/rules/yago#"
SELECT COUNT (*)
WHERE
{
  ?s  a  <http://dbpedia.org/class/yago/Church103028079>
}

answered Feb 03 at 09:23

vladtn's gravatar image

vladtn
413

edited Feb 03 at 09:25

If Virtuoso supports SPARQL 1.1, you can do:

SELECT *
WHERE
{  ?cls rdfs:subClassOf* <http://dbpedia.org/class/yago/Church103028079> .
   ?inst a ?cls
}

answered Feb 03 at 11:47

scotthenninger's gravatar image

scotthenninger
6.2k813

it is not "rdfs:subClassOf*" but "rdfs:subClassOf" (that is: leave the wildcard)

(May 07 at 11:13) dr0i dr0i's gravatar image
1

ah - without the wildcard you get only one depth of subclasses and not all subclasses recursively. See http://www.w3.org/TR/sparql11-property-paths/

(May 08 at 06:39) dr0i dr0i's gravatar image

since virtuoso (and hence:dbpedia) doesn't implement all SPARQL 1.1 features, you can't go straight forward using property paths (as scotthenninger mentioned). If you need more than one depth of subclasses (recursively) - virtuoso has its own workaround, try this:


SELECT DISTINCT  COUNT (?x)  WHERE
{
{ SELECT ?x ?y WHERE { ?x rdfs:subClassOf ?y } }
OPTION ( TRANSITIVE, T_DISTINCT, t_in(?x), t_out(?y), t_step('path_id') as ?path, t_step(?x) as ?route, t_step('step_no') AS ?jump, T_DIRECTION 2 )
FILTER ( ?y = <http://dbpedia.org/class/yago/Church103028079> )
}
(source : following links in property paths in dbpedia benchmark )

This query shows up 2863 - thats the number of all distinct (direct and indirect) subclasses (and not: instances of subclasses as vladtn described) of yago:Church103028079,

answered May 08 at 07:58

dr0i's gravatar image

dr0i
935

edited May 08 at 08:26

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×593
×120
×115
×16
×7

Asked: Feb 03 at 06:10

Seen: 509 times

Last updated: May 08 at 08:26