0
2

Assuming I have a specific DBpedia type (under the namespace http://dbpedia.org/ontology), how can I get its:

  • subtypes
  • supertypes
  • members (transitively)

This all using the SPARQL endpoint http://dbpedia.org/sparql (which I am not sure supports SPARQL 1.1) without the need to use any external tool.

This is related to my earlier question: http://answers.semanticweb.com/questions/15394/transitive-closure-of-subclassof-in-dbpedia, but more general.

asked 26 Mar '12, 05:51

myahya's gravatar image

myahya
1036
accept rate: 0%

edited 26 Mar '12, 05:55


To get all instances of a class (transitively):

## Inference Context Enabled ##
DEFINE input:inference "http://dbpedia.org/resource/inference/rules/dbpedia#"
SELECT COUNT(*)
WHERE {
  ?x a <http://dbpedia.org/ontology/NaturalPlace>
}

## Inference Context Enabled ##
DEFINE input:inference "http://dbpedia.org/resource/inference/rules/yago#"

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

Get all subclasses:

SELECT count(?x)

WHERE
  {
    {
      SELECT *
      WHERE
        {
          ?x rdfs:subClassOf ?y .
        }
    }  OPTION (transitive, t_distinct, t_in (?x), t_out (?y) ).
  FILTER (?y = <http://dbpedia.org/ontology/Person>)
}

Get all superclasses

SELECT ?y
WHERE
  {
    {
      SELECT *
      WHERE
        {
          ?x rdfs:subClassOf ?y .
        }
    }
    OPTION (TRANSITIVE, t_distinct, t_in (?x), t_out (?y) ) .
    FILTER (?x = <http://dbpedia.org/ontology/Cricketer>)
  }

link

answered 26 Mar '12, 08:47

myahya's gravatar image

myahya
1036
accept rate: 0%

edited 26 Mar '12, 15:18

Hi,

You can find a rich collection of examples also here: -- Virtuoso Collection of Transitive SPARQL Query Options and Exploit Inference Rules

Best Regards,
Rumi Kocis

link

answered 22 Jan '13, 10:57

Rumi's gravatar image

Rumi
111
accept rate: 0%

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:

×244
×146

Asked: 26 Mar '12, 05:51

Seen: 2,129 times

Last updated: 22 Jan '13, 10:57