kaos.ontology.repository
Class OntologyRepository

java.lang.Object
  extended by kaos.ontology.repository.OntologyRepository

public class OntologyRepository
extends java.lang.Object

This class conatins the JPT ontology repository and provids method to load new ontologies, manage ontologies and query the ontology knowledge base.


Field Summary
static java.lang.String maxDepthProperty
           
 
Constructor Summary
OntologyRepository()
           
OntologyRepository(boolean loadDefaultOntologies)
           
 
Method Summary
 void addFilteredNamespace(java.lang.String namespace)
          This method add a nemaspace to the set of urls depicting ontology namespaces concept of which are filtered out when returned by methods of this repository.
 java.util.Set askQuery(java.lang.String variableName, java.lang.String multiplyVariablesQuery)
          Get values of the selected variable satisfing the KIF query with possibly many variable.
 java.util.Set computeSetsIntersection(java.util.Set set1, java.util.Set set2)
          Computes intersection of two sets.
 java.lang.String convertJTPFormatToString(java.lang.String convertedString)
           
 java.lang.String convertStatementToJTPFormat(java.lang.String convertedStatement)
           
 java.lang.String convertStringToJTPFormat(java.lang.String convertedString)
           
 boolean filterConcept(java.lang.String inputConcept)
          This method filter out the concept if its namespace is in the filtered namespaces set.
 java.util.Set filterConcepts(java.util.Set inputConcepts)
          This method filter out concepts which namespaces are in the filtered namespaces set.
 java.util.Set getAllNamespaces()
          This method returns a set of urls depicting ontologies loaded into the JTP as well namespaces used internally by KAoS.
 java.util.Set getClassesDefInNamespace(java.lang.String namespaceName)
          Get set of classes defined in the given namespace.
 java.util.Set getFilteredNamespaces()
          This method returns a set of urls depicting ontology namespaces concept of which are filtered out when returned by methods of this repository.
 java.util.Set getInstancesDefInNamespace(java.lang.String namespaceName)
          Get set of instances defined in the given namespace.
 java.util.Set getInstancesOf(java.lang.String conceptName)
          Get set of instances of the given concept; if the concept is an instance itself the set contains just this instance.
 java.util.Set getListOfLoadedOntologies()
          This method returns a set of urls depicting ontologies loaded into the JTP.
 java.lang.String getLocalNameFromJTPString(java.lang.String jtpString)
           
 java.util.Set getNamspacesImportedByNamespace(java.lang.String namespaceName)
          Get set of namspaces imported by the given namespace.
 java.util.Set getOntologyDefinitionForConcept(java.lang.String conceptName)
          Get mapping to the urls of ontology concept for the given concept name.
 OntologyLoader getOntologyLoader()
          Get an ontology loader
 java.util.Vector getPropertiesApplicableTo(java.lang.String className)
          Get properties applicable to the given class
 java.util.Set getPropertiesDefInNamespace(java.lang.String namespaceName)
          Get set of properties defined in the given namespace.
 java.lang.String getRangeOnPropertyForClass(java.lang.String className, java.lang.String propertyName)
          Get the name of the class defining the range of the specified property for the given class.
 java.util.Set getResourcesWithValueForProperty(java.lang.String property, java.lang.String value)
          Get values of the variable satisfing the KIF query: (property ?subject value).
 java.util.Set getSubClassesOf(java.lang.String className)
          Get set of subclasses of the given class.
 java.util.Set getSubPropertiesOf(java.lang.String propertyName)
          Get set of subproperties of the given property.
 java.util.Set getSuperClassesOf(java.lang.String className)
          Get set of superclasses of the given class.
 java.util.Set getSuperPropertiesOf(java.lang.String propertyName)
          Get set of superproperties of the given property.
 java.util.Set getUltimateOntologyTypesOfIndividual(java.lang.String individualName)
          Finds the ultimate Ontology type of the provided individual, from the ontologies explicitly loaded into JTP context
 javax.swing.undo.UndoManager getUndoManager()
          Get the undo manager for reasoning inference.
 java.lang.String getUniqueValueForProperty(java.lang.String property, java.lang.String subject)
          Get a single value of the variable satisfing the KIF query: (property subject ?val).
 java.util.Map getValuesForMultiplyVariablesQuery(java.lang.String multiplyVariablesQuery)
          Get values of the variables satisfing the KIF query with possibly many variable.
 java.util.Set getValuesForProperty(java.lang.String property, java.lang.String subject)
          Get values of the variable satisfing the KIF query: (property subject ?val).
 void loadKB(java.net.URL _url)
          Stores the assertion as well as its forward-chained information.
 java.util.Set loadOntology(java.lang.String myURL, boolean recursiveLoad)
          Loads ontology from the provided url.
protected  void printDebugString(java.lang.String msg, int loggerDisplayLevel)
          A utility method to print a String.
 void removeFilteredNamespace(java.lang.String namespace)
          This method remove a nemaspace from the set of urls depicting ontology namespaces concept of which are filtered out when returned by methods of this repository.
 void resetOntologyLoader(java.lang.String ontlogyListFileName)
          Resets ontology loader list of loaded namespaces
 void setNotificationRef(KAoSDirectoryService _myKAoSDirectoryService)
          Sets the reference to the notification class.
static void setReasoningDepth(int depth)
          Sets the depth of the reasoning
 int tellKifString(java.lang.String assertion)
          Stores the assertion as well as its forward-chained information.
 int tellOwlString(java.lang.String assertion)
          Stores the assertion as well as its forward-chained information.
 boolean testIfIntersectionsDisjoint(java.util.Vector set1, java.util.Vector set2)
          Test if the two intersections of concepts are disjoint.
 boolean testIfSetsDifferenceEmpty(java.util.Vector set1, java.util.Vector set2)
          Test if the difference of two sets of concepts is empty (set1 - set2).
 boolean testTrue(java.lang.String statement)
          Test if the KIF statemant is true according to the ontologies in the ontology repository.
 void untellKifString(java.lang.String assertion)
          Deletes the assertion as well as its forward-chained information.
 void untellOwlString(java.lang.String assertion)
          Deletes the assertion as well as its forward-chained information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxDepthProperty

public static final java.lang.String maxDepthProperty
See Also:
Constant Field Values
Constructor Detail

OntologyRepository

public OntologyRepository()

OntologyRepository

public OntologyRepository(boolean loadDefaultOntologies)
Method Detail

setReasoningDepth

public static void setReasoningDepth(int depth)
Sets the depth of the reasoning


setNotificationRef

public void setNotificationRef(KAoSDirectoryService _myKAoSDirectoryService)
Sets the reference to the notification class.


getOntologyLoader

public OntologyLoader getOntologyLoader()
Get an ontology loader


resetOntologyLoader

public void resetOntologyLoader(java.lang.String ontlogyListFileName)
Resets ontology loader list of loaded namespaces


loadKB

public void loadKB(java.net.URL _url)
            throws ReasoningException,
                   java.io.IOException
Stores the assertion as well as its forward-chained information.

Parameters:
_url - - a url to a file containg KIF-formatted string to assert
Throws:
ReasoningException
java.io.IOException

tellKifString

public int tellKifString(java.lang.String assertion)
                  throws ReasoningException
Stores the assertion as well as its forward-chained information.

Parameters:
assertion - - a KIF-formatted string to assert
Throws:
ReasoningException

untellKifString

public void untellKifString(java.lang.String assertion)
                     throws ReasoningException
Deletes the assertion as well as its forward-chained information.

Parameters:
assertion - - a KIF-formatted string to untell
Throws:
ReasoningException

tellOwlString

public int tellOwlString(java.lang.String assertion)
                  throws ReasoningException
Stores the assertion as well as its forward-chained information.

Parameters:
assertion - - a KIF-formatted string to assert
Throws:
ReasoningException

untellOwlString

public void untellOwlString(java.lang.String assertion)
                     throws ReasoningException
Deletes the assertion as well as its forward-chained information.

Parameters:
assertion - - a OWL-formatted string to untell
Throws:
ReasoningException

getUndoManager

public javax.swing.undo.UndoManager getUndoManager()
Get the undo manager for reasoning inference.


getListOfLoadedOntologies

public java.util.Set getListOfLoadedOntologies()
This method returns a set of urls depicting ontologies loaded into the JTP.


getAllNamespaces

public java.util.Set getAllNamespaces()
This method returns a set of urls depicting ontologies loaded into the JTP as well namespaces used internally by KAoS.


getFilteredNamespaces

public java.util.Set getFilteredNamespaces()
This method returns a set of urls depicting ontology namespaces concept of which are filtered out when returned by methods of this repository.


addFilteredNamespace

public void addFilteredNamespace(java.lang.String namespace)
This method add a nemaspace to the set of urls depicting ontology namespaces concept of which are filtered out when returned by methods of this repository.

Parameters:
namespace - The name of the namespace

removeFilteredNamespace

public void removeFilteredNamespace(java.lang.String namespace)
This method remove a nemaspace from the set of urls depicting ontology namespaces concept of which are filtered out when returned by methods of this repository.

Parameters:
namespace - The name of the namespace

filterConcept

public boolean filterConcept(java.lang.String inputConcept)
This method filter out the concept if its namespace is in the filtered namespaces set.

Parameters:
inputConcept - The name of the concept
Returns:
Returns true if this concept namespace is in the set of filtered namespaces

filterConcepts

public java.util.Set filterConcepts(java.util.Set inputConcepts)
This method filter out concepts which namespaces are in the filtered namespaces set.

Parameters:
inputConcepts - The set of namespaces
Returns:
Returns set with concept which were not filtered out

loadOntology

public java.util.Set loadOntology(java.lang.String myURL,
                                  boolean recursiveLoad)
                           throws ReasoningException,
                                  java.io.IOException
Loads ontology from the provided url.

Parameters:
myURL - the url to the ontology
recursiveLoad - indicates if the imported ontologies (by the ontology depicted by myURL) should also be recursively loaded.
Returns:
Returns a set to of namespaces loaded during this step
Throws:
ReasoningException - or IOException when loading of the ontology failed.
java.io.IOException

testTrue

public boolean testTrue(java.lang.String statement)
                 throws ReasoningException
Test if the KIF statemant is true according to the ontologies in the ontology repository.

Parameters:
statement - the statement in KIF to be tested if true
Returns:
true if the statement is true and false in the opposite case
Throws:
ReasoningException - if reasoning failed.

getUniqueValueForProperty

public java.lang.String getUniqueValueForProperty(java.lang.String property,
                                                  java.lang.String subject)
                                           throws ReasoningException
Get a single value of the variable satisfing the KIF query: (property subject ?val).

Parameters:
property - the name of the property
subject - the name of the subject
Returns:
a single value for the property on this subject
Throws:
ReasoningException - if reasoning failed.

getValuesForProperty

public java.util.Set getValuesForProperty(java.lang.String property,
                                          java.lang.String subject)
                                   throws ReasoningException
Get values of the variable satisfing the KIF query: (property subject ?val).

Parameters:
property - the name of the property
subject - the name of the subject
Returns:
a set with values for the property on this subject
Throws:
ReasoningException - if reasoning failed.

getResourcesWithValueForProperty

public java.util.Set getResourcesWithValueForProperty(java.lang.String property,
                                                      java.lang.String value)
                                               throws ReasoningException
Get values of the variable satisfing the KIF query: (property ?subject value).

Parameters:
property - the name of the property
value - the value
Returns:
a set with name of subjects which has the specified value for the given property
Throws:
ReasoningException - if reasoning failed.

askQuery

public java.util.Set askQuery(java.lang.String variableName,
                              java.lang.String multiplyVariablesQuery)
                       throws ReasoningException
Get values of the selected variable satisfing the KIF query with possibly many variable.

Parameters:
variableName - the neame ofthe selected variable
multiplyVariablesQuery - the query
Returns:
a set with values satisfing the query
Throws:
ReasoningException - if reasoning failed.

getValuesForMultiplyVariablesQuery

public java.util.Map getValuesForMultiplyVariablesQuery(java.lang.String multiplyVariablesQuery)
                                                 throws ReasoningException
Get values of the variables satisfing the KIF query with possibly many variable. Please note that his method looses the association between the values.

Parameters:
multiplyVariablesQuery - the query
Returns:
a map with keys beign the name of variables and corresponding sets of values satisfing the query
Throws:
ReasoningException - if reasoning failed.

getPropertiesApplicableTo

public java.util.Vector getPropertiesApplicableTo(java.lang.String className)
                                           throws ReasoningException
Get properties applicable to the given class

Parameters:
className - the name of the class
Returns:
vector of properties names
Throws:
ReasoningException - if reasoning failed.

getRangeOnPropertyForClass

public java.lang.String getRangeOnPropertyForClass(java.lang.String className,
                                                   java.lang.String propertyName)
                                            throws ReasoningException
Get the name of the class defining the range of the specified property for the given class.

Parameters:
className - the name of the class
propertyName - the name of the property
Returns:
the name of the class defining the range
Throws:
ReasoningException - if reasoning failed.

getUltimateOntologyTypesOfIndividual

public java.util.Set getUltimateOntologyTypesOfIndividual(java.lang.String individualName)
                                                   throws UnknownConceptException
Finds the ultimate Ontology type of the provided individual, from the ontologies explicitly loaded into JTP context

Parameters:
individualName - the name of the individual
Returns:
the vector of names of the Ontology classes being the most narrow ones for the given individual
Throws:
individualName - if concept unknow or any problem with JTP approached
UnknownConceptException

getInstancesOf

public java.util.Set getInstancesOf(java.lang.String conceptName)
                             throws UnknownConceptException
Get set of instances of the given concept; if the concept is an instance itself the set contains just this instance.

Parameters:
conceptName - The name of the concept in the Jena format
Returns:
Set of instance ids in the Jena format
Throws:
UnknownConceptException - if forActor is unknow for the ontology repository

getSuperClassesOf

public java.util.Set getSuperClassesOf(java.lang.String className)
                                throws UnknownConceptException
Get set of superclasses of the given class.

Parameters:
className - The name of the class in Jena format
Returns:
Set of superclasses names in Jena format
Throws:
UnknownConceptException - if className is unknow for the ontology repository

getSubClassesOf

public java.util.Set getSubClassesOf(java.lang.String className)
                              throws UnknownConceptException
Get set of subclasses of the given class.

Parameters:
className - The name of the class in Jena format
Returns:
Set of subclasses names in Jena format
Throws:
UnknownConceptException - if className is unknow for the ontology repository

getSuperPropertiesOf

public java.util.Set getSuperPropertiesOf(java.lang.String propertyName)
                                   throws UnknownConceptException
Get set of superproperties of the given property.

Parameters:
propertyName - The name of the property in Jena format
Returns:
Set of superproperties names in Jena format
Throws:
java.lang.Exception - if propertyName is unknow for the ontology repository
UnknownConceptException

getSubPropertiesOf

public java.util.Set getSubPropertiesOf(java.lang.String propertyName)
                                 throws UnknownConceptException
Get set of subproperties of the given property.

Parameters:
propertyName - The name of the property in Jena format
Returns:
Set of subproperties names in Jena format
Throws:
java.lang.Exception - if propertyName is unknow for the ontology repository
UnknownConceptException

getClassesDefInNamespace

public java.util.Set getClassesDefInNamespace(java.lang.String namespaceName)
                                       throws UnknownNamespaceException
Get set of classes defined in the given namespace.

Parameters:
namespaceName - The name of the namespace in the Jena format
Returns:
Set of classes names in the Jena format
Throws:
UnknownNamespaceException - if namespaceName is unknow for the ontology repository

getPropertiesDefInNamespace

public java.util.Set getPropertiesDefInNamespace(java.lang.String namespaceName)
                                          throws UnknownNamespaceException
Get set of properties defined in the given namespace.

Parameters:
namespaceName - The name of the namespace in the Jena format
Returns:
Set of properties names in the Jena format
Throws:
UnknownNamespaceException - if namespaceName is unknow for the ontology repository

getInstancesDefInNamespace

public java.util.Set getInstancesDefInNamespace(java.lang.String namespaceName)
                                         throws UnknownNamespaceException
Get set of instances defined in the given namespace.

Parameters:
namespaceName - The name of the namespace in the Jena format
Returns:
Set of instances names in the Jena format
Throws:
UnknownNamespaceException - if namespaceName is unknow for the ontology repository

getNamspacesImportedByNamespace

public java.util.Set getNamspacesImportedByNamespace(java.lang.String namespaceName)
                                              throws UnknownNamespaceException
Get set of namspaces imported by the given namespace.

Parameters:
namespaceName - The name of the namespace in the Jena format
Returns:
Set of namspaces names in the Jena format
Throws:
UnknownNamespaceException - if namespaceName is unknow for the ontology repository

getOntologyDefinitionForConcept

public java.util.Set getOntologyDefinitionForConcept(java.lang.String conceptName)
Get mapping to the urls of ontology concept for the given concept name. Currently, it tries to match the concept name with the local name of the ontology definitions url.

Parameters:
conceptName - The name of the namespace in the Jena format
Returns:
Set of ontology definition url potentially matching the search concept

testIfSetsDifferenceEmpty

public boolean testIfSetsDifferenceEmpty(java.util.Vector set1,
                                         java.util.Vector set2)
                                  throws ReasoningException
Test if the difference of two sets of concepts is empty (set1 - set2).

Parameters:
set1 - the first set of concepts names (Vector)
set2 - the second set of concepts names (Vector)
Returns:
true if the statement is true and false in the opposite case
Throws:
ReasoningException - if reasoning failed.

testIfIntersectionsDisjoint

public boolean testIfIntersectionsDisjoint(java.util.Vector set1,
                                           java.util.Vector set2)
                                    throws ReasoningException
Test if the two intersections of concepts are disjoint.

Parameters:
set1 - the first set of concepts names (Vector)
set2 - the second set of concepts names (Vector)
Returns:
true if the disjoint and false in the opposite case
Throws:
ReasoningException - if reasoning failed.

computeSetsIntersection

public java.util.Set computeSetsIntersection(java.util.Set set1,
                                             java.util.Set set2)
Computes intersection of two sets.

Parameters:
set1 - the first set of concepts names
set2 - the second set of concepts names
Returns:
set being the intersection

convertStringToJTPFormat

public java.lang.String convertStringToJTPFormat(java.lang.String convertedString)

convertJTPFormatToString

public java.lang.String convertJTPFormatToString(java.lang.String convertedString)

convertStatementToJTPFormat

public java.lang.String convertStatementToJTPFormat(java.lang.String convertedStatement)

getLocalNameFromJTPString

public java.lang.String getLocalNameFromJTPString(java.lang.String jtpString)

printDebugString

protected void printDebugString(java.lang.String msg,
                                int loggerDisplayLevel)
A utility method to print a String. Add the name of the class printing the String.

Parameters:
msg - The String to be printed.