diff --git a/html/tutorial/tutorial3/embed.html b/html/tutorial/tutorial3/embed.html index e4ad4f2658c926243b11f5166afc4955ef5ad2b3..8ea6c2c4d6a03f0c5724764acf23ef63d7adbbc8 100644 --- a/html/tutorial/tutorial3/embed.html +++ b/html/tutorial/tutorial3/embed.html @@ -48,23 +48,10 @@ div.logic { own applications. </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>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> -<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>Embedding</h2> +<h2>Starting point</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> <div class="fragment"> $ 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 $ java -cp ../../lib/Procalign.jar:results Skeleton file://$CWD/myOnto.owl file://$CWD/edu.mit.visus.bibtex.owl </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> <li>Run two different alignment methods (e.g., ngram distance and smoa);</li> <li>Merge the two results;</li> @@ -84,11 +74,76 @@ $ java -cp ../../lib/Procalign.jar:results Skeleton file://$CWD/myOnto.owl file: </ul> <p>Of course, you can do it progressively.</p> + +<h2>Call an alignment method</h2> + <div class="fragment"> $ 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 </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> <div class="button"> <input type="button" onclick="show('qu7')" value="Cheat"/> @@ -114,8 +169,6 @@ $ java -cp ../../lib/Procalign.jar:results MyApp file://$CWD/myOnto.owl file://$ // Evaluate them against the references // and choose the one with the best F-Measure 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()); Evaluator evaluator = new PRecEvaluator( reference, a1 ); @@ -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>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>