net.sourceforge.fluxion.utils
Class OWLUtils

java.lang.Object
  extended by net.sourceforge.fluxion.utils.OWLUtils

public class OWLUtils
extends java.lang.Object

A utility class used to examine OWLDescriptions, and break down the axioms that make up the knowledge about OWLDescriptions into classsplit up an OWL class into smaller, constituent elements (such as the set of a classes superclasses or subclasses). A lot of these utils are very powerful, making extensive calls to a reasoner, when used to examine the relationships between classes and properties in the inferred heirarchy, and as such can use considerable compute resources if used unchecked.

Version:
0.2
Author:
Tony Burdett

Constructor Summary
OWLUtils()
           
 
Method Summary
static java.util.Set<org.semanticweb.owl.model.OWLDescription> deconstruct(org.semanticweb.owl.model.OWLDescription owlDescription)
          If the OWLDescription is an OWLObjectUnionOf, it is broken down into the set of OWLDescriptions that make up the union.
static java.util.Set<org.semanticweb.owl.model.OWLClass> getInferredSubClasses(ReasonerSession session, org.semanticweb.owl.model.OWLDescription d)
          Get the asserted subclasses of a class in the given ontology.
static java.util.Set<org.semanticweb.owl.model.OWLClass> getInferredSuperClasses(ReasonerSession session, org.semanticweb.owl.model.OWLDescription d)
          Get the inferred superclasses of a class in the given ontology.
static java.util.Set<org.semanticweb.owl.model.OWLClass> getReferencedClasses(ReasonerSession session, org.semanticweb.owl.model.OWLDescription query)
          Works out which OWLClasses are referred to by the incoming query description.
static java.util.Set<org.semanticweb.owl.model.OWLProperty> getReferencedProperties(ReasonerSession session, org.semanticweb.owl.model.OWLDescription query)
          Works out which OWLProperties are referred to by the incoming query.
static java.util.Set<org.semanticweb.owl.model.OWLClass> getRelevantClasses(ReasonerSession session, org.semanticweb.owl.model.OWLOntology ontology, org.semanticweb.owl.model.OWLDescription query)
          Works out which OWL (named, non-anonymous) classes in the supplied ontology intersect with the query OWL description.
static boolean isInteresting(ReasonerSession session, org.semanticweb.owl.model.OWLOntology ontology, org.semanticweb.owl.model.OWLRestriction t_r, org.semanticweb.owl.model.OWLRestriction q_r)
          Discover whether a query class restriction is "interesting" with respect to the target restriction.
static java.util.Set<org.semanticweb.owl.model.OWLRestriction> keep(ReasonerSession session, org.semanticweb.owl.model.OWLOntology ontology, org.semanticweb.owl.model.OWLDescription owlDescription)
          Retains any restrictions that are relevant for a given OWL class.
static java.util.Set<org.semanticweb.owl.model.OWLRestriction> keep(ReasonerSession session, org.semanticweb.owl.model.OWLOntology ontology, org.semanticweb.owl.model.OWLDescription owlDescription, org.semanticweb.owl.model.OWLProperty owlProperty)
          Retains any restrictions on the given owlClass which are pertinent to the given owlProperty.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OWLUtils

public OWLUtils()
Method Detail

deconstruct

public static java.util.Set<org.semanticweb.owl.model.OWLDescription> deconstruct(org.semanticweb.owl.model.OWLDescription owlDescription)
If the OWLDescription is an OWLObjectUnionOf, it is broken down into the set of OWLDescriptions that make up the union. Essentially, this is a convenience method that makes discovering the superclasses of a union easier.

Parameters:
owlDescription - the OWLDescription to break down, if possible
Returns:
the set of owl descriptions making up this union, or the owlDescription identity

getRelevantClasses

public static java.util.Set<org.semanticweb.owl.model.OWLClass> getRelevantClasses(ReasonerSession session,
                                                                                   org.semanticweb.owl.model.OWLOntology ontology,
                                                                                   org.semanticweb.owl.model.OWLDescription query)
                                                                            throws OWLTransformationException
Works out which OWL (named, non-anonymous) classes in the supplied ontology intersect with the query OWL description.

Parameters:
session - the ReasonerSession to use to evaluate the result
ontology - the ontology to inspect
query - the query class
Returns:
a set of relevant classes
Throws:
OWLTransformationException - is there is a problem inspecting the owl

getReferencedClasses

public static java.util.Set<org.semanticweb.owl.model.OWLClass> getReferencedClasses(ReasonerSession session,
                                                                                     org.semanticweb.owl.model.OWLDescription query)
                                                                              throws OWLTransformationException
Works out which OWLClasses are referred to by the incoming query description. Whereas getRelevantClasses(ReasonerSession, org.semanticweb.owl.model.OWLOntology, org.semanticweb.owl.model.OWLDescription) returns the classes that directly intersect, this method actually collects all the classes which are alluded to by a description. For example, for the description "Foo (has_bar Bar)", getRelevantClasses() would return "Foo". This method returns {Foo, Bar}.

Parameters:
session - the ReasonerSession to use to evaluate the result
query - the query
Returns:
the referenced classes
Throws:
OWLTransformationException - if a problem occurs

getReferencedProperties

public static java.util.Set<org.semanticweb.owl.model.OWLProperty> getReferencedProperties(ReasonerSession session,
                                                                                           org.semanticweb.owl.model.OWLDescription query)
                                                                                    throws OWLTransformationException
Works out which OWLProperties are referred to by the incoming query. This method actually collects all the properties which are alluded to by a description. For example, for the description "Foo (has_bar Bar)", getReferencedProperties() would return "has_bar".

Parameters:
session - the ReasonerSession to use to evaluate the result
query - the query
Returns:
the referenced properties
Throws:
OWLTransformationException - if a problem occurs

keep

public static java.util.Set<org.semanticweb.owl.model.OWLRestriction> keep(ReasonerSession session,
                                                                           org.semanticweb.owl.model.OWLOntology ontology,
                                                                           org.semanticweb.owl.model.OWLDescription owlDescription)
                                                                    throws OWLTransformationException
Retains any restrictions that are relevant for a given OWL class. A set of restrictions is returned that contains every restriction statement about this owl class or any of its supertypes.

It is appropriate to call this method on any quey OWL class which may have some extra restrictions present, compared to a declared OWL class in the ontology.

The set of restrictions is derived by inspecting the superclasses of the given class, then looking for any superclasses which are an OWLRestriction. There is no check as to whether the class is satisfiable at this point. For example, a restriction may be kept where the restriction is on a property whose domain is not included by the class (which would create an empty set).

The keep() method allows us to build up a valid set of restrictions on a queriable class type, which can then be used to derive some filters to perform a query.

Parameters:
session - the ReasonerSession to use to evaluate the result
ontology - the OWLOntology being queried
owlDescription - the OWLClass being "broken down"
Returns:
a map of OWLClass to a set of restrictions on this class
Throws:
OWLTransformationException - is there is a problem with deriving the query classes superclasses

keep

public static java.util.Set<org.semanticweb.owl.model.OWLRestriction> keep(ReasonerSession session,
                                                                           org.semanticweb.owl.model.OWLOntology ontology,
                                                                           org.semanticweb.owl.model.OWLDescription owlDescription,
                                                                           org.semanticweb.owl.model.OWLProperty owlProperty)
                                                                    throws OWLTransformationException
Retains any restrictions on the given owlClass which are pertinent to the given owlProperty. Any restrictions which restrict the given property are retained, whilst all others are discarded.

Parameters:
session - the ReasonerSession to use to evaluate the result
ontology - the OWLOntology being queried
owlDescription - the OWLDescription that makes up the query
owlProperty - the property being inspected for @return a map of OWLClass to a set of restrictions on this class
Returns:
The set iof OWLRestrictions that may be pertinent to this query.
Throws:
OWLTransformationException - is there is a problem with deriving the query classes superclasses

isInteresting

public static boolean isInteresting(ReasonerSession session,
                                    org.semanticweb.owl.model.OWLOntology ontology,
                                    org.semanticweb.owl.model.OWLRestriction t_r,
                                    org.semanticweb.owl.model.OWLRestriction q_r)
                             throws OWLTransformationException
Discover whether a query class restriction is "interesting" with respect to the target restriction. A restriction is deemed to be interesting if the query restriction tells us something more specific than the target restriction. For example, with regard to the property "hasFoo", if a target class, T, has a restriction (t_r) = {T some hasFoo} while our query class, Q, has a restriction (q_r) = {Q hasFoo "value"} then q_f is "interesting".

More formally, we can say that if intersection(t_r, not(q_r)) is unsatisfiable or nothing, then we are not interested in q_r. If this concept is satisfiable, then we are interested in q_r.

Parameters:
session - the ReasonerSession to use to evaluate the result
ontology - the ontology being inspected
t_r - the table class restriction
q_r - the query class restriction
Returns:
true is q_r is interesting, false otherwise
Throws:
OWLTransformationException - if there is a problem reasoning over the ontology

getInferredSuperClasses

public static java.util.Set<org.semanticweb.owl.model.OWLClass> getInferredSuperClasses(ReasonerSession session,
                                                                                        org.semanticweb.owl.model.OWLDescription d)
                                                                                 throws OWLTransformationException
Get the inferred superclasses of a class in the given ontology. Takes an OWLReasoner which should be preloaded with the current ontology to reason over.

Parameters:
session - the ReasonerSession to use to evaluate these superclasses
d - the description to check
Returns:
the superclasses of c
Throws:
OWLTransformationException - if there is a problem getting the superclasses

getInferredSubClasses

public static java.util.Set<org.semanticweb.owl.model.OWLClass> getInferredSubClasses(ReasonerSession session,
                                                                                      org.semanticweb.owl.model.OWLDescription d)
                                                                               throws OWLTransformationException
Get the asserted subclasses of a class in the given ontology. Takes an OWLReasoner which should be preloaded with the current ontology to reason over.

Parameters:
session - the ReasonerSession to use to evaluate these subclasses
d - the class to check
Returns:
the subclasses of d
Throws:
OWLTransformationException - if there is a problem getting the subclasses


Copyright © 2010. All Rights Reserved.