I am willing to seek your opinion on if it is possible to design some SPARQL query that will return the concept definitions i.e. Assuming that I have an ontology, I want to retrieve the 'necessary and sufficient conditions' defined for any random concept within that Ontology via SPARQL queries (or for that matter, any API which could do that).

I am writing a Java program and I need the program to retrieve concept definitions from ontology. Please suggest me your ideas.

asked 16 Feb '11, 08:10

bikashg's gravatar image

bikashg
269116
accept rate: 0%

edited 04 Nov '11, 09:00

You might be interested in this Stack Overflow question, Check if an underlying representation is OWL or RDFS, where an answer (disclosure: mine) describes how to extract RDFS schemata and OWL ontologies via a SPARQL query. This would presumably include the concept definitions (if they're in the data).

(19 Dec '13, 11:07) Joshua Taylor Joshua%20Taylor's gravatar image

I don't know if you can do that with Sparql, i think it's not designed for such a task. But if you are not restricted to Sparql then you could give a try to the owlapi.

http://owlapi.sourceforge.net/

hth josh

permanent link

answered 16 Feb '11, 08:46

Joshua%20Bacher's gravatar image

Joshua Bacher
23127
accept rate: 0%

i think you could use the method getAxims(clazz) in OWLOntology to get the concept definition for this clazz.

(16 Feb '11, 09:01) Joshua Bacher Joshua%20Bacher's gravatar image

Ok. Thanks for the clue, Tunichgud. I will try and write back.

(16 Feb '11, 09:20) bikashg bikashg's gravatar image

This is incorrect. OWL can be specified in RDF and SPARQL queries RDF, so it is possible. I've posed a more accurate answer to the question on SPARQL.

(16 Feb '11, 16:54) scotthenninger ♦ scotthenninger's gravatar image
1

@Scott : I don't think its incorrect. I think that this and your's are two different approaches. This one is via using API and your's is by writing a query. I agree that knowing to write a query is better; however API also makes life easy.

(18 Feb '11, 10:33) bikashg bikashg's gravatar image

Since all the RDFS and OWL definitions will be built from a specific vocabulary defined by OWL, one could simply ask for all those triples, no? That's the approach described in Check if an underlying representation is OWL or RDFS on Stack Overflow (disclaimer: I answered that question).

(19 Dec '13, 11:09) Joshua Taylor Joshua%20Taylor's gravatar image

By "necessary and sufficient conditions", I expect you mean the owl:equivalentClass definitions? I.e. local class restrictions applied to owl:equivalentClass, This can easily be done in SPARQL. Start with:

SELECT *
WHERE
{  ?s owl:equivalentClass ?o
}
If the objective from there is to get the details of the restrictions, you just need to follow the triples that define the restrictions. This query will get the restriction type, property, and value for all equivalent class definitions:
SELECT *
WHERE
{  ?cls owl:equivalentClass ?restriction .
   ?restriction owl:onProperty ?prop .
   ?restriction ?restrictType ?value
}

Getting to intersections and other OWL statements is admittedly more complex, but entirely possible. Note the same can be done for rdfs:subClassOf restrictions (sometimes known as necessary conditions).

permanent link

answered 16 Feb '11, 16:54

scotthenninger's gravatar image

scotthenninger ♦
7.5k1813
accept rate: 17%

edited 16 Feb '11, 21:18

Class expressions can be arbitrarily complex and are generally constructed recursively from other class expressions. For example, you could have an intersection, where the first class is a union of enumerations, the second class is a cardinality restriction on the complement of another boolean expression, which again has restrictions, etc. I would like to see from you a SPARQL query that matches precisely the set of all recursively created class expressions. Give me the SPARQL, and I'll owe you a beer! :-)

(04 Nov '11, 10:48) Michael Schn... ♦ Michael%20Schneider's gravatar image

Can you give me a real-world example where this kind of use case occurs?

(21 Nov '12, 13:58) scotthenninger ♦ scotthenninger's gravatar image

Do you ask for a single SPARQL query to get them all, and only those?

I guess that even for the "restricted" case, where you only allow for valid OWL DL ontologies as input graphs, this would essentially require to implement a major part of the matching algorithm that underlies the reverse OWL 2 RDF Mapping... as a SPARQL query! The matching of the many different forms of class expressions is among the most complex aspects of this algorithm, and that algorithm is complex!

So even if it would be technically feasible, I could not imagine anyone on earth who would want to execute such an insane exercise. But I don't really believe that it is possible at all, unless SPARQL would turn out to be Turing-complete. And for input beyond OWL 2 DL (i.e. for arbitrary RDF / OWL Full input), it is not even entirely well-defined what counts as a proper class expression or class axiom /syntactically/, and what not. But without such a definition, your question cannot even be answered in a meaningful and precise way with "yes" or "no" in such a scenario...

permanent link

answered 04 Nov '11, 10:38

Michael%20Schneider's gravatar image

Michael Schn... ♦
6.2k1712
accept rate: 34%

edited 04 Nov '11, 14:00

If you use Jena, or Jena+Pellet, retrieving the class hierarchy of an RDFS/OWL ontology is not too difficult. You can use listHierarchyRootClasses(), listSubClasses(), and listDeclaredProperties(). (Google is your friend for more info about these methods).

Getting this data from a remote SPARQL endpoint which provides no additional ontology of its concepts requires a quite complicated SPARQL query (that will probably timeout before you get any answer).

permanent link

answered 16 Feb '11, 09:59

datao's gravatar image

datao
271
accept rate: 0%

What I was asking was for retrieving the "necessary and sufficient conditions" of concepts; not merely the class hierarchy.

(16 Feb '11, 15:52) bikashg bikashg'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,328
×686
×46

question asked: 16 Feb '11, 08:10

question was seen: 4,321 times

last updated: 19 Dec '13, 11:09