2
2

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 03 Feb '12, 06:10

vladtn's gravatar image

vladtn
515
accept rate: 0%


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>
}
link

answered 03 Feb '12, 09:23

vladtn's gravatar image

vladtn
515
accept rate: 0%

edited 03 Feb '12, 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
}
link

answered 03 Feb '12, 11:47

scotthenninger's gravatar image

scotthenninger ♦
7.5k813
accept rate: 17%

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

(07 May '12, 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/

(08 May '12, 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,

link

answered 08 May '12, 07:58

dr0i's gravatar image

dr0i
13316
accept rate: 0%

edited 08 May '12, 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:

×1,162
×244
×182
×22
×12

Asked: 03 Feb '12, 06:10

Seen: 2,414 times

Last updated: 04 Nov '12, 16:13