jcolibri.test.test5
Class Test5

java.lang.Object
  extended by jcolibri.test.test5.Test5
All Implemented Interfaces:
StandardCBRApplication

public class Test5
extends java.lang.Object
implements StandardCBRApplication

This example shows how to map an attribute to an ontology and compute an ontology-based similarity function in the KNN. jCOLIBRI uses the OntoBridge library to do the mapping an manage the ontologies.
The mapping consists on reading the values of an attribute from the persistence layer and link them with instances of an ontology. In this example we are going to map the values of the Season column in the travelext database with the instances of the concept "SEASON" of the ontology vacation.owl. This ontology contains information about travels and vacations. The SEASON concept organizes the information as shown in this figure:

To map this concept with the attributes in the database we have to change the type of the season attribute in the description to Instance. This type automatically connects with the ontology and links its value to the proper instance. To configure the mapping we have to modify the travelDescription.hbm.xml file pointing out that we are using a Instance:

  ...
        <property name="Season" column="Season">
                <type name="jcolibri.connector.databaseutils.GenericUserType">
                        <param name="className">jcolibri.datatypes.Instance</param>
                </type>
        </property>
  ...
 
And finally, in the configure() method of our application we have to setup OntoBridge with the ontology:
      ...
                OntoBridge ob = jcolibri.util.OntoBridgeSingleton.getOntoBridge();
                ob.initWithPelletReasoner();
                OntologyDocument mainOnto = new OntologyDocument("http://gaia.fdi.ucm.es/ontologies/vacation.owl", 
                FileIO.findFile("jcolibri/test/test5/vacation.owl").toURI().toString());
                ArrayList subOntologies = new ArrayList();          
                ob.loadOntology(mainOnto, subOntologies, false);
      ...
 
With these changes the ontology is loaded and the values of Season are mapped to its instances. Now, we can compute similarity functions that use information from the ontology. Here we are using the OntCosine() method:
      simConfig.addMapping(new Attribute("Season", TravelDescription.class), new OntCosine());
 
For more information about OntoBridge read its documentation or visit the web page: http://gaia.fdi.ucm.es/projects/ontobridge/.

Version:
1.0
Author:
Juan A. Recio-Garcia
See Also:
TravelDescription, OntCosine

Constructor Summary
Test5()
           
 
Method Summary
 void configure()
          Configures the application: case base, connectors, etc.
 void cycle(CBRQuery query)
          Executes a CBR cycle with the given query.
static void main(java.lang.String[] args)
           
 void postCycle()
          Runs the code to shutdown the application.
 CBRCaseBase preCycle()
          Runs the precyle where typically cases are read and organized into a case base.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Test5

public Test5()
Method Detail

configure

public void configure()
               throws ExecutionException
Description copied from interface: StandardCBRApplication
Configures the application: case base, connectors, etc.

Specified by:
configure in interface StandardCBRApplication
Throws:
ExecutionException

preCycle

public CBRCaseBase preCycle()
                     throws ExecutionException
Description copied from interface: StandardCBRApplication
Runs the precyle where typically cases are read and organized into a case base.

Specified by:
preCycle in interface StandardCBRApplication
Returns:
The created case base with the cases in the storage.
Throws:
ExecutionException

cycle

public void cycle(CBRQuery query)
           throws ExecutionException
Description copied from interface: StandardCBRApplication
Executes a CBR cycle with the given query.

Specified by:
cycle in interface StandardCBRApplication
Throws:
ExecutionException

postCycle

public void postCycle()
               throws ExecutionException
Description copied from interface: StandardCBRApplication
Runs the code to shutdown the application. Typically it closes the connector.

Specified by:
postCycle in interface StandardCBRApplication
Throws:
ExecutionException

main

public static void main(java.lang.String[] args)
Parameters:
args -

GAIA - Group for Artificial Intelligence Applications
http://gaia.fdi.ucm.es