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
5115
accept rate: 0%


Let me answer the question, notice the "Inference rules" link at the top right 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>
}
permanent link

answered 03 Feb '12, 09:23

vladtn's gravatar image

vladtn
5115
accept rate: 0%

edited 09 Jun, 15:52

TallTed's gravatar image

TallTed
2.1k19

If Virtuoso supports SPARQL 1.1, you can do:

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

answered 03 Feb '12, 11:47

scotthenninger's gravatar image

scotthenninger ♦
7.5k1813
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

Virtuoso's SPARQL 1.1 compliance should be complete as of version 6.4.xxxx for Commercial and 6.1.6.xxxx for Open Source, including Property Paths. (Current versions are 7.2 and higher.)

Also, we have published several SPARQL 1.1 examples.

(05 Jun, 12:00) TallTed TallTed'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,

permanent link

answered 08 May '12, 07:58

dr0i's gravatar image

dr0i
13316
accept rate: 0%

edited 08 May '12, 08:26

Virtuoso's SPARQL 1.1 compliance should be complete as of version 6.4.xxxx for Commercial and 6.1.6.xxxx for Open Source, including Property Paths. (Current versions are 7.2 and higher.)

Also, we have published several SPARQL 1.1 examples.

(05 Jun, 12:00) TallTed TallTed's gravatar image
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

Question tags:

×1,414
×292
×215
×32
×12

question asked: 03 Feb '12, 06:10

question was seen: 3,648 times

last updated: 09 Jun, 15:52