Mentions légales du service

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

- updated tutorial description (pre-4.0)

parent f95b3adb
No related branches found
No related tags found
No related merge requests found
...@@ -48,23 +48,10 @@ div.logic { ...@@ -48,23 +48,10 @@ div.logic {
own applications. own applications.
</p> </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>The data</h2>
<p>Your mission, if you accept it, will be to find the best alignment between two bibliographic ontologies. They can be seen here:</p>
<dl>
<dt>edu.mit.visus.bibtex.owl</dt>
<dd>is a relatively faithfull transcription of BibTeX as an ontology. It can be seen here in <a href="edu.mit.visus.bibtex.owl"><abbr title="Ressource Description Framework">RDF</abbr>/<abbr title="eXtansible Markup Language">XML</abbr></a> or <a href="edu.mit.visus.bibtex.html"><abbr>HTML</abbr></a>.</dd>
<dt>myOnto.owl</dt>
<dd>is an extension of the previous one that contains a number of supplementary concepts. It can be seen here in <a href="myOnto.owl"><abbr>RDF</abbr>/<abbr>XML</abbr></a> or <a href="myOnto.html"><abbr>HTML</abbr></a>.</dd>
</dl>
<p>These two ontologies have been used for a few years in the <a href="oaei.ontologymatching.org">Ontology Alignment Evaluation Initiative</a>.</p> <h2>Starting point</h2>
<h2>Embedding</h2>
<p>Of course, the goal of this <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>
<p>A skeleton of program using the Alignment <abbr>API</abbr> is <a href="Skeleton.java">Skeleton.java</a>. It can be compiled by invoking:</p> <p>A skeleton of program using the Alignment <abbr>API</abbr> is <a href="Skeleton.java">Skeleton.java</a>. It can be compiled by invoking:</p>
<div class="fragment"> <div class="fragment">
$ javac -classpath ../../lib/align.jar:../../lib/procalign.jar -d results Skeleton.java $ javac -classpath ../../lib/align.jar:../../lib/procalign.jar -d results Skeleton.java
...@@ -74,7 +61,10 @@ $ javac -classpath ../../lib/align.jar:../../lib/procalign.jar -d results Skelet ...@@ -74,7 +61,10 @@ $ javac -classpath ../../lib/align.jar:../../lib/procalign.jar -d results Skelet
$ java -cp ../../lib/Procalign.jar:results Skeleton file://$CWD/myOnto.owl file://$CWD/edu.mit.visus.bibtex.owl $ java -cp ../../lib/Procalign.jar:results Skeleton file://$CWD/myOnto.owl file://$CWD/edu.mit.visus.bibtex.owl
</div> </div>
<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 in order for it performs the following:</p> <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>
<ul> <ul>
<li>Run two different alignment methods (e.g., ngram distance and smoa);</li> <li>Run two different alignment methods (e.g., ngram distance and smoa);</li>
<li>Merge the two results;</li> <li>Merge the two results;</li>
...@@ -84,11 +74,76 @@ $ java -cp ../../lib/Procalign.jar:results Skeleton file://$CWD/myOnto.owl file: ...@@ -84,11 +74,76 @@ $ java -cp ../../lib/Procalign.jar:results Skeleton file://$CWD/myOnto.owl file:
</ul> </ul>
<p>Of course, you can do it progressively.</p> <p>Of course, you can do it progressively.</p>
<h2>Call an alignment method</h2>
<div class="fragment"> <div class="fragment">
$ javac -classpath ../../lib/align.jar:../../lib/procalign.jar -d results MyApp.java $ javac -classpath ../../lib/align.jar:../../lib/procalign.jar -d results MyApp.java
$ java -cp ../../lib/Procalign.jar:results MyApp file://$CWD/myOnto.owl file://$CWD/edu.mit.visus.bibtex.owl > results/MyApp.owl $ java -cp ../../lib/Procalign.jar:results MyApp file://$CWD/myOnto.owl file://$CWD/edu.mit.visus.bibtex.owl > results/MyApp.owl
</div> </div>
<div class="fragment">
// Run two different alignment methods (e.g., ngram distance and smoa)
AlignmentProcess a1 = new StringDistAlignment();
params.setParameter("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");
a2.align( (Alignment)null, params );
</div>
<h2>Manipulate alignments (merge and trim)</h2>
<div class="fragment">
// Merge the two results.
((BasicAlignment)a1).ingest(a2);
// Threshold at various thresholds
</div>
<h2>Evaluating alignments</h2>
<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());
Evaluator evaluator = new PRecEvaluator( reference, a1 );
double best = 0.;
Alignment result = null;
Parameters p = new BasicParameters();
for ( int i = 0; i <= 10 ; i += 2 ){
a1.cut( ((double)i)/10 );
evaluator = new PRecEvaluator( reference, a1 );
evaluator.eval( p );
System.err.println("Threshold "+(((double)i)/10)+" : "+((PRecEvaluator)evaluator).getFmeasure()+" over "+a1.nbCells()+" cells");
if ( ((PRecEvaluator)evaluator).getFmeasure() > best ) {
result = (BasicAlignment)((BasicAlignment)a1).clone();
best = ((PRecEvaluator)evaluator).getFmeasure();
}
}
</div>
<h2>Displaying an alignment</h2>
<div class="fragment">
// Displays it as OWL Rules
PrintWriter writer = new PrintWriter (
new BufferedWriter(
new OutputStreamWriter( System.out, "UTF-8" )), true);
AlignmentVisitor renderer = new OWLAxiomsRendererVisitor(writer);
a1.render(renderer);
writer.flush();
writer.close();
</div>
<h2>Putting them together</h2>
<p>Do you want to see a possible solution?</p> <p>Do you want to see a possible solution?</p>
<div class="button"> <div class="button">
<input type="button" onclick="show('qu7')" value="Cheat"/> <input type="button" onclick="show('qu7')" value="Cheat"/>
...@@ -114,8 +169,6 @@ $ java -cp ../../lib/Procalign.jar:results MyApp file://$CWD/myOnto.owl file://$ ...@@ -114,8 +169,6 @@ $ java -cp ../../lib/Procalign.jar:results MyApp file://$CWD/myOnto.owl file://$
// Evaluate them against the references // Evaluate them against the references
// and choose the one with the best F-Measure // and choose the one with the best F-Measure
AlignmentParser aparser = new AlignmentParser(0); AlignmentParser aparser = new AlignmentParser(0);
// Changed by Angel for Windows
//Alignment reference = aparser.parse( "file://"+(new File ( "refalign.rdf" ) . getAbsolutePath()) );
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 ); Evaluator evaluator = new PRecEvaluator( reference, a1 );
...@@ -155,7 +208,10 @@ Threshold 1.0 : 0.5151515151515151 over 18 cells ...@@ -155,7 +208,10 @@ Threshold 1.0 : 0.5151515151515151 over 18 cells
<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>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 subclassing the Java programs provided in the Alignment <abbr>API</abbr> implementation (like BasicAlignment or DistanceAlignment).</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>Advanced:</b> What about writing an editor for the alignment <abbr>API</abbr>?</p></div> <div class="logic"><p><b>Advanced:</b> What about writing an editor for the alignment <abbr>API</abbr>?</p></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