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$
*
* Copyright (C) INRIA, 2009
* Copyright (C) INRIA, 2009-2010
*
* Modifications to the initial code base are copyright of their
* respective authors, or their employers as appropriate. Authorship
......@@ -52,17 +52,19 @@ import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
// OWL API
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLAxiom;
import org.semanticweb.owlapi.model.OWLClassExpression;
import org.semanticweb.owlapi.model.OWLNamedIndividual;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.reasoner.OWLReasoner;
// Pellet
import com.clarkparsia.pellet.owlapiv3.PelletReasoner;
//import org.semanticweb.owlapi.reasoner.OWLReasoner;
// IDDL
import fr.inrialpes.exmo.iddl.IDDLReasoner;
......@@ -191,12 +193,8 @@ public class MyApp {
AlignmentParser aparser = new AlignmentParser(0);
Alignment alu = aparser.parseString( xmlString );
al = ObjectAlignment.toObjectAlignment((URIAlignment)alu);
} catch (ParserConfigurationException pce) {
pce.printStackTrace();
} catch (SAXException saxe) {
saxe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (AlignmentException ae) {
ae.printStackTrace();
}
......@@ -299,22 +297,25 @@ public class MyApp {
// Variant 1: reasoning with merged ontologies
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
Reasoner reasoner = new Reasoner( manager );
//Pellet
OWLReasoner reasoner = null;
//Does not seem to work
//System.setErr( new PrintStream( new NullStream() ) );
// Load the ontology
try {
OWLOntology ontology = manager.loadOntology( URI.create( "file://"+tempOntoFileName ) );
reasoner.loadOntology( ontology );
} catch (OWLOntologyCreationException ooce) { ooce.printStackTrace(); }
OWLOntology ontology = manager.loadOntology( IRI.create( "file://"+tempOntoFileName ) );
reasoner = new PelletReasoner( ontology, org.semanticweb.owlapi.reasoner.BufferingMode.NON_BUFFERING );
reasoner.prepareReasoner();
} catch (OWLOntologyCreationException ooce) {
ooce.printStackTrace();
}
// get the instances of a class
OWLClass estud = manager.getOWLDataFactory().getOWLClass( URI.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 student = manager.getOWLDataFactory().getOWLClass( URI.create( "http://alignapi.gforge.inria.fr/tutorial/tutorial2/ontology2.owl#Student" ) );
Set instances = reasoner.getIndividuals( estud, false );
System.err.println("Pellet(Merged): There are "+instances.size()+" students "+estud.getURI());
OWLClass estud = manager.getOWLDataFactory().getOWLClass( IRI.create( "http://alignapi.gforge.inria.fr/tutorial/tutorial2/ontology1.owl#Estudiante" ) );
OWLClass person = manager.getOWLDataFactory().getOWLClass( IRI.create( "http://alignapi.gforge.inria.fr/tutorial/tutorial2/ontology2.owl#Person" ) );
OWLClass student = manager.getOWLDataFactory().getOWLClass( IRI.create( "http://alignapi.gforge.inria.fr/tutorial/tutorial2/ontology2.owl#Student" ) );
Set<OWLNamedIndividual> instances = reasoner.getInstances( estud, false ).getFlattened();
System.err.println("Pellet(Merged): There are "+instances.size()+" students "+estud.getIRI());
testPelletSubClass( manager, reasoner, estud, person );
testPelletSubClass( manager, reasoner, estud, student );
......@@ -334,8 +335,8 @@ public class MyApp {
}
}
public void testPelletSubClass( OWLOntologyManager manager, Reasoner reasoner, OWLDescription d1, OWLDescription d2 ) {
OWLAxiom axiom = manager.getOWLDataFactory().getOWLSubClassAxiom( d1, d2 );
public void testPelletSubClass( OWLOntologyManager manager, OWLReasoner reasoner, OWLClassExpression d1, OWLClassExpression d2 ) {
OWLAxiom axiom = manager.getOWLDataFactory().getOWLSubClassOfAxiom( d1, d2 );
boolean isit = reasoner.isEntailed( axiom );
if ( isit ) {
System.out.println( "Pellet(Merged): "+d1+" is subclass of "+d2 );
......@@ -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();
try {
al2.init( onto1, onto2 );
......
......@@ -3,7 +3,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<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" />
<link rel="stylesheet" type="text/css" href="../../base.css" />
<link rel="stylesheet" type="text/css" href="../../style.css" />
......@@ -32,7 +32,7 @@ div.logic {
</head>
<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>
<dl>
......@@ -61,9 +61,10 @@ This time, the tutorial is based on Java programming and using various
related APIs.
</p>
<p>
A more <a href="../tutorial1/index.html">simple tutorial</a> as well as
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 been designed for the Alignment API version 4.0.</small></p>
Other tutorials are <a href="../index.html">available</a>.</p>
<p style="border-top: 2px solid #AAAAAA;"><small>This tutorial has
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>
......@@ -92,19 +93,23 @@ ontology. This is not a difficult task, the goal here is only to show
how this could be achieved.
</p>
<p>For that purpose, you have to develop a program in Java. This
programme can be compiled by:
<p>For that purpose, you have to develop a program in Java.
We first define the CLASSPATH because a lot of external software is required
<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>
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">
$ 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>
The long list of jar is boring, but at least it is explicit and you
should be safe with this one.
<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>.
</p>
......@@ -225,7 +230,7 @@ This can be done with the alignment API support.
<div class="button">
<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"/>
</div>
<div class="explain" id="qu5">
......@@ -267,8 +272,8 @@ ontologies instead of the merged one.
</p>
<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="show('qu9')" value="Show solution 3"/>
<!--input type="button" onclick="show('qu8')" value="Show solution 2"/>
<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">
......@@ -393,10 +398,10 @@ IDDL: Estudiante <= Person is not entailed
IDDL: Estudiante <= Student is entailed
</pre>
<h2>Full solution</h2>
<!--h2>Full solution</h2>
<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 />
<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