|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjcolibri.test.test5.Test5
public class Test5
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()); ArrayListWith 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:subOntologies = new ArrayList (); ob.loadOntology(mainOnto, subOntologies, false); ...
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/.
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 |
---|
public Test5()
Method Detail |
---|
public void configure() throws ExecutionException
StandardCBRApplication
configure
in interface StandardCBRApplication
ExecutionException
public CBRCaseBase preCycle() throws ExecutionException
StandardCBRApplication
preCycle
in interface StandardCBRApplication
ExecutionException
public void cycle(CBRQuery query) throws ExecutionException
StandardCBRApplication
cycle
in interface StandardCBRApplication
ExecutionException
public void postCycle() throws ExecutionException
StandardCBRApplication
postCycle
in interface StandardCBRApplication
ExecutionException
public static void main(java.lang.String[] args)
args
-
|
GAIA - Group for Artificial Intelligence Applications http://gaia.fdi.ucm.es |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |