Mentions légales du service

Skip to content
Snippets Groups Projects
Commit a70651bf authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

- updated tutorial with new version of Pellet and IDDL (neutralised)

parent 42d597cc
No related branches found
No related tags found
No related merge requests found
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2009 * Copyright (C) INRIA, 2009-2010
* *
* Modifications to the initial code base are copyright of their * Modifications to the initial code base are copyright of their
* respective authors, or their employers as appropriate. Authorship * respective authors, or their employers as appropriate. Authorship
...@@ -52,17 +52,19 @@ import com.hp.hpl.jena.query.QueryExecution; ...@@ -52,17 +52,19 @@ import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QueryExecutionFactory;
// OWL API // OWL API
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntologyManager; import org.semanticweb.owlapi.model.OWLOntologyManager;
import org.semanticweb.owlapi.model.OWLOntology; import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException; import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLClass; import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLAxiom; import org.semanticweb.owlapi.model.OWLAxiom;
import org.semanticweb.owlapi.model.OWLClassExpression; import org.semanticweb.owlapi.model.OWLClassExpression;
import org.semanticweb.owlapi.model.OWLNamedIndividual;
import org.semanticweb.owlapi.apibinding.OWLManager; import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.reasoner.OWLReasoner;
// Pellet // Pellet
import com.clarkparsia.pellet.owlapiv3.PelletReasoner; import com.clarkparsia.pellet.owlapiv3.PelletReasoner;
//import org.semanticweb.owlapi.reasoner.OWLReasoner;
// IDDL // IDDL
import fr.inrialpes.exmo.iddl.IDDLReasoner; import fr.inrialpes.exmo.iddl.IDDLReasoner;
...@@ -191,12 +193,8 @@ public class MyApp { ...@@ -191,12 +193,8 @@ public class MyApp {
AlignmentParser aparser = new AlignmentParser(0); AlignmentParser aparser = new AlignmentParser(0);
Alignment alu = aparser.parseString( xmlString ); Alignment alu = aparser.parseString( xmlString );
al = ObjectAlignment.toObjectAlignment((URIAlignment)alu); al = ObjectAlignment.toObjectAlignment((URIAlignment)alu);
} catch (ParserConfigurationException pce) {
pce.printStackTrace();
} catch (SAXException saxe) { } catch (SAXException saxe) {
saxe.printStackTrace(); saxe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (AlignmentException ae) { } catch (AlignmentException ae) {
ae.printStackTrace(); ae.printStackTrace();
} }
...@@ -299,22 +297,25 @@ public class MyApp { ...@@ -299,22 +297,25 @@ public class MyApp {
// Variant 1: reasoning with merged ontologies // Variant 1: reasoning with merged ontologies
OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
Reasoner reasoner = new Reasoner( manager ); //Pellet
OWLReasoner reasoner = null;
//Does not seem to work
//System.setErr( new PrintStream( new NullStream() ) ); //System.setErr( new PrintStream( new NullStream() ) );
// Load the ontology // Load the ontology
try { try {
OWLOntology ontology = manager.loadOntology( URI.create( "file://"+tempOntoFileName ) ); OWLOntology ontology = manager.loadOntology( IRI.create( "file://"+tempOntoFileName ) );
reasoner.loadOntology( ontology ); reasoner = new PelletReasoner( ontology, org.semanticweb.owlapi.reasoner.BufferingMode.NON_BUFFERING );
} catch (OWLOntologyCreationException ooce) { ooce.printStackTrace(); } reasoner.prepareReasoner();
} catch (OWLOntologyCreationException ooce) {
ooce.printStackTrace();
}
// get the instances of a class // get the instances of a class
OWLClass estud = manager.getOWLDataFactory().getOWLClass( URI.create( "http://alignapi.gforge.inria.fr/tutorial/tutorial2/ontology1.owl#Estudiante" ) ); OWLClass estud = manager.getOWLDataFactory().getOWLClass( IRI.create( "http://alignapi.gforge.inria.fr/tutorial/tutorial2/ontology1.owl#Estudiante" ) );
OWLClass person = manager.getOWLDataFactory().getOWLClass( URI.create( "http://alignapi.gforge.inria.fr/tutorial/tutorial2/ontology2.owl#Person" ) ); OWLClass person = manager.getOWLDataFactory().getOWLClass( IRI.create( "http://alignapi.gforge.inria.fr/tutorial/tutorial2/ontology2.owl#Person" ) );
OWLClass student = manager.getOWLDataFactory().getOWLClass( URI.create( "http://alignapi.gforge.inria.fr/tutorial/tutorial2/ontology2.owl#Student" ) ); OWLClass student = manager.getOWLDataFactory().getOWLClass( IRI.create( "http://alignapi.gforge.inria.fr/tutorial/tutorial2/ontology2.owl#Student" ) );
Set instances = reasoner.getIndividuals( estud, false ); Set<OWLNamedIndividual> instances = reasoner.getInstances( estud, false ).getFlattened();
System.err.println("Pellet(Merged): There are "+instances.size()+" students "+estud.getURI()); System.err.println("Pellet(Merged): There are "+instances.size()+" students "+estud.getIRI());
testPelletSubClass( manager, reasoner, estud, person ); testPelletSubClass( manager, reasoner, estud, person );
testPelletSubClass( manager, reasoner, estud, student ); testPelletSubClass( manager, reasoner, estud, student );
...@@ -334,8 +335,8 @@ public class MyApp { ...@@ -334,8 +335,8 @@ public class MyApp {
} }
} }
public void testPelletSubClass( OWLOntologyManager manager, Reasoner reasoner, OWLDescription d1, OWLDescription d2 ) { public void testPelletSubClass( OWLOntologyManager manager, OWLReasoner reasoner, OWLClassExpression d1, OWLClassExpression d2 ) {
OWLAxiom axiom = manager.getOWLDataFactory().getOWLSubClassAxiom( d1, d2 ); OWLAxiom axiom = manager.getOWLDataFactory().getOWLSubClassOfAxiom( d1, d2 );
boolean isit = reasoner.isEntailed( axiom ); boolean isit = reasoner.isEntailed( axiom );
if ( isit ) { if ( isit ) {
System.out.println( "Pellet(Merged): "+d1+" is subclass of "+d2 ); System.out.println( "Pellet(Merged): "+d1+" is subclass of "+d2 );
...@@ -344,7 +345,7 @@ public class MyApp { ...@@ -344,7 +345,7 @@ public class MyApp {
} }
} }
public void testIDDLSubClass( IDDLReasoner dreasoner, URI onto1, URI onto2, OWLDescription d1, OWLDescription d2 ) { public void testIDDLSubClass( IDDLReasoner dreasoner, URI onto1, URI onto2, OWLClassExpression d1, OWLClassExpression d2 ) {
Alignment al2 = new ObjectAlignment(); Alignment al2 = new ObjectAlignment();
try { try {
al2.init( onto1, onto2 ); al2.init( onto1, onto2 );
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<title>Manipulating alignments in Java programs</title> <title>Exploiting alignments and reasoning</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="stylesheet" type="text/css" href="../../base.css" /> <link rel="stylesheet" type="text/css" href="../../base.css" />
<link rel="stylesheet" type="text/css" href="../../style.css" /> <link rel="stylesheet" type="text/css" href="../../style.css" />
...@@ -32,7 +32,7 @@ div.logic { ...@@ -32,7 +32,7 @@ div.logic {
</head> </head>
<body style="background-color: #FFFFFF;"> <body style="background-color: #FFFFFF;">
<h1>Manipulating alignments in Java programs: advanced tutorial on the Alignment <abbr title="Application Programming Interface">API</abbr> and server</h1> <h1>Exploiting alignments and reasoning: advanced tutorial on the Alignment <abbr title="Application Programming Interface">API</abbr> and server</h1>
<p> <p>
<dl> <dl>
...@@ -61,9 +61,10 @@ This time, the tutorial is based on Java programming and using various ...@@ -61,9 +61,10 @@ This time, the tutorial is based on Java programming and using various
related APIs. related APIs.
</p> </p>
<p> <p>
A more <a href="../tutorial1/index.html">simple tutorial</a> as well as Other tutorials are <a href="../index.html">available</a>.</p>
a small <a href="../tutorial1/server.html">server tutorial</a> are also available.</p> <p style="border-top: 2px solid #AAAAAA;"><small>This tutorial has
<p style="border-top: 2px solid #AAAAAA;"><small>This tutorial has been designed for the Alignment API version 4.0.</small></p> been designed for the Alignment API version 4.0. It is currently
incomplete due to the upgrade of Pellet to version 2.0.2 and IDDL.</small></p>
<h2>Preparation</h2> <h2>Preparation</h2>
...@@ -92,19 +93,23 @@ ontology. This is not a difficult task, the goal here is only to show ...@@ -92,19 +93,23 @@ ontology. This is not a difficult task, the goal here is only to show
how this could be achieved. how this could be achieved.
</p> </p>
<p>For that purpose, you have to develop a program in Java. This <p>For that purpose, you have to develop a program in Java.
programme can be compiled by: We first define the CLASSPATH because a lot of external software is required
<div class="fragment"> <div class="fragment">
$ javac -classpath ../../../lib/align.jar:../../../lib/procalign.jar:../../../lib/jena/jena.jar:../../../lib/jena/arq.jar:../../../lib/iddl/iddl.jar:../../../lib/pellet/pellet.jar MyApp.java $ setenv CLASSPATH ../../../lib/align.jar:../../../lib/procalign.jar:../../../lib/jena/jena.jar:../../../lib/jena/arq.jar:../../../lib/iddl/iddl.jar:../../../lib/pellet/pellet-core.jar:../../../lib/pellet/pellet-owlapiv3.jar:../../../lib/pellet/pellet-rules.jar:../../../lib/pellet/pellet-datatypes.jar:../../../lib/pellet/aterm-java-1.6.jar:../../../lib/pellet/pellet-query.jar:../../../lib/ontosim/ontosim.jar:../../../lib/pellet/pellet-el.jar:../../../lib/log4j/commons-logging.jar:../../../lib/log4j/log4j.jar:../../../lib/xerces/xercesImpl.jar:../../../lib/jena/iri.jar:../../../lib/jena/icu4j_3_4.jar:../../../lib/jena/concurrent.jar:../../../lib/xsdlib/relaxngDatatype.jar:../../../lib/xsdlib/xsdlib.jar:results
</div> </div>
and run by: The list of jars is long, but at least it is explicit and you
should be safe with this one.
This programme can be compiled by:
<div class="fragment"> <div class="fragment">
$ java -classpath .:../../../lib/align.jar:../../../lib/procalign.jar:../../../lib/jena/jena.jar:../../../lib/jena/arq.jar:../../../lib/iddl/iddl.jar:../../../lib/pellet/pellet.jar:../../../lib/ontosim/ontosim.jar:../../../lib/log4j/commons-logging.jar:../../../lib/log4j/log4j.jar:../../../lib/xerces/xercesImpl.jar:../../../lib/jena/iri.jar:../../../lib/jena/icu4j_3_4.jar:../../../lib/jena/concurrent.jar:../../../lib/pellet/relaxngDatatype.jar:../../../lib/pellet/xsdlib.jar MyApp $ javac -d results MyApp.java
</div> </div>
The long list of jar is boring, but at least it is explicit and you
should be safe with this one.
<p>
</p> </p>
<p>This
programme can be run by:
<div class="fragment">
$ java MyApp
</div></p>
You can start with the empty template <a href="Skeleton.java">Skeleton.java</a>. You can start with the empty template <a href="Skeleton.java">Skeleton.java</a>.
</p> </p>
...@@ -225,7 +230,7 @@ This can be done with the alignment API support. ...@@ -225,7 +230,7 @@ This can be done with the alignment API support.
<div class="button"> <div class="button">
<input type="button" onclick="show('qu5')" value="Show solution 1"/> <input type="button" onclick="show('qu5')" value="Show solution 1"/>
<input type="button" onclick="show('qu6')" value="Show solution 2"/> <!--input type="button" onclick="show('qu6')" value="Show solution 2"/-->
<input type="button" onclick="hide('qu5');hide('qu6');" value="Hide solutions"/> <input type="button" onclick="hide('qu5');hide('qu6');" value="Hide solutions"/>
</div> </div>
<div class="explain" id="qu5"> <div class="explain" id="qu5">
...@@ -267,8 +272,8 @@ ontologies instead of the merged one. ...@@ -267,8 +272,8 @@ ontologies instead of the merged one.
</p> </p>
<div class="button"> <div class="button">
<input type="button" onclick="show('qu7')" value="Show solution 1"/> <input type="button" onclick="show('qu7')" value="Show solution 1"/>
<input type="button" onclick="show('qu8')" value="Show solution 2"/> <!--input type="button" onclick="show('qu8')" value="Show solution 2"/>
<input type="button" onclick="show('qu9')" value="Show solution 3"/> <input type="button" onclick="show('qu9')" value="Show solution 3"/-->
<input type="button" onclick="hide('qu7');hide('qu8');hide('qu9');" value="Hide solutions"/> <input type="button" onclick="hide('qu7');hide('qu8');hide('qu9');" value="Hide solutions"/>
</div> </div>
<div class="explain" id="qu7"> <div class="explain" id="qu7">
...@@ -393,10 +398,10 @@ IDDL: Estudiante <= Person is not entailed ...@@ -393,10 +398,10 @@ IDDL: Estudiante <= Person is not entailed
IDDL: Estudiante <= Student is entailed IDDL: Estudiante <= Student is entailed
</pre> </pre>
<h2>Full solution</h2> <!--h2>Full solution</h2>
<p>Do you want to see a possible solution?</p> <p>Do you want to see a possible solution?</p>
<p>A full working solution is <a href="MyApp.java">MyApp.java</a>.</p> <p>A full working solution is <a href="MyApp.java">MyApp.java</a>.</p-->
<hr /> <hr />
<small> <small>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment