diff --git a/html/tutorial2/MyApp.java b/html/tutorial2/MyApp.java index 1862ba6f24fd2ca85fb1757a3b30b20052e49f5c..9c797d79c19c1f3e56e693b688394293326993e6 100644 --- a/html/tutorial2/MyApp.java +++ b/html/tutorial2/MyApp.java @@ -308,11 +308,13 @@ public class MyApp { // get the instances of a class OWLClass estud = manager.getOWLDataFactory().getOWLClass( URI.create( "http://alignapi.gforge.inria.fr/tutorial2/ontology1.owl#Estudiante" ) ); + OWLClass person = manager.getOWLDataFactory().getOWLClass( URI.create( "http://alignapi.gforge.inria.fr/tutorial2/ontology2.owl#Person" ) ); + OWLClass student = manager.getOWLDataFactory().getOWLClass( URI.create( "http://alignapi.gforge.inria.fr/tutorial2/ontology2.owl#Student" ) ); Set instances = reasoner.getIndividuals( estud, false ); System.err.println("Pellet(Merged): There are "+instances.size()+" students "+estud.getURI()); - testSubClass( manager, reasoner, estud, manager.getOWLDataFactory().getOWLClass( URI.create( "http://alignapi.gforge.inria.fr/tutorial2/ontology2.owl#Person" ) ) ); - testSubClass( manager, reasoner, estud, manager.getOWLDataFactory().getOWLClass( URI.create( "http://alignapi.gforge.inria.fr/tutorial2/ontology2.owl#Student" ) ) ); + testPelletSubClass( manager, reasoner, estud, person ); + testPelletSubClass( manager, reasoner, estud, student ); // Variant 2: reasoning with distributed semantics (IDDL) // test consistency of aligned ontologies @@ -320,23 +322,16 @@ public class MyApp { dreasoner.addOntology( uri1 ); dreasoner.addOntology( uri2 ); dreasoner.addAlignment( al ); - // What to do if not consistent? - System.err.println( al ); if ( dreasoner.isConsistent() ) { - System.err.println( "IDDL: the alignment network is consistent"); - Alignment al2 = new ObjectAlignment(); - try { - al2.init( uri1, uri2 ); - // add the cell - al2.addAlignCell( estud, manager.getOWLDataFactory().getOWLClass( URI.create( "http://alignapi.gforge.inria.fr/tutorial2/ontology2.owl#Student" ) ), "=", 1. ); - } catch (AlignmentException ae) { ae.printStackTrace(); } - dreasoner.isEntailed( al2 ); + System.out.println( "IDDL: the alignment network is consistent"); + testIDDLSubClass( dreasoner, uri1, uri2, estud, person ); + testIDDLSubClass( dreasoner, uri1, uri2, estud, student ); } else { - System.err.println( "IDDL: the alignment network is inconsistent"); + System.out.println( "IDDL: the alignment network is inconsistent"); } } - public void testSubClass( OWLOntologyManager manager, Reasoner reasoner, OWLDescription d1, OWLDescription d2 ) { + public void testPelletSubClass( OWLOntologyManager manager, Reasoner reasoner, OWLDescription d1, OWLDescription d2 ) { OWLAxiom axiom = manager.getOWLDataFactory().getOWLSubClassAxiom( d1, d2 ); boolean isit = reasoner.isEntailed( axiom ); if ( isit ) { @@ -346,6 +341,20 @@ public class MyApp { } } + public void testIDDLSubClass( IDDLReasoner dreasoner, URI onto1, URI onto2, OWLDescription d1, OWLDescription d2 ) { + Alignment al2 = new ObjectAlignment(); + try { + al2.init( onto1, onto2 ); + // add the cell + al2.addAlignCell( d1, d2, "<", 1. ); + } catch (AlignmentException ae) { ae.printStackTrace(); } + if ( dreasoner.isEntailed( al2 ) ) { + System.out.println( "IDDL: "+d1+" <= "+d2+" is entailed" ); + } else { + System.out.println( "IDDL: "+d1+" <= "+d2+" is not entailed" ); + } + } + public String getFromURLString( String u, boolean print ){ URL url = null; String result = "<?xml version='1.0'?>"; diff --git a/html/tutorial2/index.html b/html/tutorial2/index.html index 1b155b03a37c068dcae173e2a699bd652984915a..943f3a69a697aaa8e424199d7626f21d3394f0a3 100644 --- a/html/tutorial2/index.html +++ b/html/tutorial2/index.html @@ -270,7 +270,8 @@ ontologies instead of the merged one. <div class="button"> <input type="button" onclick="show('qu7')" value="Show solution 1"/> <input type="button" onclick="show('qu8')" value="Show solution 2"/> - <input type="button" onclick="hide('qu7');hide('qu8');" value="Hide solutions"/> + <input type="button" onclick="show('qu9')" value="Show solution 3"/> + <input type="button" onclick="hide('qu7');hide('qu8');hide('qu9');" value="Hide solutions"/> </div> <div class="explain" id="qu7"> <p>Prepare the system:</p> @@ -322,15 +323,49 @@ ontologies instead of the merged one. <p>Get the instances of "Estudiantes":</p> <pre> OWLClass estud = manager.getOWLDataFactory().getOWLClass( URI.create( "http://alignapi.gforge.inria.fr/tutorial2/ontology1.owl#Estudiante" ) ); + OWLClass person = manager.getOWLDataFactory().getOWLClass( URI.create( "http://alignapi.gforge.inria.fr/tutorial2/ontology2.owl#Person" ) ); + OWLClass student = manager.getOWLDataFactory().getOWLClass( URI.create( "http://alignapi.gforge.inria.fr/tutorial2/ontology2.owl#Student" ) ); Set instances = reasoner.getIndividuals( estud, false ); System.err.println("Pellet(Merged): There are "+instances.size()+" students "+estud.getURI()); </pre> <p>Some subsumption tests:</p> <pre> - testSubClass( manager, reasoner, estud, manager.getOWLDataFactory().getOWLClass( URI.create( "http://alignapi.gforge.inria.fr/tutorial2/ontology2.owl#Person" ) ) ); - testSubClass( manager, reasoner, estud, manager.getOWLDataFactory().getOWLClass( URI.create( "http://alignapi.gforge.inria.fr/tutorial2/ontology2.owl#Student" ) ) ); + testSubClass( manager, reasoner, estud, person ); + testSubClass( manager, reasoner, estud, student ); </pre> </div> +<div class="explain" id="qu9"> +<p>Load the two ontologies and the alignment in the IDDL reasoner:</p> +<pre> + IDDLReasoner dreasoner = new IDDLReasoner( Semantics.DL ); + dreasoner.addOntology( uri1 ); + dreasoner.addOntology( uri2 ); + dreasoner.addAlignment( al ); +</pre> +<p>Test consistency and check if a particular correspondence is a consequence:</p> +<pre> + if ( dreasoner.isConsistent() ) { + System.out.println( "IDDL: the alignment network is consistent"); + testIDDLSubClass( dreasoner, uri1, uri2, estud, person ); + testIDDLSubClass( dreasoner, uri1, uri2, estud, student ); + } else { + System.out.println( "IDDL: the alignment network is inconsistent"); + } +</pre> +</div> + +The results for these execution are (for Pellet): +<pre> +Pellet(Merged): There are 47 students http://alignapi.gforge.inria.fr/tutorial2/ontology1.owl#Estudiante +Pellet(Merged): Estudiante is not necessarily subclass of Person +Pellet(Merged): Estudiante is subclass of Student +</pre> +and for IDDL: +<pre> +IDDL: the alignment network is consistent +IDDL: Estudiante <= Person is not entailed +IDDL: Estudiante <= Student is entailed +</pre> <h2>Full solution</h2>