Mentions légales du service

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

- finished tutorial3/embed

- updated all tutorials and material for release 4.0
parent 6f52ccdd
No related branches found
No related tags found
No related merge requests found
......@@ -66,8 +66,8 @@ through its REST web service API,</li>
</ul>
It is based on Java programming and using various
related APIs.</dd>
<dt><a href="tutorial3/embed.html"></a>Embedding the Alignment API
within an application <span style="color: red;">(Not ready yet)</span></dt>
<dt><a href="tutorial3/embed.html">Embedding the Alignment API
within an application</a></dt>
<dd>Explains how an aplication
developer can embed the Alignment API within an application.</dd>
<dt><a href="tutorial3/index.html">Extending the Alignment API with a new matcher</a></dt>
......@@ -161,7 +161,7 @@ Now you can go back to any of the tutorials:
<li><a href="tutorial1/index.html">Using the Alignment API</a></li>
<li><a href="tutorial1/server.html">Manipulating Alignments through a Web client</a></li>
<li><a href="tutorial2/index.html">Manipulating alignments in Java programs</a></li>
<li><a href="tutorial3/embed.html"></a>Embedding the Alignment API within an application</li>
<li><a href="tutorial3/embed.html">Embedding the Alignment API within an application</a></li>
<li><a href="tutorial3/index.html">Extending the Alignment API with a new matcher</a></li>
</ul>
</p>
......@@ -177,10 +177,10 @@ $ xsltproc ../form-align.xsl results/file.rdf > results/file.html
<p>The format of these tutorials has been shamelessly borrowed from Sean Bechhofer's <a href="http://owl.man.ac.uk/2005/07/sssw/"><acronym>OWL</acronym> tutorial</a>.</p>
<hr />
<address>
<small>
<div style="text-align: center;">http://alignapi.gforge.inria.fr/tutorial/</div>
<hr />
$Id$
</address>
</small>
</body>
</html>
......@@ -38,7 +38,7 @@ div.logic {
<dt>This version:</dt>
<dd>http://alignapi.gforge.inria.fr/tutorial/tutorial1/server.html</dd>
<dt>Author:</dt>
<dd><a href="http://exmo.inrialpes.fr/people/euzenat">J&eacute;r&ocirc;me Euzenat</a>, INRIA Rh&ocirc;ne-Alpes
<dd><a href="http://exmo.inrialpes.fr/people/euzenat">J&eacute;r&ocirc;me Euzenat</a>, INRIA &amp; LIG
</dd>
</dl>
......
......@@ -34,9 +34,6 @@ div.logic {
<h1>Manipulating alignments in Java programs: advanced tutorial on the Alignment <abbr title="Application Programming Interface">API</abbr> and server</h1>
<p style="background-color: yellow;">
This tutorial is to be revised (but you can try it anyway and report).
</p>
<p>
<dl>
<dt>This version:</dt>
......
/*
* $Id$
*
* Copyright (C) INRIA, 2006-2009
* Copyright (C) INRIA, 2006-2009, 2010
*
* Modifications to the initial code base are copyright of their
* respective authors, or their employers as appropriate. Authorship
......@@ -28,7 +28,6 @@
import org.semanticweb.owl.align.Alignment;
import org.semanticweb.owl.align.AlignmentProcess;
import org.semanticweb.owl.align.AlignmentVisitor;
import org.semanticweb.owl.align.Parameters;
import org.semanticweb.owl.align.Evaluator;
// Alignment API implementation classes
......@@ -61,7 +60,7 @@ public class MyApp {
public static void main( String[] args ) {
URI onto1 = null;
URI onto2 = null;
Parameters params = new BasicParameters();
Properties params = new BasicParameters();
try {
// Loading ontologies
......@@ -75,13 +74,13 @@ public class MyApp {
// Run two different alignment methods (e.g., ngram distance and smoa)
AlignmentProcess a1 = new StringDistAlignment();
params.setParameter("stringFunction","smoaDistance");
params.setProperty("stringFunction","smoaDistance");
a1.init ( onto1, onto2 );
a1.align( (Alignment)null, params );
AlignmentProcess a2 = new StringDistAlignment();
a2.init ( onto1, onto2 );
params = new BasicParameters();
params.setParameter("stringFunction","ngramDistance");
params.setProperty("stringFunction","ngramDistance");
a2.align( (Alignment)null, params );
// Merge the two results.
......@@ -98,7 +97,7 @@ public class MyApp {
double best = 0.;
Alignment result = null;
Parameters p = new BasicParameters();
Properties p = new BasicParameters();
for ( int i = 0; i <= 10 ; i += 2 ){
a1.cut( ((double)i)/10 );
// JE: I do not understand why I must create a new one!
......
/*
* $Id$
*
* Copyright (C) 2006-2008, INRIA Rhne-Alpes
* Copyright (C) INRIA, 2006-2008, 2010
*
* Modifications to the initial code base are copyright of their
* respective authors, or their employers as appropriate. Authorship
......@@ -28,7 +28,6 @@
import org.semanticweb.owl.align.Alignment;
import org.semanticweb.owl.align.AlignmentProcess;
import org.semanticweb.owl.align.AlignmentVisitor;
import org.semanticweb.owl.align.Parameters;
// Alignment API implementation classes
import fr.inrialpes.exmo.align.impl.BasicAlignment;
......@@ -57,7 +56,7 @@ public class Skeleton {
public static void main( String[] args ) {
URI onto1 = null;
URI onto2 = null;
Parameters params = new BasicParameters();
Properties params = new BasicParameters();
try {
// Loading ontologies
......
......@@ -47,7 +47,9 @@ div.logic {
tutorial for embedding the alignment <abbr>API</abbr> within your
own applications.
</p>
<p>
<small>This tutorial has been designed for the Alignment API version 4.0.</small>
</p>
<p>Of course, the goal of the Alignment <abbr>API</abbr> is not to be used at the command line level (even if it can be very useful). So if you are ready for it, you can develop in Java your own application that takes advantage of the <abbr>API</abbr>.</p>
<h2>Starting point</h2>
......@@ -63,7 +65,7 @@ $ java -cp ../../lib/Procalign.jar:results Skeleton file://$CWD/myOnto.owl file:
<p>Now considering the <abbr>API</abbr> (that can be consulted through its
thin <a href="../../../javadoc/org/semanticweb/owl/align/Alignment.html">Javadoc</a>
for instance), can you modify the Skeleton program so that it performs the following:</p>
for instance), the goal is to modify the Skeleton program so that it performs the following:</p>
<ul>
<li>Run two different alignment methods (e.g., ngram distance and smoa);</li>
<li>Merge the two results;</li>
......@@ -85,24 +87,41 @@ Matching two ontologies is achieved with three steps:
<li>calling the matching method (<tt>align</tt>).</li>
</ul>
The matching method takes two arguments: an eventual alignment to
improve on (which can be null) a set of parameters
improve on (which can be null) a set of parameters. So, the three
lines below match ontologies <tt>onto1</tt> and <tt>onto2</tt> with
the <tt>StringDistAlignment</tt> matcher:
<div class="fragment">
AlignmentProcess a = new StringDistAlignment();
a.init ( onto1, onto2 );
a.align( (Alignment)null, new BasicParameters() );
</div>
</p>
<p>
Below, two different methods (<tt>StringDistAlignment</tt> with two
different <tt>stringFunction</tt> parameters) are instantiated and run:
<div class="fragment">
Now, the first step is to run two different instances
of <tt>StringDistAlignment</tt> with different <tt>stringFunction</tt>
parameters corresponding to "smoaDistance" and "ngramDistance".
</p>
<div class="button">
<input type="button" onclick="show('qu1')" value="Show result"/>
<input type="button" onclick="hide('qu1')" value="Hide result"/>
</div>
<div class="explain" id="qu1">
<pre>
Properties params = new BasicParameters();
// Run two different alignment methods (e.g., ngram distance and smoa)
AlignmentProcess a1 = new StringDistAlignment();
params.setParameter("stringFunction","smoaDistance");
params.setProperty("stringFunction","smoaDistance");
a1.init ( onto1, onto2 );
a1.align( (Alignment)null, params );
AlignmentProcess a2 = new StringDistAlignment();
a2.init ( onto1, onto2 );
params = new BasicParameters();
params.setParameter("stringFunction","ngramDistance");
params.setProperty("stringFunction","ngramDistance");
a2.align( (Alignment)null, params );
</pre>
</div>
<p>
After this step, the two matching methods have been processed and the
result is available within the alignment instances (<tt>a1</tt>
and <tt>a2</tt>).
......@@ -114,20 +133,51 @@ and <tt>a2</tt>).
Alignments offer methods to manipulate these alignments. In
particular, it is possible to
<ul>
<li>clone alignments,</li>
<li>invert alignments (change the order of ontologies),</li>
<li>merge alignments (put all their correspondences together),</li>
<li>trim them under various threshold and threshold modalities.</li>
<li>clone alignments (<tt>clone()</tt>),</li>
<li>invert alignments (change the order of ontologies, <tt>inverse()</tt>),</li>
<li>merge alignments (put all their correspondences together, <tt>ingest(Alignment)</tt>),</li>
<li>trim them under various threshold and threshold modalities (<tt>cut(threshold)</tt>).</li>
</ul>
Of these, cloning and inverting creates a new alignment while the
other operations modify the alignment.
</p>
<div class="fragment">
<p>
The goal of the excercise is to create a copy of
alignment <tt>a1</tt>, merge it with <tt>a2</tt> to invert the
order of their ontologies and to finally trim the result under a
threshold of .5. At each step, display the number of
corresondences in the resulting alignment.
</p>
<div class="button">
<input type="button" onclick="show('qu2')" value="Show result"/>
<input type="button" onclick="hide('qu2')" value="Hide result"/>
</div>
<div class="explain" id="qu2">
<pre>
// Clone a1
System.err.println( a1.nbCells() );
BasicAlignment a3 = (BasicAlignment)(a1.clone());
System.err.println( a3.nbCells() );
// Merge the two results.
((BasicAlignment)a1).ingest(a2);
a3.ingest( a2 );
System.err.println( a3.nbCells() );
// Threshold at various thresholds
// Invert the alignement
BasicAlignment a4 = a3.inverse();
System.err.println( a4.nbCells() );
// Trim above .5
a4.cut( .5 );
System.err.println( a4.nbCells() );
</pre>
</div>
<div class="logic"><p><b>More work:</b> You can consider the more
elaborate versions of <tt>cut()</tt> and compare the results.</p></div>
<h2>Evaluating alignments</h2>
<p>
......@@ -147,14 +197,10 @@ reference alignment, then creates an instance
of <tt>PRecEvaluator</tt> for computing precision and recall between
the alignment <tt>a1</tt> above with respects to the reference alignment.
<div class="fragment">
// Evaluate them against the references
// and choose the one with the best F-Measure
AlignmentParser aparser = new AlignmentParser(0);
Alignment reference = aparser.parse( (new File ( "refalign.rdf" ) ) . toURL() . toString());
Alignment reference = aparser.parse( (new File ( "refalign.rdf" ) ).toURL().toString() );
Evaluator evaluator = new PRecEvaluator( reference, a1 );
Parameters p = new BasicParameters();
evaluator.eval( p );
evaluator.eval( new BasicParameters() );
</div>
As previously, results are stored within the <tt>Evaluator</tt> object
and are accessed through specific accessors.
......@@ -174,6 +220,7 @@ F-measure.
<pre>
double best = 0.;
Alignment result = null;
Properties p = new BasicParameters();
for ( int i = 0; i <= 10 ; i += 2 ){
a1.cut( ((double)i)/10 );
evaluator = new PRecEvaluator( reference, a1 );
......@@ -233,13 +280,13 @@ alignment selected at the previous exercise as a set of OWL axioms.
<pre>
// Run two different alignment methods (e.g., ngram distance and smoa)
AlignmentProcess a1 = new StringDistAlignment();
params.setParameter("stringFunction","smoaDistance");
params.setProperty("stringFunction","smoaDistance");
a1.init ( onto1, onto2 );
a1.align( (Alignment)null, params );
AlignmentProcess a2 = new StringDistAlignment();
a2.init ( onto1, onto2 );
params = new BasicParameters();
params.setParameter("stringFunction","ngramDistance");
params.setProperty("stringFunction","ngramDistance");
a2.align( (Alignment)null, params );
// Merge the two results.
......@@ -254,7 +301,7 @@ alignment selected at the previous exercise as a set of OWL axioms.
double best = 0.;
Alignment result = null;
Parameters p = new BasicParameters();
Properties p = new BasicParameters();
for ( int i = 0; i <= 10 ; i += 2 ){
a1.cut( ((double)i)/10 );
evaluator = new PRecEvaluator( reference, a1 );
......@@ -295,18 +342,13 @@ Threshold 1.0 : 0.5151515151515151 over 18 cells
<p>
<p>A full working solution is <a href="MyApp.java">MyApp.java</a>.</p>
<div class="logic"><p><b>More work:</b> Can you add a switch like the <tt>-i</tt> switch of <tt>Procalign</tt> so that the main class of the application can be passed at commant-line.</p></div>
<div class="logic"><p><b>Advanced:</b> You can develop a specialized
matching algorithm by <a href="index.html">subclassing the Java programs provided in
the Alignment <abbr>API</abbr> implementation</a> (like BasicAlignment
or DistanceAlignment).</p></div>
<div class="logic"><p><b>More work:</b> You can add a switch like the <tt>-i</tt> switch of <tt>Procalign</tt> so that the main class of the application can be passed at commant-line.</p></div>
<div class="logic"><p><b>Advanced:</b> What about writing an editor for the alignment <abbr>API</abbr>?</p></div>
<h2>Further exercises</h2>
<p>More info: <a href="http://alignapi.gforge.inria.fr">http://alignapi.gforge.inria.fr</a></p>
<p>More info: <a href="http://alignapi.gforge.inria.fr/tutorial/">http://alignapi.gforge.inria.fr/tutorial/</a></p>
<hr />
<small>
......
......@@ -277,7 +277,14 @@ However, it will require to reimplement other types of objects
(<tt>Cell</tt>, <tt>Relation</tt>) and to implement the
full <tt>Alignement</tt> interface.
</p>
<div class="logic"><p><b>Advanced:</b> You can develop a specialized matching algorithm by subclassing the Java programs provided in the Alignment <abbr>API</abbr> implementation (like DistanceAlignment).</p></div>
<!--h3>DistanceAlignment class template</h3>
<p>
The API features a DistanceAlignment abstract class that can be specialised for creating a similarity or distance based matching method. This class offers a variety of methods for extracting alignments from distance matrix.
</p-->
<h2>Other natural extensions</h2>
<p>
......@@ -353,12 +360,10 @@ extends a class that implements the interface. This is a limitation of
Java support.
</p>
<!--h3>DistanceAlignment class template</h3>
<p>
The API features a DistanceAlignment abstract class that can be specialised for creating a similarity or distance based matching method. This class offers a variety of methods for extracting alignments from distance matrix.
</p-->
<h2>Further exercises</h2>
<p>More info: <a href="http://alignapi.gforge.inria.fr/tutorial/">http://alignapi.gforge.inria.fr/tutorial/</a></p>
<hr />
<small>
<div style="text-align: center;">http://alignapi.gforge.inria.fr/tutorial/tutorial3/</div>
......
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