diff --git a/README.AServ b/README.AServ index 6fc9c4abad66d2a750658b276c670779e66119a4..1d1fbcc0517794376f336cb92a00f4e3234315d8 100644 --- a/README.AServ +++ b/README.AServ @@ -1,6 +1,6 @@ ####################################################################### # Alignment Server launch instructions # -# 30/03/2013, version 4.5 # +# 11/01/2014, version 4.5 # ####################################################################### Using the alignment server requires an SQL database server. diff --git a/README.TXT b/README.TXT index dfea4a95ac03faebff10f064ae2f6a3a1ddabc1a..445a22e465a01dae93fd60a832d0963baa5d1aea 100644 --- a/README.TXT +++ b/README.TXT @@ -1,10 +1,10 @@ ####################################################################### # Ontology alignment API and implementation # -# 01/01/2013, version 4.4 # +# 11/01/2014, version 4.5 # # http://alignapi.gforge.inria.fr # ####################################################################### -Copyright (C) 2003-2013 INRIA. +Copyright (C) 2003-2014 INRIA. Copyright (C) 2004-2005 Université de Montréal. Copyright (C) 2005 CNR Pisa. Copyright (C) 2005 Konstantinos A. Nedas. @@ -91,16 +91,16 @@ LAST RELEASE The last release is available from: http://gforge.inria.fr/frs/?group_id=117 +DOCUMENTATION +------------- + +The documentation can be found online at http://alignapi.gforge.inria.fr + SOURCE REPOSITORY ----------------- See http://gforge.inria.fr/scm/?group_id=117 for SVN Access. -DOCUMENTATION -------------- - -The documentation can be found on http://gforge.inria.fr/docman/?group_id=117 - FILES ----- diff --git a/build.xml b/build.xml index c01367490a9cd790f12e92103438f23ead14ee7c..6d9bc8f0790b52d9e65c7ee220e80a4ed4bd1fe3 100644 --- a/build.xml +++ b/build.xml @@ -55,7 +55,7 @@ <tstamp><format locale="fr,fr" pattern="dd/MM/yyyy" property="date"/></tstamp> <property name="version.major" value="4"/> <property name="version.minor" value="5"/> - <property name="copyyear" value="2003-2013"/> + <property name="copyyear" value="2003-2014"/> <!-- first attempt --> <exec executable="svnversion" outputproperty="svn.rev" failifexecutionfails="false"/> <condition property="svn.revision" value="${svn.rev}" else="nosvn"> @@ -224,7 +224,7 @@ group="fr.inrialpes.exmo.align" desc="Alignment API implementation" main="fr.inrialpes.exmo.align.cli.Procalign" - path="skosapi/skosapi.jar owlapi30/owlapi-bin.jar ontosim/ontosim.jar getopt/getopt.jar slf4j/jcl-over-slf4j.jar slf4j/log4j-over-slf4j.jar slf4j/slf4j-api.jar jwnl/jwnl.jar lucene/lucene-core.jar jena/jena.jar jena/iri.jar jena/icu4j.jar iddl/iddl.jar xerces/xercesImpl.jar xerces/resolver.jar xerces/xml-apis.jar hermit/hermit.jar align.jar ontowrap.jar procalign.jar"> + path="skosapi/skosapi.jar owlapi30/owlapi-bin.jar ontosim/ontosim.jar cli/commons-cli.jar slf4j/jcl-over-slf4j.jar slf4j/log4j-over-slf4j.jar slf4j/slf4j-api.jar jwnl/jwnl.jar lucene/lucene-core.jar jena/jena.jar jena/iri.jar jena/icu4j.jar iddl/iddl.jar xerces/xercesImpl.jar xerces/resolver.jar xerces/xml-apis.jar hermit/hermit.jar align.jar ontowrap.jar procalign.jar"> <files> <fileset dir="classes"> <include name="fr/inrialpes/exmo/align/impl/**/*.class"/> @@ -285,7 +285,7 @@ <attribute name="Built-Date" value="${date}"/> <attribute name="Main-Class" value="fr.inrialpes.exmo.align.service.AlignmentService"/> <!-- usually each MANIFEST knows what it needs, add here --> - <!-- semanticmapper-0.2.jar jwnl.jar sboa.jar TaxoMap.jar AROMA_aserv.jaroyster2.jar, semanticmapper-0.2.jar, sboalgorithms.jar --> + <!-- semanticmapper-0.2.jar jwnl.jar sboa.jar TaxoMap.jar AROMA_aserv.jar oyster2.jar, semanticmapper-0.2.jar, sboalgorithms.jar --> <!-- others should be there naturally --> <attribute name="Class-Path" value="alignsvc.jar"/> <attribute name="Implementation-Title" value="Alignment server custom launcher"/> @@ -313,6 +313,7 @@ <!-- tested --> <target name="test" depends="bind" description="Unit test code"> <echo message="Testing..."/> + <echo message="You may also want to try sh test/clitest.sh"/> <taskdef name="testng" classpath="${tooldir}/testng/testng.jar" classname="org.testng.TestNGAntTask" /> <javac srcdir="test/src" includeantruntime="false" destdir="test/classes" debug="on" classpath="tools/testng/testng.jar" encoding="iso8859-15"> @@ -344,7 +345,7 @@ <delete> <fileset dir="test/classes" includes="**/*.class"/> <fileset dir="test/output" includes="**/*.*"/> - <fileset dir="test/html" includes="**/*.html,**/*.xml,**/*.css"/> + <fileset dir="test/html" includes="**/*.*"/> </delete> <delete dir="test/html/Ant suite"/> </target> @@ -515,7 +516,7 @@ <echo message="@{file}" /> <onepom file="@{file}" /> </for--> - <onepom file="getopt/getopt" /> + <onepom file="cli/commons-cli" /> <onepom file="google-translate/google-api-translate-java" /> <onepom file="google-translate/json" /> <onepom file="hermit/hermit" /> diff --git a/examples/omwg/total.xml b/examples/omwg/total.xml index 43540d4a0860bda3d05c28ea607855ef086e61bb..322b38a64e55e0804952b7f855037f6979a079dc 100644 --- a/examples/omwg/total.xml +++ b/examples/omwg/total.xml @@ -40,8 +40,7 @@ <Ontology rdf:about="&vin;"> <location>http://www.scharffe.fr/ontologies/OntologieDuVin.wsml</location> <formalism> - <Formalism align:uri="http://www.wsmo.org/wsml/wsml-syntax/wsml-dl" - align:name="wsml" /> + <Formalism align:uri="http://www.wsmo.org/wsml/wsml-syntax/wsml-dl" align:name="wsml" /> </formalism> </Ontology> </onto2> diff --git a/html/cli.html b/html/cli.html index bd8c1603183af1087ade65f997136a20a24b4e88..7656859191432a9c936f6461f7317be45ec375d2 100644 --- a/html/cli.html +++ b/html/cli.html @@ -33,7 +33,7 @@ the <tt>fr.inrialpes.exmo.align.cli</tt> package: These command line operations usually share switch conventions: <ul> <li>displaying help (-h);</li> -<li>displaying debug information (-d);</li> +<li>taking parameerst (-Dv=n) and parameter files (-P);</li> <li>directing the output to a file (-o);</li> </ul></p> @@ -46,7 +46,7 @@ the <tt>align</tt> method. <h2>Matching</h2> <p> -The implementation offers a stand-alone program (<tt>fr.inrialpes.exmo.align.util.Procalign</tt>) which: +The implementation offers a stand-alone program (<tt>fr.inrialpes.exmo.align.cli.Procalign</tt>) which: <ul> <li>Reads two OWL/RDF ontologies;</li> <li>Creates an alignment object;</li> @@ -65,21 +65,23 @@ Additional options are available: <p>Running the program is achieved through: <div class="terminal"> $ java -jar lib/procalign.jar -Two URIs required -usage: Procalign [options] URI1 URI2 -options are: - --impl=className -i classname Use the given alignment implementation. - --renderer=className -r className Specifies the alignment renderer - --output=filename -o filename Output the alignment in filename - --params=filename -p filename Reads parameters from filename - --alignment=filename -a filename Start from an XML alignment file - --threshold=double -t double Filters the similarities under threshold - --cutmethod=hard|perc|prop|best|span -T hard|perc|prop|best|span method for computing the threshold - --debug[=n] -d [n] Report debug info at level n - -Dparam=value Set parameter - --help -h Print this message +usage: java fr.inrialpes.exmo.align.cli.Procalign [options] ontoURI ontoURI + Matches the two ontologies identified by <ontoURI> -$Id$ +Options: + -a,--alignment <FILE> Use initial alignment FILE + -D <NAME=VALUE> Use value for given property + -d,--debug <LEVEL> debug argument is deprecated, use logging instead + See http://alignapi.gforge.inria.fr/logging.html + -h,--help Print this page + -i,--impl <CLASS> Use the given CLASS for matcher + -o,--output <FILENAME> Send output to FILENAME + -P,--params <FILE> Read parameters from FILE + -r,--renderer <CLASS> Use the given CLASS for output + -T,--cutmethod <METHOD> Method to use for triming (hard|perc|prop|best|span) + -t,--threshold <DOUBLE> Trim the alignment with regard to threshold + +Alignment API implementation 4.5 (1864M) </div> </p> <p> @@ -89,10 +91,33 @@ Parameters can be passed to all the command line interfaces through the "-Dname= <h2>Batch matching</h2> <p>There is a small utility (<tt>GroupAlign</tt>) which allows to implement batch matching. It starts with a directory containing a set of subdirectories. Each subdirectory contains an ontology to align (usually called <tt>onto.rdf</tt>) and there exist an ontology to be aligned againts these (-n argument, e.g., named <tt>./onto.rdf</tt>).</p> +<div class="terminal"> +$ java -cp lib/procalign.jar fr.inrialpes.exmo.align.cli.GroupAlign --help +usage: java fr.inrialpes.exmo.align.cli.GroupAlign [options] + Matches pairs of ontologies in subdirectories + +Options: + -a,--alignment <FILE> Use an initial alignment FILE + -D <NAME=VALUE> Use value for given property + -d,--debug <LEVEL> debug argument is deprecated, use logging instead + See http://alignapi.gforge.inria.fr/logging.html + -h,--help Print this page + -i,--impl <CLASS> Use the given Alignment implementation + -n,--name <URI> Use the given URI as common source ontology + -o,--output <FILENAME> Send output to FILENAME + -P,--params <FILE> Read parameters from FILE + -r,--renderer <CLASS> Use the given CLASS for rendering + -s,--source <FILE> Source ontology FILEname (default onto1.rdf) + -t,--target <FILE> Target ontology FILEname (default onto.rdf) + -u,--uriprefix <URI> URI prefix of the target + -w,--directory <DIR> The DIRectory containing the data to match + +Alignment API implementation 4.5 (1864M) +</div> -<p>Invoking <tt>GroupAlign</tt> with some implementation (-i argument), some set of parameters (-p argument), the name of the output file (-o argument) and optionally a renderer (-r argument) will output the resulting alignment in each of these directories: +<p>Invoking <tt>GroupAlign</tt> with some implementation (-i argument), some set of parameters (-P argument), the name of the output file (-o argument) and optionally a renderer (-r argument) will output the resulting alignment in each of these directories: <div class="terminal"> -$ java -cp $CWD/../lib/procalign.jar fr.inrialpes.exmo.align.util.GroupAlign +$ java -cp $CWD/../lib/procalign.jar fr.inrialpes.exmo.align.cli@.GroupAlign -o edna -n file://$CWD/101/onto.rdf -i fr.inrialpes.exmo.align.impl.method.EditDistNameAlignment </div> diff --git a/html/eval.html b/html/eval.html index 26e2af02067abdb2b7fca554c25ebc98b774f503..424fe9eb6c9b453d5dadaf6a2662af21a1bff9b8 100644 --- a/html/eval.html +++ b/html/eval.html @@ -60,15 +60,20 @@ See below for more graphical formats. <p> The option of <tt>EvalAlign</tt> are: <div class="terminal"> -$ java -cp lib/procalign.jar fr.inrialpes.exmo.align.cli.EvalAlign --help -usage: EvalAlign [options] file1 file2 -options are: - --debug[=n] -d [n] Report debug info at level n - --impl=className -i classname Use the given Evaluator implementation. - --output=filename -o filename Output the result in filename - --help -h Print this message +$ java -cp lib/procalign.jar fr.inrialpeS.exmo.align.cli.EvalAlign --help +usage: java fr.inrialpes.exmo.align.cli.EvalAlign [options] alignURI alignURI + Evaluate two alignments identified by <alignURI> -Alignment API implementation 4.3 (1698M) ($Id$) +Options: + -D <NAME=VALUE> Use value for given property + -d,--debug <LEVEL> debug argument is deprecated, use logging instead + See http://alignapi.gforge.inria.fr/logging.html + -h,--help Print this page + -i,--impl <CLASS> Use the given CLASS for evaluator + -o,--output <FILENAME> Send output to FILENAME + -P,--params <FILE> Read parameters from FILE + +Alignment API implementation 4.5 (1864M) </div> The <tt>-i</tt> switch enables changing the evaluator to be used (by default, <tt>PRecEvaluator</tt> is used). @@ -289,14 +294,25 @@ $ java -cp ../lib/procalign.jar fr.inrialpes.exmo.align.cli.GenPlot -l "refalign <tt>GenPlot</tt> accepts the following arguments: <div class="terminal"> $ java -cp /Java/alignapi/lib/procalign.jar fr.inrialpes.exmo.align.cli.GenPlot --help -usage: GenPlot [options] -options are: - --type=tsv|tex|html(|xml) -t tsv|tex|html(|xml) Specifies the output format - --graph=class -g class Specifies the class of Evaluator to be used - --evaluator=class -e class Specifies the class of GraphEvaluator (plotter) to be used - --list=algo1,...,algon -l algo1,...,algon Sequence of the filenames to consider - --debug[=n] -d [n] Report debug info at level n - --help -h Print this message +usage: java fr.inrialpes.exmo.align.cli.GenPlot [options] + Generate a graphic presentation of evaluation results + +Options: + -D <NAME=VALUE> Use value for given property + -d,--debug <LEVEL> debug argument is deprecated, use logging + instead + See + http://alignapi.gforge.inria.fr/logging.html + -e,--evaluator <CLASS> Use CLASS as evaluation plotter + -g,--grapher <CLASS> Use CLASS as graph generator + -h,--help Print this page + -l,--list <FILE> Consider this list of FILEs for inclusion in + the results + -o,--output <FILENAME> Send output to FILENAME + -P,--params <FILE> Read parameters from FILE + -t,--type <tsv|tex|html(|xml)> Output in the specified FORMAT (values + +Alignment API implementation 4.5 (1864M) </div> The <tt>-t</tt> switch specifies the type output. The plots are provided for PGF LaTeX as gnuplot tables. diff --git a/html/img/aserv-network.png b/html/img/aserv-network.png new file mode 100644 index 0000000000000000000000000000000000000000..9c54c093a22e3e0a70884a3c30588e8c6e3b139f Binary files /dev/null and b/html/img/aserv-network.png differ diff --git a/html/labels.html b/html/labels.html index 0d2761d10cd955b6d9d313d67d06f6e943246ef9..70935c17e0c3cab2dd87a84856a38a053de0e78c 100644 --- a/html/labels.html +++ b/html/labels.html @@ -64,7 +64,7 @@ <dt>http://knowledgeweb.semanticweb.org/heterogeneity/alignment#certificate</dd> <dd>STRING a certificate from an issuing source</dd> <dt>http://knowledgeweb.semanticweb.org/heterogeneity/alignment#time</dd> -<dd>DURATION of the matching process.</dd> +<dd>DURATION (default: INTEGER in milliseconds) of the matching process.</dd> <dt>http://knowledgeweb.semanticweb.org/heterogeneity/alignment#limitations</dd> <dd>STRING the validity range of the correspondence</dd> <dt>http://knowledgeweb.semanticweb.org/heterogeneity/alignment#properties</dd> diff --git a/html/lib.html b/html/lib.html index 176c3a256a7840ac293d6a0ea62d38be77f2f7f7..536b799811beff28bd4ddd3c7d16f587580e5c40 100644 --- a/html/lib.html +++ b/html/lib.html @@ -39,15 +39,14 @@ This is a simplified view: <a href="img/dependencies.png">click here <h2>Required for the API implementation (procalign)</h2> <dl> -<dt><a href="http://www.urbanophile.com/arenn/hacking/download.html">Gnu - getopt</a> 1.0.13: getopt.jar - [<a href="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</a>]</dt> -<dd>Gnu library for parsing command line arguments. Required - everywhere (included by OWL-API).</dd> -<dt><a href="http://www.slf4j.org/">SLF4J</a> 1.7.2: +<dt><a href="http://commons.apache.org/proper/commons-cli/">Commons CLI</a> 1.2: commons-cli.jar + [<a href="http://www.apache.org/licenses/LICENSE-2.0.html">Apache</a>]</dt> +<dd>Library for parsing command line arguments. Required for the + command line use (cli package; included by OWL-API).</dd> +<dt><a href="http://www.slf4j.org/">SLF4J</a> 1.7.5: slf4j-api.jar log4j-over-slf4j.jar jcl-over-slf4j.jar [<a href="http://www.slf4j.org/license.html">MIT license</a>] </dt> -<dd>At last some clean-up in the Java logging realm.</dd> +<dd>Java unified logging library!</dd> </dl> <h3>Required for using EDOAL</h3> @@ -118,7 +117,7 @@ and this will compile again. <h2>Required for the Alignment server (alignsvc)</h2> <dl> -<dt><a href="http://dev.mysql.com/downloads/connector/j/3.0.html">MySQL +<dt><a href="http://dev.mysql.com/downloads/connector/j/">MySQL JDBC Connectors</a> 5.1.12: mysql-connector-java-5.0.3-bin.jar [<a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GPL</a>] or <a href="http://jdbc.postgresql.org/">Postgres JDBC diff --git a/html/relnotes.html b/html/relnotes.html index eda8d8663cf6e9997bdf40b0cc301e1ca3c76c2d..eb504151cec7f0ea48b6c52ce01606571386ed0b 100644 --- a/html/relnotes.html +++ b/html/relnotes.html @@ -38,14 +38,13 @@ The development of 4 versions continues. <p><ul compact="1"> <li>Provide several URIs for the same alignment (server)</li> -<li>Adopt, overall, slf4j (impl/server)</li> <li>Implement database store for EDOAL (server)</li> <li>Add simple "harder" test generator (gen)</li> <li>Add simple "hidden" test generator (gen)</li> <li>Add a <tt>dependsOn</tt> alignment property (api)</li> <li>Consolidate alignment based on <tt>dependsOn</tt> (loop checking, cell ingestion) (impl)</li> -<li>Use the OWLReasoner interface and HermiT for adding inference to Ontowrap (ontowrap)</li> <li>Add a JSON interface (server)</li> +<li>Use the OWLReasoner interface and HermiT for adding inference to Ontowrap (ontowrap)</li> <li>Integrate tests from generator (test)</li> <li>Integrate some basic reasoning (impl).</li> <li>Complete tutorial4 with distributed reasoning.</li> @@ -74,9 +73,23 @@ with a warning: <!--h2>Version 4.9 (1xxx): ??/??/201X - Al pesto</h2--> <!--h2>Version 4.8 (1xxx): ??/??/201x - Antésine</h2--> <!--h2>Version 4.7 (1xxx): ??/??/201x - Letraset</h2--> -<!--h2>Version 4.6 (1xxx): ??/??/201X - Da lec'h all</h2--> +<!--h2>Version 4.6 (1xxx): ??/01/2014 - Da lec'h all</h2--> <p><ul compact="1"> +<li>Fixed a bug in <tt>EDOALAlignment.init()</tt> which would prohibit rendering (edoal)</li> +<li>Fixed a bug in <tt>OWLAxiomsRendererVisitor</tt>, <tt>SWRLRendererVisitor</tt>, <tt>SEKTMappingRendererVisitor</tt>, <tt>COWLMappingRendererVisitor</tt> <tt>SPARQLConstructRendererVisitor</tt>, and <tt>SPARQLSelectRendererVisitor</tt> which sometimes rendered alignments empty (impl)</li> +<li>All logging and signaling is now through slf4j (impl/server)</li> +<li>Replaced getopt by <span style="color: green">commons cli</span> 1.2 as command line interpreter (lib/cli)</li> +<li>Completed <tt>SWRLRendererVisitor</tt> to fill equivalence and subsumption statements (impl)</li> <li>Declared Alignment server as an OSGi service (server)</li> +<li>Made EDOAL vocabulary dereferenceable (edoal)</li> +<li>Fixed the build.xml file for using slf4j in microalign (android)</li> +<li>Fixed several bugs in <tt>WeightedPREvaluator</tt>, now two versions (impl)</li> +<li>Fixed display bugs in <tt>GroupEval</tt> and <tt>WGroupEval</tt> (cli)</li> +<li>Cancelled test <tt>EDOALTest.anotherRoundTripTest()</tt> because would try to load a WSMO ontology (test)</li> +<li>Changed <tt>-o</tt> option in <tt>GroupAlign</tt> to be homogeneous (cli)</li> +<li>Updated tutorial2 with deprecated <tt>BasicParameters</tt> (tutorial)</li> +<li>Added complete command line option tests in <tt>tests/clitest.sh</tt> (cli)</li> +<li>Upgraded to <span style="color: green">SLF4J</span> to 1.7.5 (lib)</li> </ul></p> <h2>Version 4.5 (1847): 25/03/2013 - Building 16</h2> diff --git a/html/testgen.html b/html/testgen.html index 600a65929afb4e4ead316ba28e94b8ba26d0b3ca..a78aa112052306e25cf2a5a2641c7eb0b9d7d326 100644 --- a/html/testgen.html +++ b/html/testgen.html @@ -349,6 +349,27 @@ a test set altering regularly one or several dimensions (each one represented by an alterator). </p> +<h4>Definitely harder benchmarks</h4> + +<p> +Benchmark is a test set were a seed ontology is altered and any test +has to match the seed ontology with the altered ontology. However, we can also ask +to match two differently altered ontologies. Since altered ontologies +come from the same seed ontology and the generateed alignments are +equivalence alignment, the reference alignment can be generated +automatically. Indeed, if benchmark test <i>X</i> generates +alignment <i>A<sub>X</sub></i> and test <i>Y</i> generates +alignment <i>A<sub>Y</sub></i>, then for the task of matching +ontology <i>o<sub>X</sub></i> to ontology <i>o<sub>Y</sub></i>, the +reference alignment will be: +<center> +<i>A<sub>X-Y</sub></i> = <i>A<sub>X</sub></i><sup>-1</sup> o <i>A<sub>Y</sub></i> +</center> +The two operations (<sup>-1</sup> and o) being part of the Alignment +API, this is easy to generate. +</p> +<p>Not available yet.</p> + <h4>Hidden ontology generator</h4> <p>Not available yet.</p> diff --git a/lib/cli/commons-cli.jar b/lib/cli/commons-cli.jar new file mode 100644 index 0000000000000000000000000000000000000000..ce4b9fffe40c41669797cd806ac989471b2acd84 Binary files /dev/null and b/lib/cli/commons-cli.jar differ diff --git a/lib/cli/commons-cli.pom b/lib/cli/commons-cli.pom new file mode 100644 index 0000000000000000000000000000000000000000..0be866944d60e94566de1021de9918520a37ed58 --- /dev/null +++ b/lib/cli/commons-cli.pom @@ -0,0 +1,21 @@ +<project> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.commons</groupId> + <artifactId>commons-cli</artifactId> + <version>1.2</version> + <name>Apache Commons CLI</name> + <inceptionYear>2002</inceptionYear> + <description> + Commons CLI provides a simple API for presenting, processing and validating a command line interface. + </description> + <packaging>jar</packaging> + <licenses> + <license> + <name>Apache License Version 2.0, January 2004</name> + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> + </license> + </licenses> + <url>http://commons.apache.org/cli/</url> + +</project> diff --git a/lib/slf4j/jcl-over-slf4j.jar b/lib/slf4j/jcl-over-slf4j.jar index 63888dc94b49d1608e89d797baab17757319d91b..a80e4f1c3cc5bf7d374837bb6c403565f68ad578 100644 Binary files a/lib/slf4j/jcl-over-slf4j.jar and b/lib/slf4j/jcl-over-slf4j.jar differ diff --git a/lib/slf4j/jcl-over-slf4j.pom b/lib/slf4j/jcl-over-slf4j.pom index c5a6d2de136d669a259407cd0324f6604febd319..59979200126069a99043281504f8fb29ce23f0fa 100644 --- a/lib/slf4j/jcl-over-slf4j.pom +++ b/lib/slf4j/jcl-over-slf4j.pom @@ -3,7 +3,7 @@ <parent> <groupId>org.slf4j</groupId> <artifactId>slf4j-parent</artifactId> - <version>1.7.2</version> + <version>1.7.5</version> </parent> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> @@ -14,7 +14,7 @@ <url>http://www.qos.ch</url> </organization> <inceptionYear>2005</inceptionYear> - <!-- Copyright (c) 2004-2011 QOS.ch --> + <!-- Copyright (c) 2004-2013 QOS.ch --> <licenses> <license> <name>MIT License</name> diff --git a/lib/slf4j/log4j-over-slf4j.jar b/lib/slf4j/log4j-over-slf4j.jar index cd04c46a124f2c17e71125e5a7e452b5bb199b9e..7caf77291dda4ce28cc3afb54be8786dd053a269 100644 Binary files a/lib/slf4j/log4j-over-slf4j.jar and b/lib/slf4j/log4j-over-slf4j.jar differ diff --git a/lib/slf4j/log4j-over-slf4j.pom b/lib/slf4j/log4j-over-slf4j.pom index 94553cca524d698c121176c245c0029f8101a561..5399331c25e92a4d9dc89bcf0ea0dbf6c191adca 100644 --- a/lib/slf4j/log4j-over-slf4j.pom +++ b/lib/slf4j/log4j-over-slf4j.pom @@ -3,7 +3,7 @@ <parent> <groupId>org.slf4j</groupId> <artifactId>slf4j-parent</artifactId> - <version>1.7.2</version> + <version>1.7.5</version> </parent> <groupId>org.slf4j</groupId> <artifactId>log4j-over-slf4j</artifactId> @@ -14,7 +14,7 @@ <url>http://www.qos.ch</url> </organization> <inceptionYear>2005</inceptionYear> - <!-- Copyright (c) 2004-2011 QOS.ch --> + <!-- Copyright (c) 2004-2013 QOS.ch --> <licenses> <license> <name>MIT License</name> diff --git a/lib/slf4j/slf4j-api.jar b/lib/slf4j/slf4j-api.jar index 73f38db9ce6973b8247c2cf267a5fd4a1464c7b3..8766455d8756ebdac09d36eea2c08db90c18b124 100644 Binary files a/lib/slf4j/slf4j-api.jar and b/lib/slf4j/slf4j-api.jar differ diff --git a/lib/slf4j/slf4j-api.pom b/lib/slf4j/slf4j-api.pom index 6e069f09a69a5d02e202eaed856c14d6c69ba69d..91928f155e53dacddf094b1e91b3f04f196689e4 100644 --- a/lib/slf4j/slf4j-api.pom +++ b/lib/slf4j/slf4j-api.pom @@ -3,7 +3,7 @@ <parent> <groupId>org.slf4j</groupId> <artifactId>slf4j-parent</artifactId> - <version>1.7.2</version> + <version>1.7.5</version> </parent> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> @@ -14,7 +14,7 @@ <url>http://www.qos.ch</url> </organization> <inceptionYear>2005</inceptionYear> - <!-- Copyright (c) 2004-2011 QOS.ch --> + <!-- Copyright (c) 2004-2013 QOS.ch --> <licenses> <license> <name>MIT License</name> diff --git a/plugins/android/build.xml b/plugins/android/build.xml index 784da804aece3f92d247bbd8450a10ea81eb6a68..18d38987f094a1a0a66c0dc2594d433ad6b92f56 100644 --- a/plugins/android/build.xml +++ b/plugins/android/build.xml @@ -70,6 +70,7 @@ <condition property="tempdir" value="${tempdir}" else="/tmp"> <isset property="tempdit"/> </condition> + <!-- two first jars seem useless --> <property name="jarclasspath" value="slf4j/jcl-over-slf4j.jar slf4j/log4j-over-slf4j.jar slf4j/slf4j-api.jar jena/jena.jar jena/iri.jar jena/icu4j.jar xerces/xercesImpl.jar xerces/resolver.jar align.jar microalign.jar"/> <tstamp><format locale="fr,fr" pattern="dd/MM/yyyy" property="date"/></tstamp> <exec executable="svnversion" outputproperty="svn.rev" failifexecutionfails="false"/> diff --git a/src/fr/inrialpes/exmo/align/cli/CommonCLI.java b/src/fr/inrialpes/exmo/align/cli/CommonCLI.java new file mode 100644 index 0000000000000000000000000000000000000000..442b46bfda96f4432b27d3930ddddec2832017dd --- /dev/null +++ b/src/fr/inrialpes/exmo/align/cli/CommonCLI.java @@ -0,0 +1,147 @@ +/* + * $Id$ + * + * Copyright (C) 2013 INRIA + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + */ + +/* + * Common command line parameter parsing based on Apache commons cli wrt + */ + +package fr.inrialpes.exmo.align.cli; + +import java.util.Properties; +import java.io.FileInputStream; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.CommandLineParser; +import org.apache.commons.cli.PosixParser; +//import org.apache.commons.cli.GnuParser; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.ParseException; +import org.apache.commons.cli.HelpFormatter; + +/** + * For instanciating this class: + * - extends CommonCLI + * - call to super() in constructor + * - add options in constructor + * - CommandLine line = parseCommandLine( args ); in main + * - retrieve new options + * - retrieve remaining args + * - redefine usage() with specific first line + * - use parameters + */ + +public abstract class CommonCLI { + final static Logger logger = LoggerFactory.getLogger( CommonCLI.class ); + + protected Options options = null; + + protected String outputfilename = null; + + protected Properties parameters = null; + + public CommonCLI() { + parameters = new Properties(); + options = new Options(); + options.addOption( "h", "help", false, "Print this page" ); + options.addOption( OptionBuilder.withLongOpt( "output" ).hasArg().withDescription( "Send output to FILE" ).withArgName("FILE").create( 'o' ) ); + options.addOption( OptionBuilder.withLongOpt( "debug" ).hasOptionalArg().withDescription( "debug argument is deprecated, use logging instead\nSee http://alignapi.gforge.inria.fr/logging.html" ).withArgName("LEVEL").create( 'd' ) ); + options.addOption( OptionBuilder.withLongOpt( "params" ).hasArg().withDescription( "Read parameters from FILE" ).withArgName("FILE").create( 'P' ) ); + options.addOption( OptionBuilder.withArgName( "NAME=VALUE" ).hasArgs(2).withValueSeparator().withDescription( "Use value for given property" ).create( 'D' ) ); + } + + // This is an example of using the interface + private void run( String[] args ) { + parseSpecificCommandLine( args ); + // Usually do process here + } + + // This is an example of processing the arguments + // In principle, use super. + public void parseSpecificCommandLine( String[] args ) { + try { + CommandLine line = parseCommandLine( args ); + if ( line == null ) return; + // Here deal with command specific arguments + for ( Object o : line.getArgList() ) { + logger.info( " Arg: {}", o ); + } + for ( String k : parameters.stringPropertyNames() ) { + logger.info( " Param: {} = {}", k, parameters.getProperty( k ) ); + } + } catch( ParseException exp ) { + logger.error( exp.getMessage() ); + usage(); + } + } + + // In spirit, this is final + public CommandLine parseCommandLine( String[] args ) throws ParseException { + CommandLineParser parser = new PosixParser(); + CommandLine line = parser.parse( options, args ); + parameters = line.getOptionProperties( "D" ); + if ( line.hasOption( 'd' ) ) { + logger.warn( "debug command-line switch DEPRECATED, use logging" ); + } + if ( line.hasOption( 'o' ) ) { + outputfilename = line.getOptionValue( 'o' ); + } + if ( line.hasOption( 'P' ) ) { + try { + String paramfile = line.getOptionValue( 'P' ); + parameters.loadFromXML( new FileInputStream( paramfile ) ); + } catch ( Exception ex ) { + logger.warn( "Cannot parse parameter file", ex ); + } + } + if ( line.hasOption( 'h' ) ) { + usage(); + line = null; + } + return line; + } + + public void exit( int returnCode ) { + System.exit( returnCode ); + } + + // This is an example of using the interface + public abstract void usage(); + + /* + * The subclasses may define usage() by calling this: + * usage( "java "+this.getClass().getName()+" [options] alignfile\nParse the given <alignfile> and prints it\nOptions:" ); + * In spirit, this is final + */ + public void usage( String firstlines ) { + usage( firstlines, "" ); + } + public void usage( String firstlines, String footer ) { + Package pkg = this.getClass().getPackage(); + String rfooter = footer; + if ( pkg != null ) + rfooter += "\n"+pkg.getImplementationTitle()+" "+pkg.getImplementationVersion(); + new HelpFormatter().printHelp( 80, firstlines, "\nOptions:", options, rfooter ); + } +} diff --git a/src/fr/inrialpes/exmo/align/cli/EvalAlign.java b/src/fr/inrialpes/exmo/align/cli/EvalAlign.java index 6e56ca008aee441e9cbac3677f37895faa1c02e1..45a5c4c931b0f8ad80831078bda5a2cc5d618921 100644 --- a/src/fr/inrialpes/exmo/align/cli/EvalAlign.java +++ b/src/fr/inrialpes/exmo/align/cli/EvalAlign.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2003-2008, 2010-2013 + * Copyright (C) INRIA, 2003-2008, 2010-2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -29,7 +29,6 @@ import fr.inrialpes.exmo.align.impl.eval.PRecEvaluator; import fr.inrialpes.exmo.align.impl.ObjectAlignment; import fr.inrialpes.exmo.align.impl.URIAlignment; -//Imported JAVA classes import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @@ -44,8 +43,13 @@ import java.io.BufferedWriter; import java.io.OutputStreamWriter; import java.lang.reflect.InvocationTargetException; -import gnu.getopt.LongOpt; -import gnu.getopt.Getopt; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.ParseException; /** A really simple utility that loads and alignment and prints it. A basic class for an OWL ontology alignment processing. The processor @@ -75,100 +79,62 @@ $Id$ @author Jérôme Euzenat */ -public class EvalAlign { +public class EvalAlign extends CommonCLI { + final static Logger logger = LoggerFactory.getLogger( EvalAlign.class ); - public static void main(String[] args) { - new EvalAlign().run( args ); + public EvalAlign() { + super(); + options.addOption( OptionBuilder.withLongOpt( "impl" ).hasArg().withDescription( "Use the given CLASS for evaluator" ).withArgName("CLASS").create( 'i' ) ); } + public static void main(String[] args) { + try { new EvalAlign().run( args ); } + catch ( Exception ex ) { ex.printStackTrace(); }; + } - public void run(String[] args) { - Properties params = new Properties(); + public void run(String[] args) throws Exception { Evaluator eval = null; String alignName1 = null; String alignName2 = null; - String filename = null; String classname = null; PrintWriter writer = null; - LongOpt[] longopts = new LongOpt[7]; - int debug = 0; - - // abcdefghijklmnopqrstuvwxyz? - // x x i x x x x x - longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); - longopts[1] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'); - longopts[2] = new LongOpt("debug", LongOpt.OPTIONAL_ARGUMENT, null, 'd'); - longopts[3] = new LongOpt("D", LongOpt.REQUIRED_ARGUMENT, null, 'D'); - longopts[4] = new LongOpt("impl", LongOpt.REQUIRED_ARGUMENT, null, 'i'); - - Getopt g = new Getopt("", args, "ho:d::i:D:", longopts); - int c; - String arg; - - while ((c = g.getopt()) != -1) { - switch(c) { - case 'h': - usage(); - return; - case 'o': - /* Output */ - filename = g.getOptarg(); - break; - case 'i': - /* Evaluator class */ - classname = g.getOptarg(); - break; - case 'd': - /* Debug level */ - arg = g.getOptarg(); - if ( arg != null ) debug = Integer.parseInt(arg.trim()); - else debug = 4; - break; - case 'D' : - /* Parameter definition */ - arg = g.getOptarg(); - int index = arg.indexOf('='); - if ( index != -1 ) { - params.setProperty( arg.substring( 0, index), - arg.substring(index+1)); - } else { - System.err.println("Bad parameter syntax: "+g); - usage(); - System.exit(0); - } - break; - } - } - - int i = g.getOptind(); + CommandLine line = null; - params.setProperty( "debug", Integer.toString( debug ) ); - // debug = Integer.parseInt( params.getProperty("debug") ); - - if (args.length > i+1 ) { - alignName1 = args[i]; - alignName2 = args[i+1]; + try { + line = parseCommandLine( args ); + if ( line == null ) return; // --help + } catch( ParseException exp ) { + logger.error( "Cannot parse command line", exp ); + usage(); + System.exit(-1); + } + if ( line.hasOption( 'i' ) ) classname = line.getOptionValue( 'i' ); + String[] argList = line.getArgs(); + if ( argList.length > 1 ) { + alignName1 = argList[0]; + alignName2 = argList[1]; } else { - System.err.println("Require two alignement filenames"); + logger.error( "Require the alignment URIs" ); usage(); - return; + System.exit(-1); } - if ( debug > 1 ) System.err.println(" Filename"+alignName1+"/"+alignName2); + logger.debug(" Filename: {}/{}", alignName1, alignName2); - Alignment align1=null, align2 = null; + Alignment align1 = null, align2 = null; try { // Load alignments - AlignmentParser aparser = new AlignmentParser( debug ); + AlignmentParser aparser = new AlignmentParser(); align1 = aparser.parse( alignName1 ); - if ( debug > 0 ) System.err.println(" Alignment structure1 parsed"); + //logger.trace(" Alignment structure1 parsed"); aparser.initAlignment( null ); align2 = aparser.parse( alignName2 ); - if ( debug > 0 ) System.err.println(" Alignment structure2 parsed"); - } catch ( Exception ex ) { ex.printStackTrace(); } + //logger.trace(" Alignment structure2 parsed"); + } catch ( Exception ex ) { + ex.printStackTrace(); + } - boolean totry = true; - try { + boolean totry = true; // 2013: This should not be necessary anymore while ( totry ) { totry = false; if ( classname != null ) { @@ -181,23 +147,23 @@ public class EvalAlign { java.lang.reflect.Constructor evaluatorConstructor = evaluatorClass.getConstructor(cparams); eval = (Evaluator)evaluatorConstructor.newInstance(mparams); } catch (ClassNotFoundException ex) { - ex.printStackTrace(); + logger.debug( "IGNORED Exception", ex ); } catch (InstantiationException ex) { - ex.printStackTrace(); + logger.debug( "IGNORED Exception", ex ); } catch (InvocationTargetException ex) { - ex.printStackTrace(); + logger.debug( "IGNORED Exception", ex ); } catch (IllegalAccessException ex) { - ex.printStackTrace(); + logger.debug( "IGNORED Exception", ex ); } catch (NoSuchMethodException ex) { - ex.printStackTrace(); + logger.error( "No such method: {}", classname ); usage(); - return; + throw( ex ); } } else { eval = new PRecEvaluator( align1, align2 ); }; // Compare try { - eval.eval(params) ; + eval.eval( parameters ) ; } catch ( AlignmentException aex ) { if ( align1 instanceof ObjectAlignment ) { throw aex; @@ -210,25 +176,24 @@ public class EvalAlign { } } } - } catch ( Exception ex ) { ex.printStackTrace(); } // Set output file try { OutputStream stream; - if (filename == null) { + if ( outputfilename == null ) { //writer = (PrintStream) System.out; stream = System.out; } else { //writer = new PrintStream(new FileOutputStream(filename)); - stream = new FileOutputStream(filename); + stream = new FileOutputStream( outputfilename ); } writer = new PrintWriter ( new BufferedWriter( new OutputStreamWriter( stream, "UTF-8" )), true); eval.write( writer ); } catch ( IOException ex ) { - ex.printStackTrace(); + logger.debug( "IGNORED Exception", ex ); } finally { writer.flush(); writer.close(); @@ -236,15 +201,6 @@ public class EvalAlign { } public void usage() { - System.err.println("usage: EvalAlign [options] file1 file2"); - System.err.println("options are:"); - System.err.println("\t--debug[=n] -d [n]\t\tReport debug info at level n"); - System.err.println("\t--impl=className -i classname\t\tUse the given evaluator implementation."); - System.err.println("\t--output=filename -o filename\tOutput the result in filename"); - System.err.println("\t-Dparam=value\t\t\tSet parameter"); - System.err.println("\t--help -h\t\t\tPrint this message"); - System.err.print("\n"+EvalAlign.class.getPackage().getImplementationTitle()+" "+EvalAlign.class.getPackage().getImplementationVersion()); - System.err.println(" ($Id$)\n"); - + usage( "java "+this.getClass().getName()+" [options] alignURI alignURI\nEvaluate two alignments identified by <alignURI>" ); } } diff --git a/src/fr/inrialpes/exmo/align/cli/ExtGroupEval.java b/src/fr/inrialpes/exmo/align/cli/ExtGroupEval.java index 200241aecc5dd9258dcdcf259862381d11bd1e62..5547dfdffff78507a37a7e12705b07c25dcf45c2 100644 --- a/src/fr/inrialpes/exmo/align/cli/ExtGroupEval.java +++ b/src/fr/inrialpes/exmo/align/cli/ExtGroupEval.java @@ -1,9 +1,7 @@ /* * $Id$ * - * Copyright (C) 2003 The University of Manchester - * Copyright (C) 2003 The University of Karlsruhe - * Copyright (C) 2003-2005, 2007-2012 INRIA + * Copyright (C) 2003-2005, 2007-2014 INRIA * Copyright (C) 2004, Université de Montréal * * This program is free software; you can redistribute it and/or @@ -52,8 +50,14 @@ import java.util.Properties; import org.xml.sax.SAXException; -import gnu.getopt.LongOpt; -import gnu.getopt.Getopt; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.Option; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.ParseException; /** A basic class for synthesizing the results of a set of alignments provided by different algorithms. The output is a table showing various generalisations @@ -68,7 +72,6 @@ import gnu.getopt.Getopt; <pre> -o filename --output=filename -f format = sepr (symetric/effort-based/precision-oriented/recall-oriented) --format=sepr - -d debug --debug=level -r filename --reference=filename -s algo/measure -l list of compared algorithms @@ -87,106 +90,64 @@ import gnu.getopt.Getopt; $Id$ </pre> -@author Sean K. Bechhofer -@author Jérôme Euzenat */ -public class ExtGroupEval { +public class ExtGroupEval extends CommonCLI { + final static Logger logger = LoggerFactory.getLogger( ExtGroupEval.class ); - Properties params = null; - String filename = null; String reference = "refalign.rdf"; String format = "s"; int fsize = 2; String type = "html"; boolean embedded = false; - String dominant = "s"; - Vector<String> listAlgo = null; - int debug = 0; + //String dominant = "s"; + String[] listAlgo = null; + int size = 0; String color = null; String ontoDir = null; + public ExtGroupEval() { + super(); + options.addOption( OptionBuilder.withLongOpt( "list" ).hasArgs().withValueSeparator(',').withDescription( "List of FILEs to be included in the results (required)" ).withArgName("FILE").create( 'l' ) ); + options.addOption( OptionBuilder.withLongOpt( "color" ).hasOptionalArg().withDescription( "Color even lines of the output in COLOR (default: lightblue)" ).withArgName("COLOR").create( 'c' ) ); + options.addOption( OptionBuilder.withLongOpt( "format" ).hasArg().withDescription( "Extended MEASures and order (symetric/effort-based/precision-oriented/recall-oriented) (default: "+format+")" ).withArgName("MEAS (sepr)").create( 'f' ) ); + //options.addOption( OptionBuilder.withLongOpt( "type" ).hasArg().withDescription( "Output TYPE (html|xml|tex|ascii|triangle; default: "+type+")" ).withArgName("TYPE").create( 't' ) ); + options.addOption( OptionBuilder.withLongOpt( "type" ).hasArg().withDescription( "Output TYPE (only html available so far)" ).withArgName("TYPE").create( 't' ) ); + //options.addOption( OptionBuilder.withLongOpt( "sup" ).hasArg().withDescription( "Are dominant columns algorithms or measure (default: s)" ).withArgName("algo").create( 's' ) ); + options.addOption( OptionBuilder.withLongOpt( "reference" ).hasArg().withDescription( "Name of the reference alignment FILE (default: "+reference+")" ).withArgName("FILE").create( 'r' ) ); + options.addOption( OptionBuilder.withLongOpt( "directory" ).hasOptionalArg().withDescription( "The DIRectory containing the data to evaluate" ).withArgName("DIR").create( 'w' ) ); + // .setRequired( true ) + Option opt = options.getOption( "list" ); + if ( opt != null ) opt.setRequired( true ); + } + public static void main(String[] args) { try { new ExtGroupEval().run( args ); } catch (Exception ex) { ex.printStackTrace(); }; } public void run(String[] args) throws Exception { - String listFile = ""; - LongOpt[] longopts = new LongOpt[10]; - - longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); - longopts[1] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'); - longopts[2] = new LongOpt("format", LongOpt.REQUIRED_ARGUMENT, null, 'f'); - longopts[3] = new LongOpt("type", LongOpt.REQUIRED_ARGUMENT, null, 't'); - longopts[4] = new LongOpt("debug", LongOpt.OPTIONAL_ARGUMENT, null, 'd'); - longopts[5] = new LongOpt("sup", LongOpt.REQUIRED_ARGUMENT, null, 's'); - longopts[6] = new LongOpt("list", LongOpt.REQUIRED_ARGUMENT, null, 'l'); - longopts[7] = new LongOpt("color", LongOpt.OPTIONAL_ARGUMENT, null, 'c'); - longopts[8] = new LongOpt("reference", LongOpt.REQUIRED_ARGUMENT, null, 'r'); - longopts[9] = new LongOpt("directory", LongOpt.REQUIRED_ARGUMENT, null, 'w'); + try { + CommandLine line = parseCommandLine( args ); + if ( line == null ) return; // --help - Getopt g = new Getopt("", args, "ho:a:d::l:f:t:r:w:c::", longopts); - int c; - String arg; - - while ((c = g.getopt()) != -1) { - switch (c) { - case 'h' : - usage(); - return; - case 'o' : - /* Write output here */ - filename = g.getOptarg(); - break; - case 'r' : - /* File name for the reference alignment */ - reference = g.getOptarg(); - break; - case 'f' : - /* Sequence of results to print */ - format = g.getOptarg(); - break; - case 't' : - /* Type of output (tex/html/xml/ascii) */ - type = g.getOptarg(); - break; - case 's' : - /* Print per type or per algo */ - dominant = g.getOptarg(); - break; - case 'c' : - /* Print colored lines */ - color = "lightblue"; - //dominant = g.getOptarg(); - break; - case 'l' : - /* List of filename */ - listFile = g.getOptarg(); - break; - case 'd' : - /* Debug level */ - arg = g.getOptarg(); - if ( arg != null ) debug = Integer.parseInt(arg.trim()); - else debug = 4; - break; - case 'w' : - /* Use the given ontology directory */ - arg = g.getOptarg(); - if ( arg != null ) ontoDir = g.getOptarg(); - else ontoDir = null; - break; + // Here deal with command specific arguments + if ( line.hasOption( 'f' ) ) format = line.getOptionValue( 'f' ); + if ( line.hasOption( 'r' ) ) reference = line.getOptionValue( 'r' ); + //if ( line.hasOption( 's' ) ) dominant = line.getOptionValue( 's' ); + if ( line.hasOption( 't' ) ) type = line.getOptionValue( 't' ); + if ( line.hasOption( 'c' ) ) color = line.getOptionValue( 'c', "lightblue" ); + if ( line.hasOption( 'l' ) ) { + listAlgo = line.getOptionValues( 'l' ); + size = listAlgo.length; } + if ( line.hasOption( 'w' ) ) ontoDir = line.getOptionValue( 'w' ); + } catch( ParseException exp ) { + logger.error( exp.getMessage() ); + usage(); + System.exit( -1 ); } - listAlgo = new Vector<String>(); - for ( String s : listFile.split(",") ) { - listAlgo.add( s ); - } - - params = new Properties(); - if (debug > 0) params.setProperty( "debug", Integer.toString( debug-1 ) ); - print( iterateDirectories() ); } @@ -200,7 +161,7 @@ public class ExtGroupEval { subdir = (new File(ontoDir)).listFiles(); } } catch (Exception e) { - System.err.println("Cannot stat dir "+ e.getMessage()); + logger.error("Cannot stat dir", e); usage(); } int size = subdir.length; @@ -209,7 +170,7 @@ public class ExtGroupEval { int i = 0; for ( int j=0 ; j < size; j++ ) { if( subdir[j].isDirectory() ) { - if ( debug > 0 ) System.err.println("\nEntering directory "+subdir[j]); + //logger.trace("Entering directory {}", subdir[j]); // eval the alignments in a subdirectory // store the result Vector vect = (Vector)iterateAlignments( subdir[j] ); @@ -234,7 +195,7 @@ public class ExtGroupEval { // call eval // store the result in a record // return the record. - if ( debug > 1) System.err.println(" Considering result "+i); + //logger.trace(" Considering result {}", i); Evaluator evaluator = eval( prefix+reference, prefix+m+".rdf"); if ( evaluator != null ) ok = true; result.add( i, evaluator ); @@ -242,8 +203,8 @@ public class ExtGroupEval { // Unload the ontologies. try { OntologyFactory.clear(); - } catch ( OntowrapException owex ) { // only report - owex.printStackTrace(); + } catch ( OntowrapException owex ) { + logger.debug( "INGORED Exception", owex ); } if ( ok == true ) return result; @@ -253,29 +214,20 @@ public class ExtGroupEval { public Evaluator eval( String alignName1, String alignName2 ) { Evaluator eval = null; try { - int nextdebug; - if ( debug < 2 ) nextdebug = 0; - else nextdebug = debug - 2; // Load alignments - AlignmentParser aparser = new AlignmentParser( nextdebug ); + AlignmentParser aparser = new AlignmentParser(); Alignment align1 = aparser.parse( alignName1 ); - if ( debug > 1 ) System.err.println(" Alignment structure1 parsed"); + //logger.trace(" Alignment structure1 parsed"); aparser.initAlignment( null ); Alignment align2 = aparser.parse( alignName2 ); - if ( debug > 1 ) System.err.println(" Alignment structure2 parsed"); + //logger.trace(" Alignment structure2 parsed"); // Create evaluator object eval = new ExtPREvaluator(ObjectAlignment.toObjectAlignment( (URIAlignment)align1 ), ObjectAlignment.toObjectAlignment( (URIAlignment)align2 ) ); // Compare - params.setProperty( "debug", Integer.toString( nextdebug ) ); - eval.eval( params ) ; + eval.eval( parameters ) ; } catch (Exception ex) { - if ( debug > 1 ) { - ex.printStackTrace(); - } else { - System.err.println("ExtGroupEval: "+ex); - System.err.println(alignName1+ " - "+alignName2 ); - } + logger.debug( "IGNORED Extension", ex ); }; return eval; } @@ -284,6 +236,23 @@ public class ExtGroupEval { * This does not only print the results but compute the average as well */ public void print( Vector<Vector> result ) { + PrintStream writer = null; + try { + if ( outputfilename == null ) { + writer = System.out; + } else { + writer = new PrintStream( new FileOutputStream( outputfilename ) ); + } + + printHTML( result, writer ); + } catch (Exception ex) { + logger.debug( "IGNORED Exception", ex ); + } finally { + writer.close(); + } + } + + public void printHTML( Vector<Vector> result, PrintStream writer ) { // variables for computing iterative harmonic means int expected = 0; // expected so far int foundVect[]; // found so far @@ -291,17 +260,10 @@ public class ExtGroupEval { double effVect[]; // effort-based similarity double precOrVect[]; // precision-oriented similarity double recOrVect[]; // recall-oriented similarity - PrintStream writer = null; fsize = format.length(); try { - // Print result - if ( filename == null ) { - writer = System.out; - } else { - writer = new PrintStream(new FileOutputStream( filename )); - } - Formatter formatter = new Formatter(writer); + Formatter formatter = new Formatter( writer ); // Print the header writer.println("<html><head></head><body>"); writer.println("<table border='2' frame='sides' rules='groups'>"); @@ -333,12 +295,12 @@ public class ExtGroupEval { //writer.println("<td>Prec.</td><td>Rec.</td>"); } writer.println("</tr></tbody><tbody>"); - foundVect = new int[ listAlgo.size() ]; - symVect = new double[ listAlgo.size() ]; - effVect = new double[ listAlgo.size() ]; - precOrVect = new double[ listAlgo.size() ]; - recOrVect = new double[ listAlgo.size() ]; - for( int k = listAlgo.size()-1; k >= 0; k-- ) { + foundVect = new int[ size ]; + symVect = new double[ size ]; + effVect = new double[ size ]; + precOrVect = new double[ size ]; + recOrVect = new double[ size ]; + for( int k = size-1; k >= 0; k-- ) { foundVect[k] = 0; symVect[k] = 0.; effVect[k] = 0.; @@ -376,29 +338,29 @@ public class ExtGroupEval { writer.print("<td>"); if ( format.charAt(i) == 's' ) { formatter.format("%1.2f", eval.getSymPrecision()); - System.out.print("</td><td>"); + writer.print("</td><td>"); formatter.format("%1.2f", eval.getSymRecall()); symVect[k] += eval.getSymSimilarity(); } else if ( format.charAt(i) == 'e' ) { formatter.format("%1.2f", eval.getEffPrecision()); - System.out.print("</td><td>"); + writer.print("</td><td>"); formatter.format("%1.2f", eval.getEffRecall()); effVect[k] += eval.getEffSimilarity(); } else if ( format.charAt(i) == 'p' ) { formatter.format("%1.2f", eval.getPrecisionOrientedPrecision()); - System.out.print("</td><td>"); + writer.print("</td><td>"); formatter.format("%1.2f", eval.getPrecisionOrientedRecall()); precOrVect[k] += eval.getPrecisionOrientedSimilarity(); } else if ( format.charAt(i) == 'r' ) { formatter.format("%1.2f", eval.getRecallOrientedPrecision()); - System.out.print("</td><td>"); + writer.print("</td><td>"); formatter.format("%1.2f", eval.getRecallOrientedRecall()); recOrVect[k] += eval.getRecallOrientedSimilarity(); } - writer.println("</td>"); + writer.print("</td>"); } } else { - writer.println("<td>n/a</td><td>n/a</td>"); + for ( int i = 0 ; i < fsize; i++) writer.print("<td>n/a</td>"); } } writer.println("</tr>"); @@ -411,19 +373,19 @@ public class ExtGroupEval { writer.print("<td>"); if ( format.charAt(i) == 's' ) { formatter.format("%1.2f", symVect[k]/foundVect[k]); - System.out.print("</td><td>"); + writer.print("</td><td>"); formatter.format("%1.2f", symVect[k]/expected); } else if ( format.charAt(i) == 'e' ) { formatter.format("%1.2f", effVect[k]/foundVect[k]); - System.out.print("</td><td>"); + writer.print("</td><td>"); formatter.format("%1.2f", effVect[k]/expected); } else if ( format.charAt(i) == 'p' ) { formatter.format("%1.2f", precOrVect[k]/foundVect[k]); - System.out.print("</td><td>"); + writer.print("</td><td>"); formatter.format("%1.2f", precOrVect[k]/expected); } else if ( format.charAt(i) == 'r' ) { formatter.format("%1.2f", recOrVect[k]/foundVect[k]); - System.out.print("</td><td>"); + writer.print("</td><td>"); formatter.format("%1.2f", recOrVect[k]/expected); } writer.println("</td>"); @@ -440,7 +402,7 @@ public class ExtGroupEval { writer.println("NaN: division per zero, likely due to empty alignent.</small></p>"); writer.println("</body></html>"); } catch (Exception ex) { - ex.printStackTrace(); + logger.debug( "IGNORED Exception", ex ); } finally { writer.flush(); writer.close(); @@ -448,19 +410,6 @@ public class ExtGroupEval { } public void usage() { - System.out.println("usage: ExtGroupEval [options]"); - System.out.println("options are:"); - System.out.println("\t--format=sepr -f sepr\tSpecifies the extended measures used (symetric/effort-based/precision-oriented/recall-oriented)"); - System.out.println("\t--reference=filename -r filename\tSpecifies the name of the reference alignment file (default: refalign.rdf)"); - System.out.println("\t--output=filename -o filename\tSpecifies a file to which the output will go"); - // Apparently not implemented - //System.out.println("\t--dominant=algo -s algo\tSpecifies if dominant columns are algorithms or measure"); - System.out.println("\t--type=html|xml|tex|ascii -t html|xml|tex|ascii\tSpecifies the output format"); - System.out.println("\t--list=algo1,...,algon -l algo1,...,algon\tSequence of the filenames to consider"); - System.out.println("\t--color=color -c color\tSpecifies if the output must color even lines of the output"); - System.out.println("\t--debug[=n] -d [n]\t\tReport debug info at level n"); - System.out.println("\t--help -h\t\t\tPrint this message"); - System.err.print("\n"+ExtGroupEval.class.getPackage().getImplementationTitle()+" "+ExtGroupEval.class.getPackage().getImplementationVersion()); - System.err.println(" ($Id$)\n"); + usage( "java "+this.getClass().getName()+" [options]\nEvaluates (with extended evaluators) in parallel several matching results on several tests in subdirectories" ); } } diff --git a/src/fr/inrialpes/exmo/align/cli/GenPlot.java b/src/fr/inrialpes/exmo/align/cli/GenPlot.java index 9d82165c5da9435175c30b4781d2d61aadedfb55..f2a92e13a364f2089104902c63531786aac81a6e 100644 --- a/src/fr/inrialpes/exmo/align/cli/GenPlot.java +++ b/src/fr/inrialpes/exmo/align/cli/GenPlot.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2003-2012, INRIA + * Copyright (C) 2003-2014, INRIA * Copyright (C) 2004, Université de Montréal * * This program is free software; you can redistribute it and/or @@ -51,8 +51,14 @@ import java.lang.InstantiationException; import org.xml.sax.SAXException; -import gnu.getopt.LongOpt; -import gnu.getopt.Getopt; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.Option; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.ParseException; import fr.inrialpes.exmo.align.parser.AlignmentParser; @@ -71,7 +77,6 @@ import fr.inrialpes.exmo.align.parser.AlignmentParser; * where the options are: * <pre> * -o filename --output=filename - * -d debug --debug=level * -l list of compared algorithms * -t output --type=output: xml/tex/html/ascii * -e classname --evaluator=classname @@ -93,22 +98,33 @@ import fr.inrialpes.exmo.align.parser.AlignmentParser; * @author Jérôme Euzenat */ -public class GenPlot { +public class GenPlot extends CommonCLI { + final static Logger logger = LoggerFactory.getLogger( GenPlot.class ); int STEP = 10; - Properties params = new Properties(); - Vector<String> listAlgo; + String[] listAlgo = null; Vector<GraphEvaluator> listEvaluators; String fileNames = ""; - String outFile = null; Constructor evalConstructor = null; Constructor graphConstructor = null; String xlabel; String ylabel; - String type = "tsv"; - int debug = 0; + String type = "tex"; int size = 0; // the set of algo to compare - PrintWriter output = null; + String ontoDir = null; + + public GenPlot() { + super(); + options.addOption( OptionBuilder.withLongOpt( "list" ).hasArgs().withValueSeparator(',').withDescription( "List of FILEs to be included in the results (required)" ).withArgName("FILE").create( 'l' ) ); + options.addOption( OptionBuilder.withLongOpt( "type" ).hasArg().withDescription( "Output in the specified FORMAT (values" ).withArgName("tsv|tex|html(|xml)").create( 't' ) ); + options.addOption( OptionBuilder.withLongOpt( "evaluator" ).hasArg().withDescription( "Use CLASS as evaluation plotter" ).withArgName("CLASS").create( 'e' ) ); + options.addOption( OptionBuilder.withLongOpt( "grapher" ).hasArg().withDescription( "Use CLASS as graph generator" ).withArgName("CLASS").create( 'g' ) ); + //options.addOption( OptionBuilder.withLongOpt( "step" ).hasArg().withDescription( "" ).withArgName("").create( 's' ) ); + options.addOption( OptionBuilder.withLongOpt( "directory" ).hasOptionalArg().withDescription( "The DIRectory containing the data to match" ).withArgName("DIR").create( 'w' ) ); + // .setRequired( true ) + Option opt = options.getOption( "list" ); + if ( opt != null ) opt.setRequired( true ); + } public static void main(String[] args) { try { new GenPlot().run( args ); } @@ -116,74 +132,26 @@ public class GenPlot { } public void run(String[] args) throws Exception { - LongOpt[] longopts = new LongOpt[10]; - - longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); - longopts[1] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'); - longopts[3] = new LongOpt("type", LongOpt.REQUIRED_ARGUMENT, null, 't'); - longopts[4] = new LongOpt("debug", LongOpt.OPTIONAL_ARGUMENT, null, 'd'); - longopts[5] = new LongOpt("evaluator", LongOpt.REQUIRED_ARGUMENT, null, 'e'); - longopts[6] = new LongOpt("grapher", LongOpt.REQUIRED_ARGUMENT, null, 'g'); - longopts[7] = new LongOpt("list", LongOpt.REQUIRED_ARGUMENT, null, 'l'); - longopts[8] = new LongOpt("step", LongOpt.REQUIRED_ARGUMENT, null, 's'); - longopts[9] = new LongOpt("D", LongOpt.REQUIRED_ARGUMENT, null, 'D'); - - Getopt g = new Getopt("", args, "ho:d::l:D:e:g:s:t:", longopts); - int step = 10; - int c; - String arg; String evalCN = "fr.inrialpes.exmo.align.impl.eval.PRecEvaluator"; String graphCN = "fr.inrialpes.exmo.align.impl.eval.PRGraphEvaluator"; - while ((c = g.getopt()) != -1) { - switch (c) { - case 'h' : - usage(); - return; - case 'o' : - /* Write output here */ - outFile = g.getOptarg(); - break; - case 'e' : - /* Name of the evaluator to use */ - evalCN = g.getOptarg(); - break; - case 'g' : - /* Name of the graph display to use */ - graphCN = g.getOptarg(); - break; - case 't' : - /* Type of output (tex/tsv(/html/xml/ascii)) */ - type = g.getOptarg(); - break; - case 'l' : - /* List of filename */ - fileNames = g.getOptarg(); - break; - //case 's' : - /* Step */ - //fileNames = g.getOptarg(); - //break; - case 'd' : - /* Debug level */ - arg = g.getOptarg(); - if ( arg != null ) debug = Integer.parseInt(arg.trim()); - else debug = 4; - break; - case 'D' : - /* Parameter definition */ - arg = g.getOptarg(); - int index = arg.indexOf('='); - if ( index != -1 ) { - params.setProperty( arg.substring( 0, index), - arg.substring(index+1)); - } else { - System.err.println("Bad parameter syntax: "+g); - usage(); - System.exit(0); - } - break; + try { + CommandLine line = parseCommandLine( args ); + if ( line == null ) return; // --help + + // Here deal with command specific arguments + if ( line.hasOption( 'e' ) ) evalCN = line.getOptionValue( 'e' ); + if ( line.hasOption( 'g' ) ) graphCN = line.getOptionValue( 'g' ); + if ( line.hasOption( 't' ) ) type = line.getOptionValue( 't' ); + if ( line.hasOption( 'l' ) ) { + listAlgo = line.getOptionValues( 'l' ); + size = listAlgo.length; } + if ( line.hasOption( 'w' ) ) ontoDir = line.getOptionValue( 'w' ); + } catch( ParseException exp ) { + logger.error( exp.getMessage() ); + usage(); + System.exit(-1); } Class<?> graphClass = Class.forName(graphCN); @@ -193,14 +161,6 @@ public class GenPlot { //Class<?> evalClass = Class.forName(evalCN); //evalConstructor = evalClass.getConstructor( cparams ); - listAlgo = new Vector<String>(); - for ( String s : fileNames.split(",") ) { - size++; - listAlgo.add( s ); - } - - if (debug > 0) params.setProperty( "debug", Integer.toString( debug-1 ) ); - // Collect correspondences from alignments in all directories // . -> Vector<EvalCell> listEvaluators = iterateDirectories(); @@ -211,7 +171,7 @@ public class GenPlot { int n = e.nbCells(); if ( n > max ) max = n; } - params.setProperty( "scale", Integer.toString( max ) ); + parameters.setProperty( "scale", Integer.toString( max ) ); xlabel = listEvaluators.get(0).xlabel(); ylabel = listEvaluators.get(0).ylabel(); @@ -223,18 +183,18 @@ public class GenPlot { for( int i = 0; i < size ; i++ ) { // Convert it with the adequate GraphPlotter // Scale the point pairs to the current display (local) - toplot.add( i, listEvaluators.get(i).eval( params ) ); + toplot.add( i, listEvaluators.get(i).eval( parameters ) ); //scaleResults( STEP, } // Set output file OutputStream stream; - if (outFile == null) { + if ( outputfilename == null) { stream = System.out; } else { - stream = new FileOutputStream(outFile); + stream = new FileOutputStream( outputfilename ); } - output = new PrintWriter ( + PrintWriter writer = new PrintWriter ( new BufferedWriter( new OutputStreamWriter( stream, "UTF-8" )), true); @@ -242,12 +202,16 @@ public class GenPlot { // Display the required type of output // Vector<Pair> -> . if ( type.equals("tsv") ){ - printTSV( toplot ); + printTSV( toplot, writer ); } else if ( type.equals("html") ) { - printHTMLGGraph( toplot ); + printHTMLGGraph( toplot, writer ); } else if ( type.equals("tex") ) { - printPGFTex( toplot ); - } else System.err.println("Flag -t "+type+" : not implemented yet"); + printPGFTex( toplot, writer ); + } else { + logger.error( "Flag -t {} : not implemented yet", type ); + usage(); + System.exit(-1); + } } /** @@ -265,17 +229,22 @@ public class GenPlot { ev.setStep( STEP ); evaluators.add( i, ev ); } - } catch (Exception ex) { //InstantiationException, IllegalAccessException - ex.printStackTrace(); + } catch ( Exception ex ) { //InstantiationException, IllegalAccessException + logger.error( "FATAL Exception", ex ); System.exit(-1); } File [] subdir = null; try { - subdir = (new File(System.getProperty("user.dir"))).listFiles(); - } catch (Exception e) { - System.err.println("Cannot stat dir "+ e.getMessage()); + if (ontoDir == null) { + subdir = (new File(System.getProperty("user.dir"))).listFiles(); + } else { + subdir = (new File(ontoDir)).listFiles(); + } + } catch ( Exception e ) { + logger.error( "Cannot stat dir", e ); usage(); + System.exit(-1); } // Evaluate the results in each directory @@ -289,42 +258,31 @@ public class GenPlot { } public void iterateAlignments ( File dir, Vector<GraphEvaluator> evaluators ) { - if ( debug > 0 ) System.err.println("Directory : "+dir); + //logger.trace( "Directory : {}", dir ); String prefix = dir.toURI().toString()+"/"; - int nextdebug; - if ( debug < 2 ) nextdebug = 0; - else nextdebug = debug - 2; - AlignmentParser aparser = new AlignmentParser( nextdebug ); + AlignmentParser aparser = new AlignmentParser(); Alignment refalign = null; try { // Load the reference alignment... refalign = aparser.parse( prefix+"refalign.rdf" ); - if ( debug > 1 ) System.err.println(" Reference alignment parsed"); + //logger.trace(" Reference alignment parsed"); } catch ( Exception aex ) { - if ( debug > 1 ) { - aex.printStackTrace(); - } else { - System.err.println("GenPlot cannot parse refalign : "+aex); - }; - return; + logger.error( "GenPlot cannot parse refalign", aex ); + System.exit(-1); } // for all alignments there, for( int i = 0; i < size; i++ ) { - String algo = listAlgo.get(i); + String algo = listAlgo[i]; Alignment al = null; - if ( debug > 0 ) System.err.println(" Considering result "+algo+" ("+i+")"); + //logger.trace(" Considering result {} ({})", algo, i ); try { aparser.initAlignment( null ); al = aparser.parse( prefix+algo+".rdf" ); - if ( debug > 1 ) System.err.println(" Alignment "+algo+" parsed"); - } catch (Exception ex) { - if ( debug > 1 ) { - ex.printStackTrace(); - } else { - System.err.println("GenPlot: "+ex); - }; + //logger.trace(" Alignment {} parsed", algo ); + } catch ( Exception ex ) { + logger.error( "IGNORED Exception", ex ); } // even if empty, declare refalign evaluators.get(i).ingest( al, refalign ); @@ -333,7 +291,7 @@ public class GenPlot { try { OntologyFactory.clear(); } catch ( OntowrapException owex ) { // only report - owex.printStackTrace(); + logger.error( "IGNORED Exception", owex ); } } @@ -370,86 +328,86 @@ public class GenPlot { * This does average plus plot * */ - public void printPGFTex( Vector<Vector<Pair>> result ){ + public void printPGFTex( Vector<Vector<Pair>> result, PrintWriter writer ){ int i = 0; String marktable[] = { "+", "*", "x", "-", "|", "o", "asterisk", "star", "oplus", "oplus*", "otimes", "otimes*", "square", "square*", "triangle", "triangle*", "diamond", "diamond*", "pentagon", "pentagon*"}; String colortable[] = { "black", "red", "green!50!black", "blue", "cyan", "magenta" } ; - output.println("\\documentclass[11pt]{book}"); - output.println(); - output.println("\\usepackage{pgf}"); - output.println("\\usepackage{tikz}"); - output.println("\\usetikzlibrary{plotmarks}"); - output.println(); - output.println("\\begin{document}"); - output.println("\\date{today}"); - output.println(""); - output.println("\n%% Plot generated by GenPlot of alignapi"); - output.println("\\begin{tikzpicture}[cap=round]"); - output.println("% Draw grid"); - output.println("\\draw[step="+(STEP/10)+"cm,very thin,color=gray] (-0.2,-0.2) grid ("+STEP+","+STEP+");"); - output.println("\\draw[->] (-0.2,0) -- (10.2,0);"); - output.println("\\draw (5,-0.3) node {$"+xlabel+"$}; "); - output.println("\\draw (0,-0.3) node {0.}; "); - output.println("\\draw (10,-0.3) node {1.}; "); - output.println("\\draw[->] (0,-0.2) -- (0,10.2);"); - output.println("\\draw (-0.3,0) node {0.}; "); - output.println("\\draw (-0.3,5) node[rotate=90] {$"+ylabel+"$}; "); - output.println("\\draw (-0.3,10) node {1.}; "); - output.println("% Plots"); + writer.println("\\documentclass[11pt]{book}"); + writer.println(); + writer.println("\\usepackage{pgf}"); + writer.println("\\usepackage{tikz}"); + writer.println("\\usetikzlibrary{plotmarks}"); + writer.println(); + writer.println("\\begin{document}"); + writer.println("\\date{today}"); + writer.println(""); + writer.println("\n%% Plot generated by GenPlot of alignapi"); + writer.println("\\begin{tikzpicture}[cap=round]"); + writer.println("% Draw grid"); + writer.println("\\draw[step="+(STEP/10)+"cm,very thin,color=gray] (-0.2,-0.2) grid ("+STEP+","+STEP+");"); + writer.println("\\draw[->] (-0.2,0) -- (10.2,0);"); + writer.println("\\draw (5,-0.3) node {$"+xlabel+"$}; "); + writer.println("\\draw (0,-0.3) node {0.}; "); + writer.println("\\draw (10,-0.3) node {1.}; "); + writer.println("\\draw[->] (0,-0.2) -- (0,10.2);"); + writer.println("\\draw (-0.3,0) node {0.}; "); + writer.println("\\draw (-0.3,5) node[rotate=90] {$"+ylabel+"$}; "); + writer.println("\\draw (-0.3,10) node {1.}; "); + writer.println("% Plots"); i = 0; for ( String m : listAlgo ) { - output.print("\\draw["+colortable[i%6] ); - if ( !listEvaluators.get(i).isValid() ) output.print(",dotted"); - output.println("] plot[mark="+marktable[i%19]+"] file {"+m+".table};"); + writer.print("\\draw["+colortable[i%6] ); + if ( !listEvaluators.get(i).isValid() ) writer.print(",dotted"); + writer.println("] plot[mark="+marktable[i%19]+"] file {"+m+".table};"); //,smooth i++; } // And a legend - output.println("% Legend"); + writer.println("% Legend"); i = 0; for ( String m : listAlgo ) { - output.print("\\draw["+colortable[i%6] ); - if ( !listEvaluators.get(i).isValid() ) output.print(",dotted"); - output.println("] plot[mark="+marktable[i%19]+"] coordinates {("+((i%3)*3+1)+","+(-(i/3)*.8-1)+") ("+((i%3)*3+3)+","+(-(i/3)*.8-1)+")};"); + writer.print("\\draw["+colortable[i%6] ); + if ( !listEvaluators.get(i).isValid() ) writer.print(",dotted"); + writer.println("] plot[mark="+marktable[i%19]+"] coordinates {("+((i%3)*3+1)+","+(-(i/3)*.8-1)+") ("+((i%3)*3+3)+","+(-(i/3)*.8-1)+")};"); //,smooth - output.println("\\draw["+colortable[i%6]+"] ("+((i%3)*3+2)+","+(-(i/3)*.8-.8)+") node {"+m+"};"); - output.printf("\\draw["+colortable[i%6]+"] ("+((i%3)*3+2)+","+(-(i/3)*.8-1.2)+") node {%1.2f};\n", listEvaluators.get(i).getGlobalResult() ); + writer.println("\\draw["+colortable[i%6]+"] ("+((i%3)*3+2)+","+(-(i/3)*.8-.8)+") node {"+m+"};"); + writer.printf("\\draw["+colortable[i%6]+"] ("+((i%3)*3+2)+","+(-(i/3)*.8-1.2)+") node {%1.2f};\n", listEvaluators.get(i).getGlobalResult() ); i++; } - output.println("\\end{tikzpicture}"); - output.println(); - output.println("\\end{document}"); + writer.println("\\end{tikzpicture}"); + writer.println(); + writer.println("\\end{document}"); i = 0; for( Vector<Pair> table : result ) { - String algo = listAlgo.get(i); + String algo = listAlgo[i]; // Open one file - PrintWriter writer = null; + PrintWriter auxwriter = null; try { - writer = new PrintWriter ( + auxwriter = new PrintWriter ( new BufferedWriter( new OutputStreamWriter( new FileOutputStream(algo+".table"), "UTF-8" )), true); // Print header - writer.println("#Curve 0, "+(STEP+1)+" points"); - writer.println("#x y type"); - writer.println("%% Plot generated by GenPlot of alignapi"); - writer.println("%% Include in PGF tex by:\n"); - writer.println("%% \\begin{tikzpicture}[cap=round]"); - writer.println("%% \\draw[step="+(STEP/10)+"cm,very thin,color=gray] (-0.2,-0.2) grid ("+STEP+","+STEP+");"); - writer.println("%% \\draw[->] (-0.2,0) -- (10.2,0) node[right] {$"+xlabel+"$}; "); - writer.println("%% \\draw[->] (0,-0.2) -- (0,10.2) node[above] {$"+ylabel+"$}; "); - writer.println("%% \\draw plot[mark=+,smooth] file {"+algo+".table};"); - writer.println("%% \\end{tikzpicture}"); - writer.println(); + auxwriter.println("#Curve 0, "+(STEP+1)+" points"); + auxwriter.println("#x y type"); + auxwriter.println("%% Plot generated by GenPlot of alignapi"); + auxwriter.println("%% Include in PGF tex by:\n"); + auxwriter.println("%% \\begin{tikzpicture}[cap=round]"); + auxwriter.println("%% \\draw[step="+(STEP/10)+"cm,very thin,color=gray] (-0.2,-0.2) grid ("+STEP+","+STEP+");"); + auxwriter.println("%% \\draw[->] (-0.2,0) -- (10.2,0) node[right] {$"+xlabel+"$}; "); + auxwriter.println("%% \\draw[->] (0,-0.2) -- (0,10.2) node[above] {$"+ylabel+"$}; "); + auxwriter.println("%% \\draw plot[mark=+,smooth] file {"+algo+".table};"); + auxwriter.println("%% \\end{tikzpicture}"); + auxwriter.println(); for( Pair p : table ) { - if ( debug > 1 ) System.err.println( " >> "+p.getX()+" - "+p.getY() ); - writer.println( p.getX()*10+" "+ p.getY()*10 ); + //logger.trace( " >> {} - {}", p.getX(), p.getY() ); + auxwriter.println( p.getX()*10+" "+ p.getY()*10 ); } - } catch (Exception ex) { - ex.printStackTrace(); + } catch ( Exception ex ) { + logger.error( "IGNORED Exception", ex ); } finally { - if ( writer != null ) writer.close(); + if ( auxwriter != null ) auxwriter.close(); } // UnsupportedEncodingException + FileNotFoundException i++; @@ -460,30 +418,30 @@ public class GenPlot { * This does average plus generate the call for Google Chart API * */ - public void printHTMLGGraph( Vector<Vector<Pair>> result ){ - output.print("<img src=\"http://chart.apis.google.com/chart?"); - output.print("chs=600x500&cht=lxy&chg=10,10&chof=png"); - output.print("&chxt=x,x,y,y&chxr=0,0.0,1.0,0.1|2,0.0,1.0,0.1&chxl=1:|"+xlabel+"|3:|"+ylabel+"&chma=b&chxp=1,50|3,50&chxs=0N*sz1*|2N*sz1*"); - output.print("&chd=t:"); // data + public void printHTMLGGraph( Vector<Vector<Pair>> result, PrintWriter writer ){ + writer.print("<img src=\"http://chart.apis.google.com/chart?"); + writer.print("chs=600x500&cht=lxy&chg=10,10&chof=png"); + writer.print("&chxt=x,x,y,y&chxr=0,0.0,1.0,0.1|2,0.0,1.0,0.1&chxl=1:|"+xlabel+"|3:|"+ylabel+"&chma=b&chxp=1,50|3,50&chxs=0N*sz1*|2N*sz1*"); + writer.print("&chd=t:"); // data boolean firstalg = true; for( Vector<Pair> table : result ) { - if ( !firstalg ) output.print("|"); + if ( !firstalg ) writer.print("|"); firstalg = false; boolean firstpoint = true; String Yval = "|"; for( Pair p : table ) { if ( !firstpoint ) { - output.print(","); + writer.print(","); Yval += ","; } firstpoint = false; Yval += String.format("%1.2f", p.getY()*10); - if ( debug > 1 ) System.err.println( " >> "+p.getX()+" - "+p.getY() ); - output.printf( "%1.2f", p.getX()*10 ); + //logger.trace( " >> {} - {}", p.getX(), p.getY() ); + writer.printf( "%1.2f", p.getX()*10 ); } - output.print( Yval ); + writer.print( Yval ); } - output.print("&chdl="); // labels + writer.print("&chdl="); // labels int i = 0; //String marktable[] = { "+", "*", "x", "-", "|", "o", "asterisk", "star", "oplus", "oplus*", "otimes", "otimes*", "square", "square*", "triangle", "triangle*", "diamond", "diamond*", "pentagon", "pentagon*"}; //String colortable[] = { "black", "red", "green!50!black", "blue", "cyan", "magenta" }; @@ -492,11 +450,11 @@ public class GenPlot { String color = ""; for ( String m : listAlgo ) { if ( i > 0 ) { - output.print( "|" ); + writer.print( "|" ); color += ","; style += "|"; } - output.print( m ); + writer.print( m ); color += colortable[i%28]; if ( !listEvaluators.get(i).isValid() ) { style += "2,6,3"; @@ -505,39 +463,32 @@ public class GenPlot { } i++; } - //output.print("&chdlp=b"); // legend position (but ugly) - output.print("&chco="+color); // colors - output.print("&chls="+style); // linestyle - output.println("&chds=0,10\"/>"); + //writer.print("&chdlp=b"); // legend position (but ugly) + writer.print("&chco="+color); // colors + writer.print("&chls="+style); // linestyle + writer.println("&chds=0,10\"/>"); } // 2010: TSV output is not finished // It is supposed to provide // List of algo // List of STEP + points - public void printTSV( Vector<Vector<Pair>> points ) { + public void printTSV( Vector<Vector<Pair>> points, PrintWriter writer ) { // Print first line for ( String m : listAlgo ) { - output.print("\t"+m ); + writer.print("\t"+m ); } // Print others for ( int i= 0; i < 100 ; i += STEP ) { for( int j = 0; j < size; j++ ){ Pair precrec = points.get(j).get(i); - output.println( precrec.getX()+" "+precrec.getY() ); + writer.println( precrec.getX()+" "+precrec.getY() ); } } - output.println(); + writer.println(); } public void usage() { - System.out.println("usage: GenPlot [options]"); - System.out.println("options are:"); - System.out.println("\t--type=tsv|tex|html(|xml) -t tsv|tex|html(|xml)\tSpecifies the output format"); - System.out.println("\t--graph=class -g class\tSpecifies the class of Evaluator to be used"); - System.out.println("\t--evaluator=class -e class\tSpecifies the class of GraphEvaluator (plotter) to be used"); - System.out.println("\t--list=algo1,...,algon -l algo1,...,algon\tSequence of the filenames to consider"); - System.out.println("\t--debug[=n] -d [n]\t\tReport debug info at level n"); - System.out.println("\t--help -h\t\t\tPrint this message"); + usage( "java "+this.getClass().getName()+" [options]\nGenerate a graphic presentation of evaluation results" ); } } diff --git a/src/fr/inrialpes/exmo/align/cli/GroupAlign.java b/src/fr/inrialpes/exmo/align/cli/GroupAlign.java index f9480feda3acb13b2adb1c28d1cbe695952ebba9..01298e5851bf42d0fc8960f0dafc7c31908ea0ae 100644 --- a/src/fr/inrialpes/exmo/align/cli/GroupAlign.java +++ b/src/fr/inrialpes/exmo/align/cli/GroupAlign.java @@ -1,9 +1,7 @@ /* * $Id$ * - * Copyright (C) 2003 The University of Manchester - * Copyright (C) 2003 The University of Karlsruhe - * Copyright (C) 2003-2008, 2010-2013 INRIA + * Copyright (C) 2003-2008, 2010-2014 INRIA * Copyright (C) 2004, Université de Montréal * * This program is free software; you can redistribute it and/or @@ -22,8 +20,6 @@ * USA. */ -/* This program evaluates the results of several ontology aligners in a row. -*/ package fr.inrialpes.exmo.align.cli; import org.semanticweb.owl.align.Alignment; @@ -38,7 +34,6 @@ import fr.inrialpes.exmo.ontowrap.OntologyFactory; import java.io.File; import java.io.FileOutputStream; -import java.io.FileInputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.OutputStreamWriter; @@ -51,8 +46,14 @@ import java.util.Properties; import org.xml.sax.SAXException; -import gnu.getopt.LongOpt; -import gnu.getopt.Getopt; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.Option; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.ParseException; /** A batch class for an OWL ontology alignment processing. It aligns all the ontology pairs denoted @@ -69,32 +70,37 @@ import gnu.getopt.Getopt; --name=filename -n filename output results in filename.rdf --impl=className -i classname Use the given alignment implementation. --renderer=className -r className Specifies the alignment renderer - --debug=level -d level </pre> <pre> $Id$ </pre> +*/ -@author Sean K. Bechhofer -@author Jérôme Euzenat - */ - -public class GroupAlign { +public class GroupAlign extends CommonCLI { + final static Logger logger = LoggerFactory.getLogger( GroupAlign.class ); - Properties params = null; - String filename = "align"; - String paramfile = null; String urlprefix = null; String source = "onto1.rdf"; String target = "onto.rdf"; URI uri1 = null; String initName = null; - int debug = 0; String alignmentClassName = "fr.inrialpes.exmo.align.impl.method.StringDistAlignment"; String rendererClass = "fr.inrialpes.exmo.align.impl.renderer.RDFRendererVisitor"; String ontoDir = null; + public GroupAlign() { + super(); + options.addOption( OptionBuilder.withLongOpt( "alignment" ).hasArg().withDescription( "Use an initial alignment FILE" ).withArgName("FILE").create( 'a' ) ); + options.addOption( OptionBuilder.withLongOpt( "renderer" ).hasArg().withDescription( "Use the given CLASS for rendering" ).withArgName("CLASS").create( 'r' ) ); + options.addOption( OptionBuilder.withLongOpt( "impl" ).hasArg().withDescription( "Use the given Alignment implementation" ).withArgName("CLASS").create( 'i' ) ); + options.addOption( OptionBuilder.withLongOpt( "name" ).hasArg().withDescription( "Use the given URI as common source ontology" ).withArgName("URI").create( 'n' ) ); + options.addOption( OptionBuilder.withLongOpt( "uriprefix" ).hasArg().withDescription( "URI prefix of the target" ).withArgName("URI").create( 'u' ) ); + options.addOption( OptionBuilder.withLongOpt( "source" ).hasArg().withDescription( "Source ontology FILEname (default "+source+")" ).withArgName("FILE").create( 's' ) ); + options.addOption( OptionBuilder.withLongOpt( "target" ).hasArg().withDescription( "Target ontology FILEname (default "+target+")" ).withArgName("FILE").create( 't' ) ); + options.addOption( OptionBuilder.withLongOpt( "directory" ).hasOptionalArg().withDescription( "The DIRectory containing the data to match" ).withArgName("DIR").create( 'w' ) ); + } + public static void main(String[] args) { try { new GroupAlign().run( args ); } catch (Exception ex) { ex.printStackTrace(); }; @@ -102,109 +108,32 @@ public class GroupAlign { public void run(String[] args) throws Exception { - LongOpt[] longopts = new LongOpt[13]; - params = new Properties(); - - longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); - longopts[1] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'); - longopts[2] = new LongOpt("alignment", LongOpt.REQUIRED_ARGUMENT, null, 'a'); - longopts[3] = new LongOpt("renderer", LongOpt.REQUIRED_ARGUMENT, null, 'r'); - longopts[4] = new LongOpt("debug", LongOpt.OPTIONAL_ARGUMENT, null, 'd'); - longopts[5] = new LongOpt("impl", LongOpt.REQUIRED_ARGUMENT, null, 'i'); - longopts[6] = new LongOpt("params", LongOpt.REQUIRED_ARGUMENT, null, 'p'); - longopts[7] = new LongOpt("name", LongOpt.REQUIRED_ARGUMENT, null, 'n'); - longopts[8] = new LongOpt("prefix", LongOpt.REQUIRED_ARGUMENT, null, 'u'); - longopts[9] = new LongOpt("source", LongOpt.REQUIRED_ARGUMENT, null, 's'); - longopts[10] = new LongOpt("target", LongOpt.REQUIRED_ARGUMENT, null, 't'); - // Is there a way for that in LongOpt ??? - longopts[11] = new LongOpt("D", LongOpt.REQUIRED_ARGUMENT, null, 'D'); - longopts[12] = new LongOpt("directory", LongOpt.REQUIRED_ARGUMENT, null, 'w'); - - Getopt g = new Getopt("", args, "ho:a:d::n:u:r:i:s:t:p:D:w:", longopts); - int c; - String arg; - - while ((c = g.getopt()) != -1) { - switch (c) { - case 'h' : - usage(); - return; - case 'o' : - /* Write output in given filename */ - filename = g.getOptarg(); - break; - case 'n' : - arg = g.getOptarg(); - /* Use common ontology to compare */ - if(arg!=null){ - try { uri1 = new URI(g.getOptarg()); - } catch (Exception e) { e.printStackTrace(); } - } - else{uri1 = null;} - break; - case 'p' : - /* Read parameters from filename */ - paramfile = g.getOptarg(); - params.loadFromXML( new FileInputStream( paramfile ) ); - break; - case 'r' : - /* Use the given class for rendering */ - rendererClass = g.getOptarg(); - break; - case 'i' : - /* Use the given class for the alignment */ - alignmentClassName = g.getOptarg(); - break; - case 'a' : - /* Use the given file as a partial alignment */ - initName = g.getOptarg(); - break; - case 'u' : - /* Use the given url prefix for fetching the ontologies */ - urlprefix = g.getOptarg(); - break; - case 's' : - /* Use the given filename for source ontology */ - source = g.getOptarg(); - break; - case 't' : - /* Use the given filename for target ontology */ - target = g.getOptarg(); - break; - case 'D' : - /* Parameter definition */ - arg = g.getOptarg(); - int index = arg.indexOf('='); - if ( index != -1 ) { - params.setProperty( arg.substring( 0, index), - arg.substring(index+1)); - } else { - System.err.println("Bad parameter syntax: "+g); - usage(); - System.exit(0); - } - break; - case 'd' : - /* Debug level */ - arg = g.getOptarg(); - if ( arg != null ) debug = Integer.parseInt(arg.trim()); - else debug = 4; - break; - case 'w' : - /* Use the given ontology directory */ - arg = g.getOptarg(); - if ( arg != null ) ontoDir = g.getOptarg(); - else ontoDir = null; - break; - } - } + try { + outputfilename = "align"; + + CommandLine line = parseCommandLine( args ); + if ( line == null ) return; // --help - //int i = g.getOptind(); + // Here deal with command specific arguments - if (debug == 0 && params.getProperty("debug") != null) { - debug = Integer.parseInt(params.getProperty("debug")); + if ( line.hasOption( 'n' ) ) { + try { uri1 = new URI( line.getOptionValue('n') ); + } catch ( Exception e ) { + logger.debug( "IGNORED Exception (cannot create source URI)", e ); + } + } + if ( line.hasOption( 'r' ) ) rendererClass = line.getOptionValue( 'r' ); + if ( line.hasOption( 'i' ) ) alignmentClassName = line.getOptionValue( 'i' ); + if ( line.hasOption( 'a' ) ) initName = line.getOptionValue( 'a' ); + if ( line.hasOption( 'u' ) ) urlprefix = line.getOptionValue( 'u' ); + if ( line.hasOption( 's' ) ) source = line.getOptionValue( 's' ); + if ( line.hasOption( 't' ) ) target = line.getOptionValue( 't' ); + if ( line.hasOption( 'w' ) ) ontoDir = line.getOptionValue( 'w' ); + } catch( ParseException exp ) { + logger.error( exp.getMessage() ); + usage(); + System.exit(-1); } - if (debug > 0) params.setProperty( "debug", Integer.toString( debug-1 ) ); iterateDirectories(); } @@ -219,14 +148,14 @@ public class GroupAlign { subdir = (new File(ontoDir)).listFiles(); } } catch ( Exception e ) { - System.err.println("Cannot stat dir "+ e.getMessage()); + logger.error( "Cannot stat dir", e ); usage(); } int size = subdir.length; for ( int i=0 ; i < size; i++ ) { if( subdir[i].isDirectory() ) { // Align - if ( debug > 0 ) System.err.println("Directory: "+subdir[i]); + //logger.trace("Directory: {}", subdir[i]); align( subdir[i] ); } } @@ -250,56 +179,56 @@ public class GroupAlign { // file://localhost/localpath // Apparently should be file:///c:/localpath } - //System.err.println("Here it is "+prefix+" (end by /?)"); + //logger.trace{}("Here it is {} (end by /?)", prefix ); try { if ( !source.equalsIgnoreCase("onto1.rdf") && !target.equalsIgnoreCase("onto1.rdf") ) { - uri1 = new URI(prefix+source); - } else if ( uri1 == null ) uri1 = new URI(prefix+source); - URI uri2 = new URI(prefix+target); + uri1 = new URI( prefix+source ); + } else if ( uri1 == null ) uri1 = new URI( prefix+source ); + URI uri2 = new URI( prefix+target ); - if (debug > 1) System.err.println(" Handler set"); - if (debug > 1) System.err.println(" URI1: "+uri1); - if (debug > 1) System.err.println(" URI2: "+uri2); + //logger.trace(" Handler set"); + //logger.trace(" URI1: {}", uri1); + //logger.trace(" URI2: {}", uri2); try { - if (initName != null) { - AlignmentParser aparser = new AlignmentParser(debug-1); - init = aparser.parse( initName ); + if ( initName != null ) { + AlignmentParser aparser = new AlignmentParser(); + init = aparser.parse( prefix+initName ); uri1 = init.getFile1(); uri2 = init.getFile2(); - if (debug > 1) System.err.println(" Init parsed"); + logger.debug(" Init parsed"); } // Create alignment object Object[] mparams = {}; Class[] cparams = {}; - Class<?> alignmentClass = Class.forName(alignmentClassName); + Class<?> alignmentClass = Class.forName( alignmentClassName ); java.lang.reflect.Constructor alignmentConstructor = alignmentClass.getConstructor(cparams); - result = (AlignmentProcess)alignmentConstructor.newInstance(mparams); + result = (AlignmentProcess)alignmentConstructor.newInstance( mparams ); result.init( uri1, uri2 ); } catch (Exception ex) { - System.err.println("Cannot create alignment "+ alignmentClassName+ "\n"+ ex.getMessage()); + logger.debug( "Cannot create alignment {}", alignmentClassName ); throw ex; } - if (debug > 1) System.err.println(" Alignment structure created"); + logger.debug(" Alignment structure created"); // Compute alignment long time = System.currentTimeMillis(); - result.align(init, params); // add opts + result.align( init, parameters ); long newTime = System.currentTimeMillis(); result.setExtension( Namespace.ALIGNMENT.uri, Annotations.TIME, Long.toString(newTime - time) ); - if (debug > 1) System.err.println(" Alignment performed"); + logger.debug(" Alignment performed"); // Set output file writer = new PrintWriter ( new BufferedWriter( new OutputStreamWriter( - new FileOutputStream(dir+File.separator+filename+".rdf"), "UTF-8" )), true); + new FileOutputStream(dir+File.separator+outputfilename), "UTF-8" )), true); AlignmentVisitor renderer = null; try { @@ -309,41 +238,30 @@ public class GroupAlign { Class.forName(rendererClass).getConstructor(cparams); renderer = (AlignmentVisitor)rendererConstructor.newInstance(mparams); } catch (Exception ex) { - System.err.println("Cannot create renderer "+rendererClass+"\n"+ ex.getMessage()); + logger.debug( "Cannot create renderer {}", rendererClass ); throw ex; } - if (debug > 1) System.err.println(" Outputing result to "+dir+File.separator+filename+".rdf"); + logger.debug(" Outputing result to {}/{}", dir, outputfilename ); + // Output result.render( renderer); - if (debug > 1) System.err.println(" Done..."+renderer+"\n"); - } catch (Exception ex) { - if ( debug > 1 ) ex.printStackTrace(); + logger.debug(" Done...{}", renderer ); + } catch (Exception ex) { + logger.debug( "IGNORED Exception", ex ); } finally { // JE: This instruction is very important if ( writer != null ) writer.close(); // Unload the ontologies - try { OntologyFactory.clear(); } catch (Exception e) {}; + try { OntologyFactory.clear(); + } catch (Exception e) { + logger.debug( "IGNORED Exception on close", e ); + }; } } public void usage() { - System.err.println("usage: GroupAlign [options]"); - System.err.println("options are:"); - System.err.println("\t--name=uri -n uri\t\tUse the given uri to compare with."); - System.err.println("\t--source=filename -s filename Source filename (default onto1.rdf)"); - System.err.println("\t--target=filename -t filename Target filename (default onto.rdf)"); - System.err.println("\t--prefix=uriprefix -u uriprefix URI prefix of the target"); - System.err.println("\t--output=filename -o filename\tOutput the alignment in filename.rdf"); - System.err.println("\t--impl=className -i classname\t\tUse the given alignment implementation."); - System.err.println("\t--renderer=className -r className\tSpecifies the alignment renderer"); - System.err.println("\t--alignment=filename -a filename Start from an XML alignment file"); - System.err.println("\t--params=filename -p filename\tReads parameters from filename"); - System.err.println("\t-Dparam=value\t\t\tSet parameter"); - System.err.println("\t--debug[=n] -d [n]\t\tReport debug info at level n"); - System.err.println("\t--help -h\t\t\tPrint this message"); - System.err.print("\n"+GroupAlign.class.getPackage().getImplementationTitle()+" "+GroupAlign.class.getPackage().getImplementationVersion()); - System.err.println(" ($Id$)\n"); + usage( "java "+this.getClass().getName()+" [options]\nMatches pairs of ontologies in subdirectories" ); } } diff --git a/src/fr/inrialpes/exmo/align/cli/GroupEval.java b/src/fr/inrialpes/exmo/align/cli/GroupEval.java index 99448170c22cfd66ad70d4e8d2adf0cbe598b137..ec3acb6abe97f9f6b07c7156f7c7bd1b4138d050 100644 --- a/src/fr/inrialpes/exmo/align/cli/GroupEval.java +++ b/src/fr/inrialpes/exmo/align/cli/GroupEval.java @@ -1,9 +1,7 @@ /* * $Id$ * - * Copyright (C) 2003 The University of Manchester - * Copyright (C) 2003 The University of Karlsruhe - * Copyright (C) 2003-2012, INRIA + * Copyright (C) 2003-2014, INRIA * Copyright (C) 2004, Université de Montréal * * This program is free software; you can redistribute it and/or @@ -48,8 +46,14 @@ import java.util.Properties; import org.xml.sax.SAXException; -import gnu.getopt.LongOpt; -import gnu.getopt.Getopt; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.Option; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.ParseException; import fr.inrialpes.exmo.align.parser.AlignmentParser; @@ -65,7 +69,6 @@ import fr.inrialpes.exmo.align.parser.AlignmentParser; <pre> -o filename --output=filename -f format = prfot (precision/recall/f-measure/overall/time) --format=prfot - -d debug --debug=level -r filename --reference=filename -s algo/measure -l list of compared algorithms @@ -83,108 +86,65 @@ import fr.inrialpes.exmo.align.parser.AlignmentParser; $Id$ </pre> -@author Sean K. Bechhofer -@author Jérôme Euzenat */ -public class GroupEval { +public class GroupEval extends CommonCLI { + final static Logger logger = LoggerFactory.getLogger( GroupEval.class ); - Properties params = null; - String filename = null; String reference = "refalign.rdf"; String format = "pr"; int fsize = 2; String type = "html"; boolean embedded = false; String dominant = "s"; - Vector<String> listAlgo = null; - int debug = 0; + String[] listAlgo = null; + int size = 0; String color = null; String ontoDir = null; + public GroupEval() { + super(); + options.addOption( OptionBuilder.withLongOpt( "list" ).hasArgs().withValueSeparator(',').withDescription( "List of FILEs to be included in the results (required)" ).withArgName("FILE").create( 'l' ) ); + options.addOption( OptionBuilder.withLongOpt( "color" ).hasOptionalArg().withDescription( "Color even lines of the output in COLOR (default: lightblue)" ).withArgName("COLOR").create( 'c' ) ); + options.addOption( OptionBuilder.withLongOpt( "format" ).hasArg().withDescription( "Used MEASures and order (precision/recall/f-measure/overall/time) (default: "+format+")" ).withArgName("MEAS").create( 'f' ) ); + options.addOption( OptionBuilder.withLongOpt( "type" ).hasArg().withDescription( "Output TYPE (html|xml|tex|ascii|triangle; default: "+type+")" ).withArgName("TYPE").create( 't' ) ); + //options.addOption( OptionBuilder.withLongOpt( "sup" ).hasArg().withDescription( "Specifies if dominant columns are algorithms or measure" ).withArgName("algo").create( 's' ) ); + options.addOption( OptionBuilder.withLongOpt( "reference" ).hasArg().withDescription( "Name of the reference alignment FILE (default: "+reference+")" ).withArgName("FILE").create( 'r' ) ); + options.addOption( OptionBuilder.withLongOpt( "directory" ).hasOptionalArg().withDescription( "The DIRectory containing the data to evaluate" ).withArgName("DIR").create( 'w' ) ); + // .setRequired( true ) + Option opt = options.getOption( "list" ); + if ( opt != null ) opt.setRequired( true ); + } + + public static void main(String[] args) { try { new GroupEval().run( args ); } catch (Exception ex) { ex.printStackTrace(); }; } public void run(String[] args) throws Exception { - String listFile = ""; - LongOpt[] longopts = new LongOpt[10]; - - longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); - longopts[1] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'); - longopts[2] = new LongOpt("format", LongOpt.REQUIRED_ARGUMENT, null, 'f'); - longopts[3] = new LongOpt("type", LongOpt.REQUIRED_ARGUMENT, null, 't'); - longopts[4] = new LongOpt("debug", LongOpt.OPTIONAL_ARGUMENT, null, 'd'); - longopts[5] = new LongOpt("sup", LongOpt.REQUIRED_ARGUMENT, null, 's'); - longopts[6] = new LongOpt("list", LongOpt.REQUIRED_ARGUMENT, null, 'l'); - longopts[7] = new LongOpt("color", LongOpt.OPTIONAL_ARGUMENT, null, 'c'); - longopts[8] = new LongOpt("reference", LongOpt.REQUIRED_ARGUMENT, null, 'r'); - longopts[9] = new LongOpt("directory", LongOpt.REQUIRED_ARGUMENT, null, 'w'); - - Getopt g = new Getopt("", args, "ho:a:d::l:f:t:r:w:c::", longopts); - int c; - String arg; - - while ((c = g.getopt()) != -1) { - switch (c) { - case 'h' : - usage(); - return; - case 'o' : - /* Write output here */ - filename = g.getOptarg(); - break; - case 'r' : - /* File name for the reference alignment */ - reference = g.getOptarg(); - break; - case 'f' : - /* Sequence of results to print */ - format = g.getOptarg(); - break; - case 't' : - /* Type of output (tex/html/xml/ascii) */ - type = g.getOptarg(); - break; - case 's' : - /* Print per type or per algo */ - dominant = g.getOptarg(); - break; - case 'c' : - /* Print colored lines */ - arg = g.getOptarg(); - if ( arg != null ) { - color = arg.trim(); - } else color = "lightblue"; - break; - case 'l' : - /* List of filename */ - listFile = g.getOptarg(); - break; - case 'd' : - /* Debug level */ - arg = g.getOptarg(); - if ( arg != null ) debug = Integer.parseInt(arg.trim()); - else debug = 4; - break; - case 'w' : - /* Use the given ontology directory */ - arg = g.getOptarg(); - if ( arg != null ) ontoDir = g.getOptarg(); - else ontoDir = null; - break; - } - } - listAlgo = new Vector<String>(); - for ( String s : listFile.split(",") ) { - listAlgo.add( s ); + try { + CommandLine line = parseCommandLine( args ); + if ( line == null ) return; // --help + + // Here deal with command specific arguments + if ( line.hasOption( 'f' ) ) format = line.getOptionValue( 'f' ); + if ( line.hasOption( 'r' ) ) reference = line.getOptionValue( 'r' ); + if ( line.hasOption( 's' ) ) dominant = line.getOptionValue( 's' ); + if ( line.hasOption( 't' ) ) type = line.getOptionValue( 't' ); + if ( line.hasOption( 'c' ) ) color = line.getOptionValue( 'c', "lightblue" ); + if ( line.hasOption( 'l' ) ) { + listAlgo = line.getOptionValues( 'l' ); + size = listAlgo.length; + } + if ( line.hasOption( 'w' ) ) ontoDir = line.getOptionValue( 'w' ); + } catch( ParseException exp ) { + logger.error( exp.getMessage() ); + usage(); + System.exit( -1 ); } - params = new Properties(); - if (debug > 0) params.setProperty( "debug", Integer.toString( debug-1 ) ); - print( iterateDirectories() ); } @@ -192,13 +152,13 @@ public class GroupEval { Vector<Vector> result = null; File [] subdir = null; try { - if (ontoDir == null) { - subdir = (new File(System.getProperty("user.dir"))).listFiles(); - } else { - subdir = (new File(ontoDir)).listFiles(); - } - } catch (Exception e) { - System.err.println("Cannot stat dir "+ e.getMessage()); + if (ontoDir == null) { + subdir = (new File(System.getProperty("user.dir"))).listFiles(); + } else { + subdir = (new File(ontoDir)).listFiles(); + } + } catch ( Exception e ) { + logger.error( "Cannot stat dir ", e ); usage(); } int size = subdir.length; @@ -207,7 +167,7 @@ public class GroupEval { int i = 0; for ( int j=0 ; j < size; j++ ) { if( subdir[j].isDirectory() ) { - if ( debug > 0 ) System.err.println("\nEntering directory "+subdir[j]); + //logger.trace( "Entering directory {}", subdir[j] ); // eval the alignments in a subdirectory // store the result Vector vect = iterateAlignments( subdir[j] ); @@ -232,7 +192,7 @@ public class GroupEval { // call eval // store the result in a record // return the record. - if ( debug > 2) System.err.println(" Considering result "+i); + //logger.trace( " Considering result {}", i ); Evaluator evaluator = eval( prefix+reference, prefix+m+".rdf"); if ( evaluator != null ) ok = true; result.add( i, evaluator ); @@ -240,8 +200,8 @@ public class GroupEval { // Unload the ontologies. try { OntologyFactory.clear(); - } catch ( OntowrapException owex ) { // only report - owex.printStackTrace(); + } catch ( OntowrapException owex ) { + logger.debug( "IGNORED Exception", owex ); } if ( ok == true ) return result; @@ -251,28 +211,19 @@ public class GroupEval { public Evaluator eval( String alignName1, String alignName2 ) { Evaluator eval = null; try { - int nextdebug; - if ( debug < 2 ) nextdebug = 0; - else nextdebug = debug - 2; // Load alignments - AlignmentParser aparser = new AlignmentParser( nextdebug ); + AlignmentParser aparser = new AlignmentParser(); Alignment align1 = aparser.parse( alignName1 ); - if ( debug > 2 ) System.err.println(" Alignment structure1 parsed"); + //logger.trace(" Alignment structure1 parsed"); aparser.initAlignment( null ); Alignment align2 = aparser.parse( alignName2 ); - if ( debug > 2 ) System.err.println(" Alignment structure2 parsed"); + //logger.trace(" Alignment structure2 parsed"); // Create evaluator object eval = new PRecEvaluator( align1, align2 ); // Compare - params.setProperty( "debug", Integer.toString( nextdebug ) ); - eval.eval( params ) ; + eval.eval( parameters ) ; } catch (Exception ex) { - if ( debug > 1 ) { - ex.printStackTrace(); - } else { - System.err.println("GroupEval: "+ex); - System.err.println(alignName1+ " - "+alignName2 ); - } + logger.debug( "IGNORED Exception", ex ); }; return eval; } @@ -283,16 +234,16 @@ public class GroupEval { public void print( Vector<Vector> result ) { PrintStream writer = null; try { - if ( filename == null ) { + if ( outputfilename == null ) { writer = System.out; } else { - writer = new PrintStream(new FileOutputStream( filename )); + writer = new PrintStream( new FileOutputStream( outputfilename ) ); } if ( type.equals("html") ) printHTML( result, writer ); else if ( type.equals("tex") ) printLATEX( result, writer ); else if ( type.equals("triangle") ) printTRIANGLE( result, writer ); } catch ( FileNotFoundException fnfex) { - fnfex.printStackTrace(); + logger.error( "Cannot open file", fnfex ); } finally { writer.close(); } @@ -309,10 +260,10 @@ public class GroupEval { int foundVect[]; // found so far int correctVect[]; // correct so far long timeVect[]; // time so far - foundVect = new int[ listAlgo.size() ]; - correctVect = new int[ listAlgo.size() ]; - timeVect = new long[ listAlgo.size() ]; - for( int k = listAlgo.size()-1; k >= 0; k-- ) { + foundVect = new int[ size ]; + correctVect = new int[ size ]; + timeVect = new long[ size ]; + for( int k = size-1; k >= 0; k-- ) { foundVect[k] = 0; correctVect[k] = 0; timeVect[k] = 0; @@ -399,9 +350,11 @@ public class GroupEval { double prec2 = precision*precision; double a = ((prec2-(recall*recall)+1)/2); double b = java.lang.Math.sqrt( prec2 - (a*a) ); - a = a*10; b = b*10; //for printing scale 10. - writer.println("\\draw plot[mark=+,] coordinates {("+a+","+b+")};"); - writer.println("\\draw ("+(a+.01)+","+(b+.01)+") node[anchor=south west] {"+m+"};"); + if ( b == b ) { // Test if b is not NaN! Otherwise, no square root: the point is out of the triangle + a = a*10; b = b*10; //for printing scale 10. + writer.println("\\draw plot[mark=+,] coordinates {("+a+","+b+")};"); + writer.println("\\draw ("+(a+.01)+","+(b+.01)+") node[anchor=south west] {"+m+"};"); + } k++; } writer.println("\\end{tikzpicture}"); @@ -454,10 +407,10 @@ public class GroupEval { //writer.println("<td>Prec.</td><td>Rec.</td>"); } writer.println("</tr></tbody><tbody>"); - foundVect = new int[ listAlgo.size() ]; - correctVect = new int[ listAlgo.size() ]; - timeVect = new long[ listAlgo.size() ]; - for( int k = listAlgo.size()-1; k >= 0; k-- ) { + foundVect = new int[ size ]; + correctVect = new int[ size ]; + timeVect = new long[ size ]; + for( int k = size-1; k >= 0; k-- ) { foundVect[k] = 0; correctVect[k] = 0; timeVect[k] = 0; @@ -508,10 +461,10 @@ public class GroupEval { } else if ( format.charAt(i) == 'r' ) { formatter.format("%1.2f", eval.getRecall()); } - writer.println("</td>"); + writer.print("</td>"); } } else { - for ( int i = 0 ; i < fsize; i++) writer.println("<td>n/a</td>"); + for ( int i = 0 ; i < fsize; i++) writer.print("<td>n/a</td>"); } } writer.println("</tr>"); @@ -575,7 +528,7 @@ public class GroupEval { writer.println("\\setlength{\\tabcolsep}{3pt} % May be changed"); writer.println("\\begin{table}"); writer.print("\\begin{tabular}{|l||"); - for ( int i = listAlgo.size(); i > 0; i-- ) { + for ( int i = size; i > 0; i-- ) { for ( int j = fsize; j > 0; j-- ) writer.print("c"); writer.print("|"); } @@ -607,10 +560,10 @@ public class GroupEval { } } writer.println(" \\\\ \\hline"); - foundVect = new int[ listAlgo.size() ]; - correctVect = new int[ listAlgo.size() ]; - timeVect = new long[ listAlgo.size() ]; - for( int k = listAlgo.size()-1; k >= 0; k-- ) { + foundVect = new int[ size ]; + correctVect = new int[ size ]; + timeVect = new long[ size ]; + for( int k = size-1; k >= 0; k-- ) { foundVect[k] = 0; correctVect[k] = 0; timeVect[k] = 0; @@ -697,21 +650,7 @@ public class GroupEval { } public void usage() { - System.out.println("usage: GroupEval [options]"); - System.out.println("options are:"); - System.out.println("\t--format=prfot -r prfot\tSpecifies the output order (precision/recall/f-measure/overall/time)"); - // Apparently not implemented - //System.out.println("\t--sup=algo -s algo\tSpecifies if dominant columns are algorithms or measure"); - System.out.println("\t--output=filename -o filename\tSpecifies a file to which the output will go"); - System.out.println("\t--reference=filename -r filename\tSpecifies the name of the reference alignment file (default: refalign.rdf)"); - - System.out.println("\t--type=html|xml|tex|ascii|triangle -t html|xml|tex|ascii\tSpecifies the output format"); - System.out.println("\t--list=algo1,...,algon -l algo1,...,algon\tSequence of the filenames to consider"); - System.out.println("\t--color=color -c color\tSpecifies if the output must color even lines of the output"); - System.out.println("\t--debug[=n] -d [n]\t\tReport debug info at level n"); - System.out.println("\t--help -h\t\t\tPrint this message"); - System.err.print("\n"+GroupEval.class.getPackage().getImplementationTitle()+" "+GroupEval.class.getPackage().getImplementationVersion()); - System.err.println(" ($Id$)\n"); + usage( "java "+this.getClass().getName()+" [options]\nEvaluates in parallel several matching results on several tests in subdirectories" ); } /* diff --git a/src/fr/inrialpes/exmo/align/cli/GroupOutput.java b/src/fr/inrialpes/exmo/align/cli/GroupOutput.java index 33342e942a0692482f65e56badd111dea59270a3..56e84b54d7fe2e3b4ae15932254ab83824c92ad1 100644 --- a/src/fr/inrialpes/exmo/align/cli/GroupOutput.java +++ b/src/fr/inrialpes/exmo/align/cli/GroupOutput.java @@ -1,9 +1,7 @@ /* * $Id$ * - * Copyright (C) 2003 The University of Manchester - * Copyright (C) 2003 The University of Karlsruhe - * Copyright (C) 2003-2012, INRIA + * Copyright (C) 2003-2014, INRIA * Copyright (C) 2004, Université de Montréal * * This program is free software; you can redistribute it and/or @@ -25,6 +23,7 @@ /* This program evaluates the results of several ontology aligners and generates a LaTeX diagram for each of these */ + package fr.inrialpes.exmo.align.cli; import org.semanticweb.owl.align.Alignment; @@ -49,12 +48,18 @@ import java.util.Vector; import java.util.Enumeration; import java.util.Properties; -import gnu.getopt.LongOpt; -import gnu.getopt.Getopt; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.ParseException; import fr.inrialpes.exmo.align.parser.AlignmentParser; -/** A basic class for synthesizing the alignment results of an algorithm with +/** + * A basic class for synthesizing the alignment results of an algorithm with * regard to the ontology characteristics as a colored module. * * These modules are however computed on averaging the precision recall/graphs @@ -70,12 +75,11 @@ import fr.inrialpes.exmo.align.parser.AlignmentParser; * <pre> * -o filename --output=filename * -c --color - * -v --value + * -v --values * -e --labels * -m --measure - * -d debug --debug=level * -l list of compared algorithms - * -t output --type=output: xml/tex/html/ascii + * -t output --type=output: tex/html * </pre> * * The input is taken in the current directory in a set of subdirectories (one per @@ -123,7 +127,8 @@ But it is less informative than the above presentation. \end{tikzpicture} */ -public class GroupOutput { +public class GroupOutput extends CommonCLI { + final static Logger logger = LoggerFactory.getLogger( GroupOutput.class ); static int SIZE = 16;// Nb of cells = 2^ = 16 static int cellSpec[][] = { {101}, //liph=0 @@ -142,102 +147,78 @@ public class GroupOutput { {257},//h=13 {254,260,261},//i=14 {262,265,266} };//emptyset=15 - Properties params = null; - Vector<String> listAlgo; - String fileNames = ""; - String outFile = null; + String[] listAlgo; String type = "tex"; - String color = null; + String color = "blue"; boolean labels = false; - boolean value = false; - int debug = 0; + boolean values = false; int measure = 0; PrintWriter output = null; - + String ontoDir = null; + String prefix = null; + + public GroupOutput() { + super(); + options.addOption( "v", "values", false, "Displays the values" ); + options.addOption( "e", "labels", false, "Displays graph labels" ); + options.addOption( OptionBuilder.withLongOpt( "color" ).hasOptionalArg().withDescription( "Use COLOR to fill cells (default: "+color+")" ).withArgName("COLOR").create( 'c' ) ); + options.addOption( OptionBuilder.withLongOpt( "type" ).hasArg().withDescription( "Specifies the output TYPE (html|tex; default: "+type+")" ).withArgName("TYPE").create( 't' ) ); + options.addOption( OptionBuilder.withLongOpt( "list" ).hasArgs().withValueSeparator(',').withDescription( "Consider this list of FILEs for inclusion in the results" ).withArgName("FILE").create( 'l' ) ); + options.addOption( OptionBuilder.withLongOpt( "format" ).hasArg().withDescription( "Display MEASure (prof; default: f)" ).withArgName("MEAS").create( 'f' ) ); + options.addOption( OptionBuilder.withLongOpt( "directory" ).hasOptionalArg().withDescription( "The DIRectory containing the data to match" ).withArgName("DIR").create( 'w' ) ); + } public static void main(String[] args) { try { new GroupOutput().run( args ); } catch (Exception ex) { ex.printStackTrace(); }; } public void run(String[] args) throws Exception { - LongOpt[] longopts = new LongOpt[10]; - - longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); - longopts[1] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'); - longopts[2] = new LongOpt("color", LongOpt.OPTIONAL_ARGUMENT, null, 'c'); - longopts[3] = new LongOpt("type", LongOpt.REQUIRED_ARGUMENT, null, 't'); - longopts[4] = new LongOpt("debug", LongOpt.OPTIONAL_ARGUMENT, null, 'd'); - longopts[6] = new LongOpt("list", LongOpt.REQUIRED_ARGUMENT, null, 'l'); - longopts[7] = new LongOpt("value", LongOpt.NO_ARGUMENT, null, 'v'); - longopts[8] = new LongOpt("labels", LongOpt.NO_ARGUMENT, null, 'e'); - longopts[9] = new LongOpt("measure", LongOpt.REQUIRED_ARGUMENT, null, 'm'); - - Getopt g = new Getopt("", args, "hveo:c::d::l:t:m:", longopts); - int c; - String arg; - - while ((c = g.getopt()) != -1) { - switch (c) { - case 'h' : - usage(); - return; - case 'v' : - value = true; - break; - case 'e' : - labels = true; - break; - case 'o' : - /* Write output here */ - outFile = g.getOptarg(); - break; - case 'c' : - /* Cell color */ - arg = g.getOptarg(); - if ( arg != null ) { - color = arg.trim(); - } else color = "blue"; - break; - case 't' : - /* Type of output (tex/tsv(/html/xml/ascii)) */ - type = g.getOptarg(); - break; - case 'l' : - /* List of filename */ - fileNames = g.getOptarg(); - break; - case 'm' : - /* measure to be used */ - String s = g.getOptarg(); + + try { + CommandLine line = parseCommandLine( args ); + if ( line == null ) return; // --help + + // Here deal with command specific arguments + if ( line.hasOption( 'v' ) ) values = true; + if ( line.hasOption( 'e' ) ) labels = true; + if ( line.hasOption( 'c' ) ) color = line.getOptionValue( 'c', "blue" ); + if ( line.hasOption( 't' ) ) type = line.getOptionValue( 't' ); + if ( line.hasOption( 'l' ) ) listAlgo = line.getOptionValues( 'l' ); + if ( line.hasOption( 'f' ) ) { + String s = line.getOptionValue( 'f' ); if ( s.equals("p") ) measure = 1; else if ( s.equals("r") ) measure = 2; else if ( s.equals("o") ) measure = 3; - break; - case 'd' : - /* Debug level */ - arg = g.getOptarg(); - if ( arg != null ) debug = Integer.parseInt(arg.trim()); - else debug = 4; - break; } + if ( line.hasOption( 'w' ) ) ontoDir = line.getOptionValue( 'w' ); + } catch( ParseException exp ) { + logger.error( exp.getMessage() ); + usage(); + System.exit(-1); } - listAlgo = new Vector<String>(); - for ( String s : fileNames.split(",") ) { - listAlgo.add( s ); - } + parameters.setProperty( "step", Integer.toString(SIZE) ); - params = new Properties(); - if (debug > 0) params.setProperty( "debug", Integer.toString(debug-1) ); - - params.setProperty( "step", Integer.toString(SIZE) ); + try { + File dir = null; + if ( ontoDir == null ) { + dir = new File( System.getProperty("user.dir") ); + } else { + dir = new File( ontoDir ); + } + prefix = dir.toURI().toString(); + } catch ( Exception e ) { + logger.error( "Cannot stat dir ", e ); + usage(); + System.exit(-1); + } // Set output file OutputStream stream; - if (outFile == null) { + if ( outputfilename == null) { stream = System.out; } else { - stream = new FileOutputStream(outFile); + stream = new FileOutputStream( outputfilename ); } output = new PrintWriter ( new BufferedWriter( @@ -268,11 +249,13 @@ public class GroupOutput { public void iterateAlgorithm(){ // for all alignments there, for ( String algo : listAlgo ) { - if ( debug > 0 ) System.err.println("Algorithm: "+algo); + //logger.trace("Algorithm: {}", algo); // type if ( type.equals("tex") ) { printPGFTeX( algo, iterateCells( algo ) ); - } else System.err.println("Flag -t "+type+" : not implemented yet"); + } else { + logger.warn( "Flag -t {} : not implemented yet", type ); + } } } @@ -285,53 +268,46 @@ public class GroupOutput { } public double iterateTests( String algo, int[] tests ){ - File dir = (new File(System.getProperty("user.dir"))); double result = 0.0; int nbtests = 0; for ( int i=0; i<tests.length; i++ ){//size() or length - if ( debug > 1 ) System.err.println(" tests: "+tests[i]); - String prefix = dir.toURI().toString()+"/"+tests[i]+"/"; + //logger.trace(" tests: {}", tests[i]); + String testdir = prefix+"/"+tests[i]+"/"; try { - PRecEvaluator evaluator = (PRecEvaluator)eval( prefix+"refalign.rdf", prefix+algo+".rdf"); + PRecEvaluator evaluator = (PRecEvaluator)eval( testdir+"refalign.rdf", testdir+algo+".rdf"); result += getMeasure( evaluator ); nbtests++; // Only the tests that succeed - } catch ( AlignmentException aex ) { // simple error message - if ( aex.getCause() != null ) - System.err.println( aex.getCause().getMessage() ); - else System.err.println( aex ); + } catch ( AlignmentException aex ) { + logger.debug( "IGNORED Exception", aex ); } } // Unload the ontologies. try { OntologyFactory.clear(); - } catch ( OntowrapException owex ) { // only report - owex.printStackTrace(); + } catch ( OntowrapException owex ) { + logger.debug( "IGNORED Exception", owex ); } return result/(double)nbtests; } public Evaluator eval( String alignName1, String alignName2 ) throws AlignmentException { Evaluator eval = null; - int nextdebug; - if ( debug < 3 ) nextdebug = 0; - else nextdebug = debug - 3; // Load alignments Alignment align1=null, align2=null; try { - AlignmentParser aparser = new AlignmentParser( nextdebug ); + AlignmentParser aparser = new AlignmentParser(); align1 = aparser.parse( alignName1 ); - if ( debug > 2 ) System.err.println(" Alignment structure1 parsed"); + //logger.trace(" Alignment structure1 parsed"); aparser.initAlignment( null ); align2 = aparser.parse( alignName2 ); - if ( debug > 2 ) System.err.println(" Alignment structure2 parsed"); + //logger.trace(" Alignment structure2 parsed"); } catch (Exception ex) { throw new AlignmentException( "Cannot parse ", ex ); } // Create evaluator object eval = new PRecEvaluator( align1, align2 ); // Compare - params.setProperty( "debug", Integer.toString( nextdebug ) ); - eval.eval( params ) ; + eval.eval( parameters ) ; return eval; } @@ -350,35 +326,35 @@ public class GroupOutput { } output.println("\\draw (0,2.) node[diamond"+colorFormat(cells[11])+"] {}; % l"); - if (value) output.println("\\draw (0,2.) node {"+stringFormat(cells[11])+"}; % l"); + if (values) output.println("\\draw (0,2.) node {"+stringFormat(cells[11])+"}; % l"); output.println("\\draw (0,1.) node[diamond"+colorFormat(cells[5])+"] {}; % lp"); - if (value) output.println("\\draw (0,1.) node {"+stringFormat(cells[5])+"}; % lp"); + if (values) output.println("\\draw (0,1.) node {"+stringFormat(cells[5])+"}; % lp"); output.println("\\draw (0.5,1.5) node[diamond"+colorFormat(cells[2])+"] {}; % lip"); - if (value) output.println("\\draw (0.5,1.5) node {"+stringFormat(cells[2])+"}; % lip"); + if (values) output.println("\\draw (0.5,1.5) node {"+stringFormat(cells[2])+"}; % lip"); output.println("\\draw (1.,2.) node[diamond"+colorFormat(cells[6])+"] {}; %li"); - if (value) output.println("\\draw (1.,2.) node {"+stringFormat(cells[6])+"}; %li"); + if (values) output.println("\\draw (1.,2.) node {"+stringFormat(cells[6])+"}; %li"); output.println("\\draw (-0.5,-0.5) node[diamond"+colorFormat(cells[9])+"] {}; % ip"); - if (value) output.println("\\draw (-0.5,-0.5) node {"+stringFormat(cells[9])+"}; % ip"); + if (values) output.println("\\draw (-0.5,-0.5) node {"+stringFormat(cells[9])+"}; % ip"); output.println("\\draw (0,0) node[diamond"+colorFormat(cells[12])+"] {}; %p"); - if (value) output.println("\\draw (0,0) node {"+stringFormat(cells[12])+"}; %p"); + if (values) output.println("\\draw (0,0) node {"+stringFormat(cells[12])+"}; %p"); output.println("\\draw (.5,.5) node[diamond"+colorFormat(cells[3])+"] {}; % lph"); - if (value) output.println("\\draw (.5,.5) node {"+stringFormat(cells[3])+"}; % lph"); + if (values) output.println("\\draw (.5,.5) node {"+stringFormat(cells[3])+"}; % lph"); output.println("\\draw (1.,1.) node[diamond"+colorFormat(cells[0])+"] {}; % liph"); - if (value) output.println("\\draw (1.,1.) node {"+stringFormat(cells[0])+"}; % liph"); + if (values) output.println("\\draw (1.,1.) node {"+stringFormat(cells[0])+"}; % liph"); output.println("\\draw (1.5,1.5) node[diamond"+colorFormat(cells[4])+"] {}; %hil"); - if (value) output.println("\\draw (1.5,1.5) node {"+stringFormat(cells[4])+"}; %hil"); + if (values) output.println("\\draw (1.5,1.5) node {"+stringFormat(cells[4])+"}; %hil"); output.println("\\draw (2.,2.) node[diamond"+colorFormat(cells[14])+"] {}; %i"); - if (value) output.println("\\draw (2.,2.) node {"+stringFormat(cells[14])+"}; %i"); + if (values) output.println("\\draw (2.,2.) node {"+stringFormat(cells[14])+"}; %i"); output.println("\\draw (2.,1.) node[diamond"+colorFormat(cells[10])+"] {}; % hi"); - if (value) output.println("\\draw (2.,1.) node {"+stringFormat(cells[10])+"}; % hi"); + if (values) output.println("\\draw (2.,1.) node {"+stringFormat(cells[10])+"}; % hi"); output.println("\\draw (1.5,0.5) node[diamond"+colorFormat(cells[1])+"] {}; % phi"); - if (value) output.println("\\draw (1.5,0.5) node {"+stringFormat(cells[1])+"}; % phi"); + if (values) output.println("\\draw (1.5,0.5) node {"+stringFormat(cells[1])+"}; % phi"); output.println("\\draw (1.,0) node[diamond"+colorFormat(cells[8])+"] {}; % ph"); - if (value) output.println("\\draw (1.,0) node {"+stringFormat(cells[8])+"}; % ph"); + if (values) output.println("\\draw (1.,0) node {"+stringFormat(cells[8])+"}; % ph"); output.println("\\draw (2.,0) node[diamond"+colorFormat(cells[13])+"] {}; % h"); - if (value) output.println("\\draw (2.,0) node {"+stringFormat(cells[13])+"}; % h"); + if (values) output.println("\\draw (2.,0) node {"+stringFormat(cells[13])+"}; % h"); output.println("\\draw (2.5,-0.5) node[diamond"+colorFormat(cells[7])+"] {}; % hl"); - if (value) output.println("\\draw (2.5,-0.5) node {"+stringFormat(cells[7])+"}; % hl"); + if (values) output.println("\\draw (2.5,-0.5) node {"+stringFormat(cells[7])+"}; % hl"); output.println("\\end{scope}"); @@ -422,14 +398,6 @@ public class GroupOutput { } public void usage() { - System.out.println("usage: GenPlot [options]"); - System.out.println("options are:"); - System.out.println("\t--values -v\tSpecifies if the values should be displayed"); - System.out.println("\t--label -e\tSpecifies if the labels should be displayed"); - System.out.println("\t--measure=[prf] -c [prf]\tThe measure to display [F-measure]"); - System.out.println("\t--color=color -c color\tSpecifies the color to use [blue]"); - System.out.println("\t--list=algo1,...,algon -l algo1,...,algon\tSequence of the filenames to consider"); - System.out.println("\t--debug[=n] -d [n]\t\tReport debug info at level n"); - System.out.println("\t--help -h\t\t\tPrint this message"); + usage( "java "+this.getClass().getName()+" [options]\nDisplays matcher results in a topological display" ); } } diff --git a/src/fr/inrialpes/exmo/align/cli/ParserPrinter.java b/src/fr/inrialpes/exmo/align/cli/ParserPrinter.java index ff336caa3367a7969dab92c265fe5998723bfc77..33247689c01b9c76b9b216c9a3def7224d5a0d37 100644 --- a/src/fr/inrialpes/exmo/align/cli/ParserPrinter.java +++ b/src/fr/inrialpes/exmo/align/cli/ParserPrinter.java @@ -18,14 +18,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* -*/ package fr.inrialpes.exmo.align.cli; -//Imported JAVA classes import java.lang.Integer; import java.lang.Double; import java.util.Hashtable; +import java.util.List; import java.util.Properties; import java.io.File; @@ -37,8 +35,13 @@ import java.io.OutputStreamWriter; import org.xml.sax.SAXException; -import gnu.getopt.LongOpt; -import gnu.getopt.Getopt; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.ParseException; import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentVisitor; @@ -64,7 +67,6 @@ import fr.inrialpes.exmo.align.parser.AlignmentParser; --inverse -i Inverse first and second ontology --threshold=threshold -t threshold Trim the alugnment with regard to threshold --cutmethod=hard|perc|prop|best|span -T hard|perc|prop|best|span Method to use for triming - --debug[=n] -d [n] Report debug info at level n, --output=filename -o filename Output the alignment in filename --help -h Print this message </pre> @@ -79,7 +81,19 @@ $Id$ */ -public class ParserPrinter { +public class ParserPrinter extends CommonCLI { + final static Logger logger = LoggerFactory.getLogger( ParserPrinter.class ); + + public ParserPrinter() { + super(); + options.addOption( "i", "inverse", false, "Inverse first and second ontology" ); + options.addOption( "e", "embedded", false, "Read the alignment as embedded in a XML file" ); + options.addOption( OptionBuilder.withLongOpt( "renderer" ).hasArg().withDescription( "Use the given CLASS for rendering" ).withArgName("CLASS").create( 'r' ) ); + options.addOption( OptionBuilder.withLongOpt( "parser" ).hasArg().withDescription( "Use the given CLASS for parsing" ).withArgName("CLASS").create( 'p' ) ); + options.addOption( OptionBuilder.withLongOpt( "threshold" ).hasArg().withDescription( "Trim the alignment with regard to threshold" ).withArgName("DOUBLE").create( 't' ) ); + options.addOption( OptionBuilder.withLongOpt( "cutmethod" ).hasArg().withDescription( "Method to use for triming (hard|perc|prop|best|span)" ).withArgName("METHOD").create( 'T' ) ); + options.addOption( OptionBuilder.withLongOpt( "outputDir" ).hasArg().withDescription( "Split the output in a DIRectory (SPARQL)" ).withArgName("DIR").create( 'w' ) ); + } public static void main(String[] args) { try { new ParserPrinter().run( args ); } @@ -89,118 +103,57 @@ public class ParserPrinter { public void run(String[] args) throws Exception { Alignment result = null; String initName = null; - String filename = null; String dirName = null; PrintWriter writer = null; AlignmentVisitor renderer = null; - LongOpt[] longopts = new LongOpt[11]; - int debug = 0; String rendererClass = null; String parserClass = null; boolean inverse = false; boolean embedded = false; double threshold = 0; String cutMethod = "hard"; - Properties params = new Properties(); - - longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); - longopts[1] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'); - longopts[2] = new LongOpt("debug", LongOpt.OPTIONAL_ARGUMENT, null, 'd'); - longopts[3] = new LongOpt("renderer", LongOpt.REQUIRED_ARGUMENT, null, 'r'); - longopts[4] = new LongOpt("parser", LongOpt.REQUIRED_ARGUMENT, null, 'p'); - longopts[5] = new LongOpt("inverse", LongOpt.NO_ARGUMENT, null, 'i'); - longopts[6] = new LongOpt("threshold", LongOpt.REQUIRED_ARGUMENT, null, 't'); - longopts[7] = new LongOpt("cutmethod", LongOpt.REQUIRED_ARGUMENT, null, 'T'); - longopts[8] = new LongOpt("embedded", LongOpt.NO_ARGUMENT, null, 'e'); - longopts[9] = new LongOpt("dirName", LongOpt.REQUIRED_ARGUMENT, null, 'c'); - // Is there a way for that in LongOpt ??? - longopts[10] = new LongOpt("D", LongOpt.REQUIRED_ARGUMENT, null, 'D'); - - Getopt g = new Getopt("", args, "ehio:t:T:d::r:p:c:D:", longopts); - int c; - String arg; - while ((c = g.getopt()) != -1) { - switch(c) { - case 'h': + try { + CommandLine line = parseCommandLine( args ); + if ( line == null ) return; // --help + + // Here deal with command specific arguments + if ( line.hasOption( 'i' ) ) inverse = true; + if ( line.hasOption( 'e' ) ) embedded = true; + if ( line.hasOption( 'c' ) ) dirName = line.getOptionValue( 'c' ); + if ( line.hasOption( 'r' ) ) rendererClass = line.getOptionValue( 'r' ); + if ( line.hasOption( 'p' ) ) parserClass = line.getOptionValue( 'p' ); + if ( line.hasOption( 't' ) ) threshold = Double.parseDouble(line.getOptionValue( 't' )); + if ( line.hasOption( 'T' ) ) cutMethod = line.getOptionValue( 'T' ); + String[] argList = line.getArgs(); + if ( argList.length > 0 ) { + initName = argList[0]; + } else { + logger.error("Require the alignement filename"); usage(); - return; - case 'i': - inverse = true; - break; - case 'e': - embedded = true; - break; - case 'o': - /* Write warnings to stdout rather than stderr */ - filename = g.getOptarg(); - break; - case 'c': - dirName = g.getOptarg(); - break; - case 'r': - /* Use the given class for rendernig */ - rendererClass = g.getOptarg(); - break; - case 'p': - /* Use the given class for rendernig */ - parserClass = g.getOptarg(); - break; - case 't' : - /* Threshold */ - threshold = Double.parseDouble(g.getOptarg()); - break; - case 'T' : - /* Cut method */ - cutMethod = g.getOptarg(); - break; - case 'd': - /* Debug level */ - arg = g.getOptarg(); - if ( arg != null ) debug = Integer.parseInt(arg.trim()); - else debug = 4; - break; - case 'D' : - /* Parameter definition */ - arg = g.getOptarg(); - int index = arg.indexOf('='); - if ( index != -1 ) { - params.setProperty( arg.substring( 0, index), - arg.substring(index+1)); - } else { - System.err.println("Bad parameter syntax: "+g); - usage(); - System.exit(0); - } - break; + System.exit(-1); } - } - - int i = g.getOptind(); - - if (args.length > i ) { - initName = args[i]; - } else { - System.out.println("Require the alignement filename"); + } catch( ParseException exp ) { + logger.error( exp.getMessage() ); usage(); - return; + System.exit(-1); } - if ( debug > 1 ) System.err.println(" Filename"+initName); + //logger.trace("Filename: {}", initName); try { // Create parser AlignmentParser aparser = null; - if ( parserClass == null ) aparser = new AlignmentParser( debug ); + if ( parserClass == null ) aparser = new AlignmentParser(); else { try { - Object[] mparams = { (Object)debug }; - java.lang.reflect.Constructor[] parserConstructors = - Class.forName(parserClass).getConstructors(); - aparser = (AlignmentParser) parserConstructors[0].newInstance(mparams); + Class[] cparams = {}; + java.lang.reflect.Constructor parserConstructor = + Class.forName(parserClass).getConstructor(cparams); + Object[] mparams = {}; + aparser = (AlignmentParser) parserConstructor.newInstance(mparams); } catch (Exception ex) { - System.err.println("Cannot create parser " + - parserClass + "\n" + ex.getMessage() ); + logger.error("Cannot create parser {}", parserClass ); usage(); return; } @@ -208,22 +161,21 @@ public class ParserPrinter { aparser.setEmbedded( embedded ); result = aparser.parse( initName ); - if ( debug > 0 ) System.err.println(" Alignment structure parsed"); + logger.debug(" Alignment structure parsed"); // Set output file OutputStream stream; - if (filename == null) { + if ( outputfilename == null ) { //writer = (PrintStream) System.out; stream = System.out; - } - else { - //writer = new PrintStream(new FileOutputStream(filename)); - stream = new FileOutputStream(filename); + } else { + //writer = new PrintStream(new FileOutputStream(outputfilename)); + stream = new FileOutputStream( outputfilename ); } if ( dirName != null ) { File f = new File(dirName); f.mkdir(); - params.setProperty( "dir", dirName ); - params.setProperty( "split", "true" ); + parameters.setProperty( "dir", dirName ); + parameters.setProperty( "split", "true" ); } writer = new PrintWriter ( new BufferedWriter( @@ -239,19 +191,19 @@ public class ParserPrinter { else { try { Object[] mparams = {(Object) writer }; + // JE: Not terrible: use the right constructor java.lang.reflect.Constructor[] rendererConstructors = Class.forName(rendererClass).getConstructors(); renderer = (AlignmentVisitor) rendererConstructors[0].newInstance(mparams); } catch (Exception ex) { - System.err.println("Cannot create renderer " + - rendererClass + "\n" + ex.getMessage() ); + logger.error( "Cannot create renderer {}", rendererClass ); usage(); return; } } - renderer.init( params ); + renderer.init( parameters ); // Render the alignment try { @@ -264,27 +216,11 @@ public class ParserPrinter { } } catch (Exception ex) { - ex.printStackTrace(); + logger.debug( "IGNORED Exception", ex ); } } public void usage() { - System.out.println("usage: ParserPrinter [options] URI"); - System.out.println("options are:"); - //System.out.println("\t--alignment=filename -a filename Start from an XML alignment file"); - System.out.println("\t--debug[=n] -d [n]\t\tReport debug info at level ,"); - System.out.println("\t--renderer=className -r\t\tUse the given class for output."); - System.out.println("\t--parser=className -p\t\tUse the given class for input."); - System.out.println("\t--embedded -e\t\tRead the alignment as embedded in XML file"); - System.out.println("\t--inverse -i\t\tInverse first and second ontology"); - System.out.println("\t--threshold=threshold -t threshold\t\tTrim the alugnment with regard to threshold"); - System.out.println("\t--cutmethod=hard|perc|prop|best|span -T hard|perc|prop|best|span\t\tMethod to use for triming"); - System.out.println("\t--output=filename -o filename\tOutput the alignment in filename"); - System.out.println("\t--outputDir=dirName -c dirName\tSplit the output in a directory (SPARQL)"); - System.out.println("\t--help -h\t\t\tPrint this message"); - System.err.println("\t-Dparam=value\t\t\tSet parameter"); - System.err.print("\n"+ParserPrinter.class.getPackage().getImplementationTitle()+" "+ParserPrinter.class.getPackage().getImplementationVersion()); - System.err.println(" ($Id$)\n"); - + usage( "java "+this.getClass().getName()+" [options] alignfile\nParse the given <alignfile> and prints it" ); } } diff --git a/src/fr/inrialpes/exmo/align/cli/Procalign.java b/src/fr/inrialpes/exmo/align/cli/Procalign.java index 7a3103d1811664a7396f983f2e40d9b939b7a6c7..7bac26a637e0e9fab2deb9ca0081de502b9bc2b8 100644 --- a/src/fr/inrialpes/exmo/align/cli/Procalign.java +++ b/src/fr/inrialpes/exmo/align/cli/Procalign.java @@ -1,8 +1,6 @@ /* * $Id$ * - * Copyright (C) 2003 The University of Manchester - * Copyright (C) 2003 The University of Karlsruhe * Copyright (C) 2003-2008, 2010-2013 INRIA * Copyright (C) 2004, Université de Montréal * @@ -22,9 +20,6 @@ * USA. */ -/* This program is an adaptation of the Processor.java class of the - initial release of the OWL-API -*/ package fr.inrialpes.exmo.align.cli; import org.semanticweb.owl.align.Alignment; @@ -36,21 +31,27 @@ import fr.inrialpes.exmo.align.impl.Namespace; import java.io.OutputStream; import java.io.FileOutputStream; -import java.io.FileInputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.OutputStreamWriter; import java.net.URI; +import java.net.URISyntaxException; import java.util.Hashtable; import java.util.Properties; import java.lang.Double; import java.lang.Integer; import java.lang.Long; +import java.lang.reflect.Constructor; import org.xml.sax.SAXException; -import gnu.getopt.LongOpt; -import gnu.getopt.Getopt; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.ParseException; import fr.inrialpes.exmo.align.parser.AlignmentParser; @@ -71,7 +72,6 @@ import fr.inrialpes.exmo.align.parser.AlignmentParser; <pre> --alignment=filename -a filename Start from an XML alignment file --params=filename -p filename Read the parameters in file - --debug[=n] -d [n] Report debug info at level n, --output=filename -o filename Output the alignment in filename --impl=className -i classname Use the given alignment implementation. --renderer=className -r className Specifies the alignment renderer @@ -86,15 +86,27 @@ import fr.inrialpes.exmo.align.parser.AlignmentParser; $Id$ </pre> -@author Sean K. Bechhofer @author Jérôme Euzenat - */ +*/ -public class Procalign { +public class Procalign extends CommonCLI { + final static Logger logger = LoggerFactory.getLogger( Procalign.class ); - public static void main(String[] args) { + public Procalign() { + super(); + options.addOption( OptionBuilder.withLongOpt( "renderer" ).hasArg().withDescription( "Use the given CLASS for output" ).withArgName("CLASS").create( 'r' ) ); + options.addOption( OptionBuilder.withLongOpt( "impl" ).hasArg().withDescription( "Use the given CLASS for matcher" ).withArgName("CLASS").create( 'i' ) ); + options.addOption( OptionBuilder.withLongOpt( "alignment" ).hasArg().withDescription( "Use initial alignment FILE" ).withArgName("FILE").create( 'a' ) ); + options.addOption( OptionBuilder.withLongOpt( "threshold" ).hasArg().withDescription( "Trim the alignment with regard to threshold" ).withArgName("DOUBLE").create( 't' ) ); + options.addOption( OptionBuilder.withLongOpt( "cutmethod" ).hasArg().withDescription( "Method to use for triming (hard|perc|prop|best|span)" ).withArgName("METHOD").create( 'T' ) ); + } + + public static void main( String[] args ) { try { new Procalign().run( args ); } - catch ( Exception ex ) { ex.printStackTrace(); }; + catch ( Exception ex ) { + ex.printStackTrace(); + System.exit(-1); + }; } public Alignment run(String[] args) throws Exception { @@ -105,152 +117,84 @@ public class Procalign { String initName = null; Alignment init = null; String alignmentClassName = "fr.inrialpes.exmo.align.impl.method.StringDistAlignment"; - String filename = null; - String paramfile = null; String rendererClass = "fr.inrialpes.exmo.align.impl.renderer.RDFRendererVisitor"; PrintWriter writer = null; AlignmentVisitor renderer = null; - int debug = 0; double threshold = 0; - Properties params = new Properties(); - - LongOpt[] longopts = new LongOpt[10]; - - longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); - longopts[1] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'); - longopts[2] = new LongOpt("alignment", LongOpt.REQUIRED_ARGUMENT, null, 'a'); - longopts[3] = new LongOpt("renderer", LongOpt.REQUIRED_ARGUMENT, null, 'r'); - longopts[4] = new LongOpt("debug", LongOpt.OPTIONAL_ARGUMENT, null, 'd'); - longopts[5] = new LongOpt("impl", LongOpt.REQUIRED_ARGUMENT, null, 'i'); - longopts[6] = new LongOpt("threshold", LongOpt.REQUIRED_ARGUMENT, null, 't'); - longopts[7] = new LongOpt("cutmethod", LongOpt.REQUIRED_ARGUMENT, null, 'T'); - longopts[8] = new LongOpt("params", LongOpt.REQUIRED_ARGUMENT, null, 'p'); - // Is there a way for that in LongOpt ??? - longopts[9] = new LongOpt("D", LongOpt.REQUIRED_ARGUMENT, null, 'D'); - - Getopt g = new Getopt("", args, "ho:a:p:d::r:t:T:i:D:", longopts); - int c; - String arg; - - while ((c = g.getopt()) != -1) { - switch (c) { - case 'h' : + CommandLine line = null; + + try { + line = parseCommandLine( args ); + } catch( ParseException exp ) { + logger.error( "Cannot parse command line", exp ); + usage(); + exit( -1 ); + } + if ( line == null ) exit(1); // --help + if ( line.hasOption( 'r' ) ) rendererClass = line.getOptionValue( 'r' ); + if ( line.hasOption( 'i' ) ) alignmentClassName = line.getOptionValue( 'i' ); + if ( line.hasOption( 'a' ) ) initName = line.getOptionValue( 'a' ); + if ( line.hasOption( 't' ) ) threshold = Double.parseDouble(line.getOptionValue( 't' )); + if ( line.hasOption( 'T' ) ) cutMethod = line.getOptionValue( 'T' ); + String[] argList = line.getArgs(); + if ( argList.length > 1 ) { + try { + onto1 = new URI( argList[0] ); + onto2 = new URI( argList[1] ); + } catch( URISyntaxException usex ) { + logger.error( "Error in ontology URIs", usex ); usage(); - return null; - case 'o' : - /* Use filename instead of stdout */ - filename = g.getOptarg(); - break; - case 'p' : - /* Read parameters from filename */ - paramfile = g.getOptarg(); - params.loadFromXML( new FileInputStream( paramfile ) ); - break; - case 'r' : - /* Use the given class for rendering */ - rendererClass = g.getOptarg(); - break; - case 'i' : - /* Use the given class for the alignment */ - alignmentClassName = g.getOptarg(); - break; - case 'a' : - /* Use the given file as a partial alignment */ - initName = g.getOptarg(); - break; - case 't' : - /* Threshold */ - threshold = Double.parseDouble(g.getOptarg()); - break; - case 'T' : - /* Cut method */ - cutMethod = g.getOptarg(); - break; - case 'd' : - /* Debug level */ - arg = g.getOptarg(); - if ( arg != null ) debug = Integer.parseInt(arg.trim()); - else debug = 4; - break; - case 'D' : - /* Parameter definition */ - arg = g.getOptarg(); - int index = arg.indexOf('='); - if ( index != -1 ) { - params.setProperty( arg.substring( 0, index), - arg.substring(index+1)); - } else { - System.err.println("Bad parameter syntax: "+g); - usage(); - System.exit(0); - } - break; + exit( -1 ); } + } else { + logger.error( "Require the ontology URIs" ); + usage(); + exit(-1); } - - int i = g.getOptind(); - if (debug > 0) { - params.setProperty( "debug", Integer.toString(debug) ); - } else if ( params.getProperty("debug") != null ) { - debug = Integer.parseInt( params.getProperty("debug") ); - } + logger.debug( "Ready to match {} and {}", onto1, onto2 ); try { - URI uri1 = null; - URI uri2 = null; - - if (args.length > i + 1) { - uri1 = new URI(args[i++]); - uri2 = new URI(args[i]); - } else if (initName == null) { - System.err.println("Two URIs required"); - usage(); - System.exit(0); + if (initName != null) { + AlignmentParser aparser = new AlignmentParser(); + Alignment al = aparser.parse( initName ); + init = al; + logger.debug("Init parsed"); } - if (debug > 0) System.err.println(" Ready"); + // Create alignment object + Class<?> alignmentClass = Class.forName( alignmentClassName ); + Class[] cparams = {}; + Constructor alignmentConstructor = alignmentClass.getConstructor(cparams); + Object[] mparams = {}; + result = (AlignmentProcess)alignmentConstructor.newInstance(mparams); + result.init( onto1, onto2 ); + } catch ( Exception ex ) { + logger.error( "Cannot create alignment {}", alignmentClassName ); + usage(); + throw ex; + } - try { - if (initName != null) { - AlignmentParser aparser = new AlignmentParser(debug); - Alignment al = aparser.parse( initName ); - init = al; - if (debug > 0) System.err.println(" Init parsed"); - } + logger.debug("Alignment structure created"); - // Create alignment object - Object[] mparams = {}; - Class<?> alignmentClass = Class.forName(alignmentClassName); - Class[] cparams = {}; - java.lang.reflect.Constructor alignmentConstructor = alignmentClass.getConstructor(cparams); - result = (AlignmentProcess)alignmentConstructor.newInstance(mparams); - result.init( uri1, uri2 ); - } catch (Exception ex) { - System.err.println("Cannot create alignment "+alignmentClassName+"\n" - +ex.getMessage()); - usage(); - throw ex; - } - - if (debug > 0) System.err.println(" Alignment structure created"); + try { // Compute alignment long time = System.currentTimeMillis(); - result.align( init, params ); // add opts + result.align( init, parameters ); // add opts long newTime = System.currentTimeMillis(); result.setExtension( Namespace.ALIGNMENT.uri, Annotations.TIME, Long.toString(newTime - time) ); // Thresholding if (threshold != 0) result.cut( cutMethod, threshold ); - if (debug > 0) System.err.println(" Matching performed"); + logger.debug( "Matching performed" ); // Set output file OutputStream stream; - if (filename == null) { + if ( outputfilename == null ) { stream = System.out; } else { - stream = new FileOutputStream(filename); + stream = new FileOutputStream( outputfilename ); } writer = new PrintWriter ( new BufferedWriter( @@ -261,18 +205,19 @@ public class Procalign { Object[] mparams = {(Object) writer }; java.lang.reflect.Constructor[] rendererConstructors = Class.forName(rendererClass).getConstructors(); + // JE: Not terrible: use the right constructor renderer = (AlignmentVisitor) rendererConstructors[0].newInstance(mparams); } catch (Exception ex) { - System.err.println("Cannot create renderer "+rendererClass+"\n" - + ex.getMessage()); + logger.error( "Cannot create renderer {}", rendererClass ); usage(); throw ex; } // Output result.render(renderer); - } catch (Exception ex) { + logger.debug( "Output printed" ); + } catch ( Exception ex ) { throw ex; } finally { if ( writer != null ) { @@ -284,18 +229,6 @@ public class Procalign { } public void usage() { - System.err.println(Procalign.class.getPackage().getImplementationTitle()+" "+Procalign.class.getPackage().getImplementationVersion()); - System.err.println("\nusage: Procalign [options] URI1 URI2"); - System.err.println("options are:"); - System.err.println("\t--impl=className -i classname\t\tUse the given alignment implementation."); - System.err.println("\t--renderer=className -r className\tSpecifies the alignment renderer"); - System.err.println("\t--output=filename -o filename\tOutput the alignment in filename"); - System.err.println("\t--params=filename -p filename\tReads parameters from filename"); - System.err.println("\t--alignment=filename -a filename Start from an XML alignment file"); - System.err.println("\t--threshold=double -t double\tFilters the similarities under threshold"); - System.err.println("\t--cutmethod=hard|perc|prop|best|span -T hard|perc|prop|best|span\tmethod for computing the threshold"); - System.err.println("\t--debug[=n] -d [n]\t\tReport debug info at level n"); - System.err.println("\t-Dparam=value\t\t\tSet parameter"); - System.err.println("\t--help -h\t\t\tPrint this message"); + usage( "java "+this.getClass().getName()+" [options] ontoURI ontoURI\nMatches the two ontologies identified by <ontoURI>" ); } } diff --git a/src/fr/inrialpes/exmo/align/cli/TestGen.java b/src/fr/inrialpes/exmo/align/cli/TestGen.java index 33be1e29e3c159a77cdbb9966a26db177257445f..b5077d292f520633c34a24f6987c1249058a28b4 100644 --- a/src/fr/inrialpes/exmo/align/cli/TestGen.java +++ b/src/fr/inrialpes/exmo/align/cli/TestGen.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2011-2012, INRIA + * Copyright (C) 2011-2013, INRIA * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -21,11 +21,17 @@ package fr.inrialpes.exmo.align.cli; -import gnu.getopt.Getopt; -import gnu.getopt.LongOpt; - import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.Option; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.ParseException; + import fr.inrialpes.exmo.align.gen.TestGenerator; import fr.inrialpes.exmo.align.gen.BenchmarkGenerator; import fr.inrialpes.exmo.align.gen.TestSet; @@ -40,23 +46,29 @@ import fr.inrialpes.exmo.align.gen.ParametersIds; </pre> where filename is the seed ontology, - and the options are: - <pre> - --debug[=n] -d [n] --> Report debug info at level n, - </pre> */ -public class TestGen { - private Properties params = null; - private String methodName = null; //the name of the method - private String fileName = null; //the name of the input file - private String dir = "."; // - private String url; // - private int debug = 0; +public class TestGen extends CommonCLI { + final static Logger logger = LoggerFactory.getLogger( TestGen.class ); + + private String methodName = null; //the name of the method + private String fileName = "onto.rdf"; //the name of the input file + private String dir = "."; // + private String url; // public TestGen() { - fileName = "onto.rdf"; + super(); + options.addOption( OptionBuilder.withLongOpt( "testset" ).hasArg().withDescription( "Use CLASS for generating the test set" ).withArgName("CLASS").create( 't' ) ); + options.addOption( OptionBuilder.withLongOpt( "outdir" ).hasArg().withDescription( "Output DIRectory (default: current)" ).withArgName("DIR").create( 'w' ) ); + options.addOption( OptionBuilder.withLongOpt( "uriprefix" ).hasArg().withDescription( "URI prefix of the seed ontology (REQUIRED)" ).withArgName("URI").create( 'u' ) ); + options.addOption( OptionBuilder.withLongOpt( "alignname" ).hasArg().withDescription( "FILEname of generated alignment (default: refalign.rdf)" ).withArgName("FILE").create( 'a' ) ); + // .setRequired( true ) + Option opt = options.getOption( "uriprefix" ); + if ( opt != null ) opt.setRequired( true ); + // We redefine the message for -o + opt = options.getOption( "output" ); + if ( opt != null ) opt.setDescription( "FILEname of the generated ontology (default: "+fileName+")" ); } public static void main(String[] args) { @@ -65,83 +77,49 @@ public class TestGen { } public void run(String[] args) throws Exception { - LongOpt[] longopts = new LongOpt[10]; - params = new Properties(); - - longopts[0] = new LongOpt("testset", LongOpt.REQUIRED_ARGUMENT, null, 't'); - longopts[1] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); - longopts[2] = new LongOpt("debug", LongOpt.OPTIONAL_ARGUMENT, null, 'd'); - longopts[3] = new LongOpt("outdir", LongOpt.REQUIRED_ARGUMENT, null, 'o'); - longopts[4] = new LongOpt("urlprefix", LongOpt.REQUIRED_ARGUMENT, null, 'u'); - longopts[5] = new LongOpt("ontoname", LongOpt.REQUIRED_ARGUMENT, null, 'n'); - longopts[6] = new LongOpt("alignname", LongOpt.REQUIRED_ARGUMENT, null, 'a'); - longopts[7] = new LongOpt("D", LongOpt.REQUIRED_ARGUMENT, null, 'D'); - - Getopt g = new Getopt("", args, "d::o:u:m:n:a:D:t:h", longopts); - int c; - String arg; - - while ((c = g.getopt()) != -1) { - switch (c) { - case 'h': + try { + CommandLine line = parseCommandLine( args ); + if ( line == null ) return; // --help + + outputfilename = fileName; // likely useless + + // Here deal with command specific arguments + if ( line.hasOption( 't' ) ) methodName = line.getOptionValue( 't' ); + if ( line.hasOption( 'o' ) ) parameters.setProperty( "ontoname", line.getOptionValue( 'o' ) ); + if ( line.hasOption( 'a' ) ) parameters.setProperty( "alignname", line.getOptionValue( 'a' ) ); + if ( line.hasOption( 'w' ) ) { + dir = line.getOptionValue( 'w' ); + parameters.setProperty( "outdir", dir ); + } + if ( line.hasOption( 'u' ) ) { + url = line.getOptionValue( 'u' ); + parameters.setProperty( "urlprefix", url ); // JE: Danger urlprefix/uriprefix + } + String[] argList = line.getArgs(); + if ( argList.length > 0 ) { + fileName = argList[0]; + parameters.setProperty( "filename", fileName ); + } else { + logger.error("Require the seed ontology filename"); usage(); - return; - case 't': - methodName = g.getOptarg(); - break; - case 'n': - params.setProperty( "ontoname", g.getOptarg() ); - break; - case 'a': - params.setProperty( "alignname", g.getOptarg() ); - break; - case 'o' : /* Use output directory */ - dir = g.getOptarg(); - params.setProperty( "outdir", dir ); - break; - case 'u' : /* URLPrefix */ - url = g.getOptarg(); - params.setProperty( "urlprefix", url ); - break; - case 'd' : /* Debug level */ - arg = g.getOptarg(); - if ( arg != null ) params.setProperty( "debug", arg.trim() ); - else params.setProperty( "debug", "4" ); - break; - case 'D' : /* Parameter definition: could be used for all parameters */ - arg = g.getOptarg(); - int index = arg.indexOf('='); - if ( index != -1 ) { - params.setProperty( arg.substring( 0, index), - arg.substring(index+1)); - } else { - System.err.println("Bad parameter syntax: "+g); - usage(); - System.exit(0); - } - break; + System.exit(-1); } - } - - // We need an ontology - int i = g.getOptind(); - - if ( args.length > i ) { - fileName = args[i]; - params.setProperty( "filename", fileName ); - } else { - System.out.println("Require the seed ontology filename"); + } catch( ParseException exp ) { + logger.error( exp.getMessage() ); usage(); - return; + System.exit(-1); } - if ( debug > 0 ) System.err.println( " >>>> "+methodName+" from "+fileName ); + logger.debug( " >>>> {} from {}", methodName, fileName ); if ( methodName == null ) { // generate one test TestGenerator tg = new TestGenerator(); + // It would certainly be better to initialise the generator with parameters tg.setDirPrefix( dir ); tg.setURLPrefix( url ); - tg.modifyOntology( fileName, (Properties)null, (String)null, params ); + if ( parameters.getProperty( "ontoname" ) != null ) tg.setOntoFilename( parameters.getProperty( "ontoname" ) ); + if ( parameters.getProperty( "alignname" ) != null ) tg.setAlignFilename( parameters.getProperty( "alignname" ) ); + tg.modifyOntology( fileName, (Properties)null, (String)null, parameters ); } else { // generate a test set TestSet tset = null; try { @@ -151,38 +129,30 @@ public class TestGen { java.lang.reflect.Constructor testSetConstructor = testSetClass.getConstructor(cparams); tset = (TestSet)testSetConstructor.newInstance(mparams); } catch (Exception ex) { - System.err.println("Cannot create TestSet "+methodName+"\n"+ex.getMessage()); + logger.error("Cannot create TestSet {}", methodName ); + logger.error("Caught error", ex ); usage(); - throw ex; + System.exit(-1); } - tset.generate( params ); + tset.generate( parameters ); } } public void usage() { - System.out.println("TestGen [options] filename"); - System.out.println("such that filename is the filename of the seed ontology\n"); - System.out.println("options are:"); - System.out.println("\t--urlprefix=url"); - System.out.println("\t--testset=classname, where classname is the name of an implementation of TestSet"); - System.out.println("\t--alignname=filename [default: refalign.rdf]"); - System.out.println("\t--ontoname=filename [default: onto.rdf]"); - System.out.println("\t--outdir=directory [default: .]"); - System.out.println("\t--help"); - System.out.println("\t--debug=number [default: 0]"); - System.out.println("\t-Dparameter=value"); - System.out.println("where the parameters are"); - System.out.println( "\tRemove percentage subclasses \""+ParametersIds.REMOVE_CLASSES+"\"" ); - System.out.println( "\tRemove percentage properties \""+ParametersIds.REMOVE_PROPERTIES+"\"" ); - System.out.println( "\tRemove percentage comments \""+ParametersIds.REMOVE_COMMENTS+"\"" ); - System.out.println( "\tRemove percentage restrictions \""+ParametersIds.REMOVE_RESTRICTIONS+"\"" ); - System.out.println( "\tRemove individuals \""+ParametersIds.REMOVE_INDIVIDUALS+"\"" ); - System.out.println( "\tAdd percentage subclasses \""+ParametersIds.ADD_CLASSES+"\"" ); - System.out.println( "\tAdd percentage properties \""+ParametersIds.ADD_PROPERTIES+"\"" ); - System.out.println( "\tRename percentage classes \""+ParametersIds.RENAME_CLASSES+"\"" ); - System.out.println( "\tRename percentage properties \""+ParametersIds.RENAME_PROPERTIES+"\"" ); - System.out.println( "\tnoHierarchy \""+ParametersIds.NO_HIERARCHY+"\"" ); - System.out.println( "\tLevel flattened \""+ParametersIds.LEVEL_FLATTENED+"\"" ); - System.out.println( "\tAdd nbClasses to a specific level \""+ParametersIds.ADD_CLASSESLEVEL+"\"" ); + usage( "java "+this.getClass().getName()+" [options] -u uriprefix filename\nGenerate ontology matching tests from the seed ontology file", + "Such that parameters may be:"+ + "\tRemove percentage subclasses \""+ParametersIds.REMOVE_CLASSES+"\""+ + "\tRemove percentage properties \""+ParametersIds.REMOVE_PROPERTIES+"\""+ + "\tRemove percentage comments \""+ParametersIds.REMOVE_COMMENTS+"\""+ + "\tRemove percentage restrictions \""+ParametersIds.REMOVE_RESTRICTIONS+"\""+ + "\tRemove individuals \""+ParametersIds.REMOVE_INDIVIDUALS+"\""+ + "\tAdd percentage subclasses \""+ParametersIds.ADD_CLASSES+"\""+ + "\tAdd percentage properties \""+ParametersIds.ADD_PROPERTIES+"\""+ + "\tRename percentage classes \""+ParametersIds.RENAME_CLASSES+"\""+ + "\tRename percentage properties \""+ParametersIds.RENAME_PROPERTIES+"\""+ + "\tnoHierarchy \""+ParametersIds.NO_HIERARCHY+"\""+ + "\tLevel flattened \""+ParametersIds.LEVEL_FLATTENED+"\""+ + "\tAdd nbClasses to a specific level \""+ParametersIds.ADD_CLASSESLEVEL+"\"" + ); } } diff --git a/src/fr/inrialpes/exmo/align/cli/WGroupEval.java b/src/fr/inrialpes/exmo/align/cli/WGroupEval.java index efc5656f93e8cc557b96654878302f9cf044f290..4dc2580fc57cdbc5737cde70210c226027a59e8e 100644 --- a/src/fr/inrialpes/exmo/align/cli/WGroupEval.java +++ b/src/fr/inrialpes/exmo/align/cli/WGroupEval.java @@ -1,9 +1,7 @@ /* * $Id$ * - * Copyright (C) 2003 The University of Manchester - * Copyright (C) 2003 The University of Karlsruhe - * Copyright (C) 2003-2012, INRIA + * Copyright (C) 2003-2014, INRIA * Copyright (C) 2004, Université de Montréal * * This program is free software; you can redistribute it and/or @@ -47,8 +45,14 @@ import java.util.Properties; import org.xml.sax.SAXException; -import gnu.getopt.LongOpt; -import gnu.getopt.Getopt; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.Option; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.ParseException; import fr.inrialpes.exmo.align.parser.AlignmentParser; @@ -64,7 +68,6 @@ import fr.inrialpes.exmo.align.parser.AlignmentParser; <pre> -o filename --output=filename -f format = prfot (precision/recall/f-measure/overall/time) --format=prfot - -d debug --debug=level -r filename --reference=filename -s algo/measure -l list of compared algorithms @@ -82,108 +85,65 @@ import fr.inrialpes.exmo.align.parser.AlignmentParser; $Id$ </pre> -@author Sean K. Bechhofer -@author Jérôme Euzenat - */ +*/ -public class WGroupEval { +public class WGroupEval extends CommonCLI { + final static Logger logger = LoggerFactory.getLogger( WGroupEval.class ); - Properties params = null; - String filename = null; String reference = "refalign.rdf"; String format = "pr"; int fsize = 2; String type = "html"; boolean embedded = false; String dominant = "s"; - Vector<String> listAlgo = null; - int debug = 0; + String[] listAlgo = null; + int size = 0; String color = null; String ontoDir = null; + public WGroupEval() { + super(); + options.addOption( OptionBuilder.withLongOpt( "list" ).hasArgs().withValueSeparator(',').withDescription( "List of FILEs to be included in the results (required)" ).withArgName("FILE").create( 'l' ) ); + options.addOption( OptionBuilder.withLongOpt( "color" ).hasOptionalArg().withDescription( "Color even lines of the output in COLOR (default: lightblue)" ).withArgName("COLOR").create( 'c' ) ); + options.addOption( OptionBuilder.withLongOpt( "format" ).hasArg().withDescription( "Used (weighted) MEASures and order (precision/recall/f-measure/overall/time) (default: "+format+")" ).withArgName("MEAS (prfot)").create( 'f' ) ); + options.addOption( OptionBuilder.withLongOpt( "type" ).hasArg().withDescription( "Output TYPE (html|xml|tex|ascii|triangle; default: "+type+")" ).withArgName("TYPE").create( 't' ) ); + //options.addOption( OptionBuilder.withLongOpt( "sup" ).hasArg().withDescription( "Specifies if dominant columns are algorithms or measure" ).withArgName("algo").create( 's' ) ); + options.addOption( OptionBuilder.withLongOpt( "reference" ).hasArg().withDescription( "Name of the reference alignment FILE (default: "+reference+")" ).withArgName("FILE").create( 'r' ) ); + options.addOption( OptionBuilder.withLongOpt( "directory" ).hasOptionalArg().withDescription( "The DIRectory containing the data to evaluate" ).withArgName("DIR").create( 'w' ) ); + // .setRequired( true ) + Option opt = options.getOption( "list" ); + if ( opt != null ) opt.setRequired( true ); + } + + public static void main(String[] args) { try { new WGroupEval().run( args ); } catch (Exception ex) { ex.printStackTrace(); }; } public void run(String[] args) throws Exception { - String listFile = ""; - LongOpt[] longopts = new LongOpt[10]; - - longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); - longopts[1] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'); - longopts[2] = new LongOpt("format", LongOpt.REQUIRED_ARGUMENT, null, 'f'); - longopts[3] = new LongOpt("type", LongOpt.REQUIRED_ARGUMENT, null, 't'); - longopts[4] = new LongOpt("debug", LongOpt.OPTIONAL_ARGUMENT, null, 'd'); - longopts[5] = new LongOpt("sup", LongOpt.REQUIRED_ARGUMENT, null, 's'); - longopts[6] = new LongOpt("list", LongOpt.REQUIRED_ARGUMENT, null, 'l'); - longopts[7] = new LongOpt("color", LongOpt.OPTIONAL_ARGUMENT, null, 'c'); - longopts[8] = new LongOpt("reference", LongOpt.REQUIRED_ARGUMENT, null, 'r'); - longopts[9] = new LongOpt("directory", LongOpt.REQUIRED_ARGUMENT, null, 'w'); - - Getopt g = new Getopt("", args, "ho:a:d::l:f:t:r:w:c::", longopts); - int c; - String arg; - - while ((c = g.getopt()) != -1) { - switch (c) { - case 'h' : - usage(); - return; - case 'o' : - /* Write output here */ - filename = g.getOptarg(); - break; - case 'r' : - /* File name for the reference alignment */ - reference = g.getOptarg(); - break; - case 'f' : - /* Sequence of results to print */ - format = g.getOptarg(); - break; - case 't' : - /* Type of output (tex/html/xml/ascii) */ - type = g.getOptarg(); - break; - case 's' : - /* Print per type or per algo */ - dominant = g.getOptarg(); - break; - case 'c' : - /* Print colored lines */ - arg = g.getOptarg(); - if ( arg != null ) { - color = arg.trim(); - } else color = "lightblue"; - break; - case 'l' : - /* List of filename */ - listFile = g.getOptarg(); - break; - case 'd' : - /* Debug level */ - arg = g.getOptarg(); - if ( arg != null ) debug = Integer.parseInt(arg.trim()); - else debug = 4; - break; - case 'w' : - /* Use the given ontology directory */ - arg = g.getOptarg(); - if ( arg != null ) ontoDir = g.getOptarg(); - else ontoDir = null; - break; - } - } - listAlgo = new Vector<String>(); - for ( String s : listFile.split(",") ) { - listAlgo.add( s ); + try { + CommandLine line = parseCommandLine( args ); + if ( line == null ) return; // --help + + // Here deal with command specific arguments + if ( line.hasOption( 'f' ) ) format = line.getOptionValue( 'f' ); + if ( line.hasOption( 'r' ) ) reference = line.getOptionValue( 'r' ); + if ( line.hasOption( 's' ) ) dominant = line.getOptionValue( 's' ); + if ( line.hasOption( 't' ) ) type = line.getOptionValue( 't' ); + if ( line.hasOption( 'c' ) ) color = line.getOptionValue( 'c', "lightblue" ); + if ( line.hasOption( 'l' ) ) { + listAlgo = line.getOptionValues( 'l' ); + size = listAlgo.length; + } + if ( line.hasOption( 'w' ) ) ontoDir = line.getOptionValue( 'w' ); + } catch( ParseException exp ) { + logger.error( exp.getMessage() ); + usage(); + System.exit( -1 ); } - params = new Properties(); - if (debug > 0) params.setProperty( "debug", Integer.toString( debug-1 ) ); - print( iterateDirectories() ); } @@ -197,8 +157,9 @@ public class WGroupEval { subdir = (new File(ontoDir)).listFiles(); } } catch (Exception e) { - System.err.println("Cannot stat dir "+ e.getMessage()); + logger.error("Cannot stat dir ", e); usage(); + System.exit(-1); } int size = subdir.length; Arrays.sort(subdir); @@ -206,7 +167,7 @@ public class WGroupEval { int i = 0; for ( int j=0 ; j < size; j++ ) { if( subdir[j].isDirectory() ) { - if ( debug > 0 ) System.err.println("\nEntering directory "+subdir[j]); + //logger.trace("Entering directory {}", subdir[j]); // eval the alignments in a subdirectory // store the result Vector vect = iterateAlignments( subdir[j] ); @@ -231,7 +192,7 @@ public class WGroupEval { // call eval // store the result in a record // return the record. - if ( debug > 2) System.err.println(" Considering result "+i); + //logger.trace(" Considering result {}", i); Evaluator evaluator = eval( prefix+reference, prefix+m+".rdf"); if ( evaluator != null ) ok = true; result.add( i, evaluator ); @@ -239,8 +200,8 @@ public class WGroupEval { // Unload the ontologies. try { OntologyFactory.clear(); - } catch ( OntowrapException owex ) { // only report - owex.printStackTrace(); + } catch ( OntowrapException owex ) { + logger.debug( "IGNORED Exception", owex ); } if ( ok == true ) return result; @@ -250,57 +211,69 @@ public class WGroupEval { public Evaluator eval( String alignName1, String alignName2 ) { Evaluator eval = null; try { - int nextdebug; - if ( debug < 2 ) nextdebug = 0; - else nextdebug = debug - 2; // Load alignments - AlignmentParser aparser = new AlignmentParser( nextdebug ); + AlignmentParser aparser = new AlignmentParser(); Alignment align1 = aparser.parse( alignName1 ); - if ( debug > 2 ) System.err.println(" Alignment structure1 parsed"); + //logger.trace(" Alignment structure1 parsed"); aparser.initAlignment( null ); Alignment align2 = aparser.parse( alignName2 ); - if ( debug > 2 ) System.err.println(" Alignment structure2 parsed"); + //logger.trace(" Alignment structure2 parsed"); // Create evaluator object eval = new WeightedPREvaluator( align1, align2 ); // Compare - params.setProperty( "debug", Integer.toString( nextdebug ) ); - eval.eval( params ) ; + eval.eval( parameters ) ; } catch (Exception ex) { - if ( debug > 1 ) { - ex.printStackTrace(); - } else { - System.err.println("WGroupEval: "+ex); - System.err.println(alignName1+ " - "+alignName2 ); - } + logger.debug( "IGNORED Exception", ex ); }; return eval; } + /** + * The writer used to print the result + */ + PrintStream writer = null; + /** * This does not only print the results but compute the average as well */ public void print( Vector<Vector> result ) { - if ( type.equals("html") ) printHTML( result ); - else if ( type.equals("tex") ) printLATEX( result ); - else if ( type.equals("triangle") ) printTRIANGLE( result ); + PrintStream writer = null; + try { + if ( outputfilename == null ) { + writer = System.out; + } else { + writer = new PrintStream( new FileOutputStream( outputfilename ) ); + } + + if ( type.equals("html") ) printHTML( result, writer ); + else if ( type.equals("tex") ) printLATEX( result, writer ); + else if ( type.equals("triangle") ) printTRIANGLE( result, writer ); + } catch (Exception ex) { + logger.debug( "IGNORED Exception", ex ); + } finally { + writer.close(); + } } - public void printTRIANGLE( Vector<Vector> result ) { + public void printTRIANGLE( Vector<Vector> result, PrintStream writer ) { // variables for computing iterative harmonic means double expected = 0.; // expected so far double foundVect[]; // found so far - double correctVect[]; // correct so far + double correctFoundVect[]; // correct so far + double correctExpVect[]; // correct so far long timeVect[]; // time so far - foundVect = new double[ listAlgo.size() ]; - correctVect = new double[ listAlgo.size() ]; - timeVect = new long[ listAlgo.size() ]; - for( int k = listAlgo.size()-1; k >= 0; k-- ) { + foundVect = new double[ size ]; + correctFoundVect = new double[ size ]; + correctExpVect = new double[ size ]; + timeVect = new long[ size ]; + for( int k = size-1; k >= 0; k-- ) { foundVect[k] = 0.; - correctVect[k] = 0.; + correctFoundVect[k] = 0.; + correctExpVect[k] = 0.; timeVect[k] = 0; } for ( Vector test : result ) { - int nexpected = -1; + double newexpected = -1.; Enumeration f = test.elements(); // Too bad the first element must be skipped f.nextElement(); @@ -308,56 +281,59 @@ public class WGroupEval { WeightedPREvaluator eval = (WeightedPREvaluator)f.nextElement(); if ( eval != null ){ // iterative H-means computation - if ( nexpected == -1 ){ - nexpected = 0; - expected += eval.getExpected(); + if ( newexpected == -1. ){ + newexpected = eval.getExpected(); + expected += newexpected; } foundVect[k] += eval.getFound(); - correctVect[k] += eval.getCorrect(); + correctFoundVect[k] += eval.getCorrectFound(); + correctExpVect[k] += eval.getCorrectExpected(); timeVect[k] += eval.getTime(); + } else { + correctExpVect[k] += newexpected; } } } - System.out.println("\\documentclass[11pt]{book}"); - System.out.println(); - System.out.println("\\usepackage{pgf}"); - System.out.println("\\usepackage{tikz}"); - System.out.println(); - System.out.println("\\begin{document}"); - System.out.println("\\date{today}"); - System.out.println(""); - System.out.println("\n%% Plot generated by GenPlot of alignapi"); - System.out.println("\\begin{tikzpicture}[cap=round]"); - System.out.println("% Draw grid"); - System.out.println("\\draw[step=1cm,very thin,color=gray] (-0.2,-0.2) grid (10.0,9.0);"); - System.out.println("\\draw[|-|] (-0,0) -- (10,0);"); - System.out.println("%\\draw[dashed,very thin] (0,0) -- (5,8.66) -- (10,0);"); - System.out.println("\\draw[dashed,very thin] (10,0) arc (0:60:10cm);"); - System.out.println("\\draw[dashed,very thin] (0,0) arc (180:120:10cm);"); - - System.out.println("\\draw (0,-0.3) node {$recall$}; "); - System.out.println("\\draw (10,-0.3) node {$precision$}; "); - //System.out.println("\\draw (0,-0.3) node {0.}; "); - //System.out.println("\\draw (10,-0.3) node {1.}; "); - System.out.println("% Plots"); + writer.println("\\documentclass[11pt]{book}"); + writer.println(); + writer.println("\\usepackage{pgf}"); + writer.println("\\usepackage{tikz}"); + writer.println(); + writer.println("\\begin{document}"); + writer.println("\\date{today}"); + writer.println(""); + writer.println("\n%% Plot generated by GenPlot of alignapi"); + writer.println("\\begin{tikzpicture}[cap=round]"); + writer.println("% Draw grid"); + writer.println("\\draw[step=1cm,very thin,color=gray] (-0.2,-0.2) grid (10.0,9.0);"); + writer.println("\\draw[|-|] (-0,0) -- (10,0);"); + writer.println("%\\draw[dashed,very thin] (0,0) -- (5,8.66) -- (10,0);"); + writer.println("\\draw[dashed,very thin] (10,0) arc (0:60:10cm);"); + writer.println("\\draw[dashed,very thin] (0,0) arc (180:120:10cm);"); + + writer.println("\\draw (0,-0.3) node {$recall$}; "); + writer.println("\\draw (10,-0.3) node {$precision$}; "); + //writer.println("\\draw (0,-0.3) node {0.}; "); + //writer.println("\\draw (10,-0.3) node {1.}; "); + writer.println("% Plots"); int k = 0; for ( String m: listAlgo ) { - double precision = correctVect[k]/foundVect[k]; - double recall = correctVect[k]/expected; + double precision = 1. - correctFoundVect[k]/foundVect[k]; + double recall = 1. - correctExpVect[k]/expected; double prec2 = precision*precision; double a = ((prec2-(recall*recall)+1)/2); double b = java.lang.Math.sqrt( prec2 - (a*a) ); a = a*10; b = b*10; //for printing scale 10. - System.out.println("\\draw plot[mark=+,] coordinates {("+a+","+b+")};"); - System.out.println("\\draw ("+(a+.01)+","+(b+.01)+") node[anchor=south west] {"+m+"};"); + writer.println("\\draw plot[mark=+,] coordinates {("+a+","+b+")};"); + writer.println("\\draw ("+(a+.01)+","+(b+.01)+") node[anchor=south west] {"+m+"};"); k++; } - System.out.println("\\end{tikzpicture}"); - System.out.println(); - System.out.println("\\end{document}"); + writer.println("\\end{tikzpicture}"); + writer.println(); + writer.println("\\end{document}"); } - public void printLATEX( Vector result ) { + public void printLATEX( Vector result, PrintStream writer ) { } /* A few comments on how and why computing "weighted harmonic means" @@ -406,182 +382,162 @@ and which the program does... */ - public void printHTML( Vector<Vector> result ) { + public void printHTML( Vector<Vector> result, PrintStream writer ) { // variables for computing iterative harmonic means int expected = 0; // expected so far int foundVect[]; // found so far - int correctVect[]; // correct so far + int correctFoundVect[]; // correct so far + int correctExpVect[]; // correct so far long timeVect[]; // time so far - PrintStream writer = null; fsize = format.length(); // JE: the writer should be put out // JE: the h-means computation should be put out as well - try { - // Print result - if ( filename == null ) { - writer = System.out; - } else { - writer = new PrintStream(new FileOutputStream( filename )); - } - Formatter formatter = new Formatter(writer); - - // Print the header - if ( embedded != true ) writer.println("<html><head></head><body>"); - writer.println("<table border='2' frame='sides' rules='groups'>"); - writer.println("<colgroup align='center' />"); - // for each algo <td spancol='2'>name</td> - for ( String m : listAlgo ) { - writer.println("<colgroup align='center' span='"+fsize+"' />"); - } - // For each file do a - writer.println("<thead valign='top'><tr><th>algo</th>"); - // for each algo <td spancol='2'>name</td> - for ( String m : listAlgo ) { - writer.println("<th colspan='"+fsize+"'>"+m+"</th>"); - } - writer.println("</tr></thead><tbody><tr><td>test</td>"); - // for each algo <td>Prec.</td><td>Rec.</td> - for ( String m : listAlgo ) { - for ( int i = 0; i < fsize; i++){ - writer.print("<td>"); - if ( format.charAt(i) == 'p' ) { - writer.print("Prec."); - } else if ( format.charAt(i) == 'f' ) { - writer.print("FMeas."); - } else if ( format.charAt(i) == 'o' ) { - writer.print("Over."); - } else if ( format.charAt(i) == 't' ) { - writer.print("Time"); - } else if ( format.charAt(i) == 'r' ) { - writer.print("Rec."); - } - writer.println("</td>"); + Formatter formatter = new Formatter( writer ); + + // Print the header + if ( embedded != true ) writer.println("<html><head></head><body>"); + writer.println("<table border='2' frame='sides' rules='groups'>"); + writer.println("<colgroup align='center' />"); + // for each algo <td spancol='2'>name</td> + for ( String m : listAlgo ) { + writer.println("<colgroup align='center' span='"+fsize+"' />"); + } + // For each file do a + writer.println("<thead valign='top'><tr><th>algo</th>"); + // for each algo <td spancol='2'>name</td> + for ( String m : listAlgo ) { + writer.println("<th colspan='"+fsize+"'>"+m+"</th>"); + } + writer.println("</tr></thead><tbody><tr><td>test</td>"); + // for each algo <td>Prec.</td><td>Rec.</td> + for ( String m : listAlgo ) { + for ( int i = 0; i < fsize; i++){ + writer.print("<td>"); + if ( format.charAt(i) == 'p' ) { + writer.print("Prec."); + } else if ( format.charAt(i) == 'f' ) { + writer.print("FMeas."); + } else if ( format.charAt(i) == 'o' ) { + writer.print("Over."); + } else if ( format.charAt(i) == 't' ) { + writer.print("Time"); + } else if ( format.charAt(i) == 'r' ) { + writer.print("Rec."); } - //writer.println("<td>Prec.</td><td>Rec.</td>"); + writer.println("</td>"); } - writer.println("</tr></tbody><tbody>"); - foundVect = new int[ listAlgo.size() ]; - correctVect = new int[ listAlgo.size() ]; - timeVect = new long[ listAlgo.size() ]; - for( int k = listAlgo.size()-1; k >= 0; k-- ) { - foundVect[k] = 0; - correctVect[k] = 0; - timeVect[k] = 0; - } - // </tr> - // For each directory <tr> - boolean colored = false; - for ( Vector test : result ) { - int nexpected = -1; - if ( colored == true && color != null ){ - colored = false; - writer.println("<tr bgcolor=\""+color+"\">"); - } else { - colored = true; - writer.println("<tr>"); - }; - // Print the directory <td>bla</td> - writer.println("<td>"+(String)test.get(0)+"</td>"); - // For each record print the values <td>bla</td> - Enumeration f = test.elements(); - f.nextElement(); - for( int k = 0 ; f.hasMoreElements() ; k++) { - WeightedPREvaluator eval = (WeightedPREvaluator)f.nextElement(); - if ( eval != null ){ - // iterative H-means computation - if ( nexpected == -1 ){ - expected += eval.getExpected(); - nexpected = 0; - } - foundVect[k] += eval.getFound(); - correctVect[k] += eval.getCorrect(); - timeVect[k] += eval.getTime(); - - for ( int i = 0 ; i < fsize; i++){ - writer.print("<td>"); - if ( format.charAt(i) == 'p' ) { - formatter.format("%1.2f", eval.getPrecision()); - } else if ( format.charAt(i) == 'f' ) { - formatter.format("%1.2f", eval.getFmeasure()); - } else if ( format.charAt(i) == 'o' ) { - formatter.format("%1.2f", eval.getOverall()); - } else if ( format.charAt(i) == 't' ) { - if ( eval.getTime() == 0 ){ - writer.print("-"); - } else { - formatter.format("%1.2f", eval.getTime()); - } - } else if ( format.charAt(i) == 'r' ) { - formatter.format("%1.2f", eval.getRecall()); + //writer.println("<td>Prec.</td><td>Rec.</td>"); + } + writer.println("</tr></tbody><tbody>"); + foundVect = new int[ size ]; + correctFoundVect = new int[ size ]; + correctExpVect = new int[ size ]; + timeVect = new long[ size ]; + for( int k = size-1; k >= 0; k-- ) { + foundVect[k] = 0; + correctFoundVect[k] = 0; + correctExpVect[k] = 0; + timeVect[k] = 0; + } + // </tr> + // For each directory <tr> + boolean colored = false; + for ( Vector test : result ) { + double newexpected = -1.; + if ( colored == true && color != null ){ + colored = false; + writer.println("<tr bgcolor=\""+color+"\">"); + } else { + colored = true; + writer.println("<tr>"); + }; + // Print the directory <td>bla</td> + writer.println("<td>"+(String)test.get(0)+"</td>"); + // For each record print the values <td>bla</td> + Enumeration f = test.elements(); + f.nextElement(); + for( int k = 0 ; f.hasMoreElements() ; k++) { + WeightedPREvaluator eval = (WeightedPREvaluator)f.nextElement(); + if ( eval != null ) { + // iterative H-means computation + if ( newexpected == -1. ){ + newexpected = eval.getExpected(); + expected += newexpected; + } + foundVect[k] += eval.getFound(); + correctFoundVect[k] += eval.getCorrectFound(); + correctExpVect[k] += eval.getCorrectExpected(); + timeVect[k] += eval.getTime(); + + for ( int i = 0 ; i < fsize; i++){ + writer.print("<td>"); + if ( format.charAt(i) == 'p' ) { + formatter.format("%1.2f", eval.getPrecision()); + } else if ( format.charAt(i) == 'f' ) { + formatter.format("%1.2f", eval.getFmeasure()); + } else if ( format.charAt(i) == 'o' ) { + formatter.format("%1.2f", eval.getOverall()); + } else if ( format.charAt(i) == 't' ) { + if ( eval.getTime() == 0 ){ + writer.print("-"); + } else { + formatter.format("%1.2f", eval.getTime()); } - writer.println("</td>"); + } else if ( format.charAt(i) == 'r' ) { + formatter.format("%1.2f", eval.getRecall()); } - } else { - writer.println("<td>n/a</td><td>n/a</td>"); + writer.println("</td>"); } + } else { // JE 2013: will break if the previous tests are all NULL + correctExpVect[k] += newexpected; + // Nothing needs to be incremented for precision + for ( int i = 0 ; i < fsize; i++) writer.print("<td>n/a</td>"); + writer.println(); } - writer.println("</tr>"); - } - writer.print("<tr bgcolor=\"yellow\"><td>H-mean</td>"); - // Here we are computing a sheer average. - // While in the column results we print NaN when the returned - // alignment is empty, - // here we use the real values, i.e., add 0 to both correctVect and - // foundVect, so this is OK for computing the average. - int k = 0; - // ??? - for ( String m : listAlgo ) { - double precision = (double)correctVect[k]/foundVect[k]; - double recall = (double)correctVect[k]/expected; - for ( int i = 0 ; i < fsize; i++){ - writer.print("<td>"); - if ( format.charAt(i) == 'p' ) { - formatter.format("%1.2f", precision); - } else if ( format.charAt(i) == 'f' ) { - formatter.format("%1.2f", 2 * precision * recall / (precision + recall)); - } else if ( format.charAt(i) == 'o' ) { - formatter.format("%1.2f", recall * (2 - (1 / precision))); - } else if ( format.charAt(i) == 't' ) { - if ( timeVect[k] == 0 ){ - writer.print("-"); - } else { - formatter.format("%1.2f", timeVect[k]); - } - } else if ( format.charAt(i) == 'r' ) { - formatter.format("%1.2f", recall); - } - writer.println("</td>"); - }; - k++; } writer.println("</tr>"); - writer.println("</tbody></table>"); - writer.println("<p><small>n/a: result alignment not provided or not readable<br />"); - writer.println("NaN: division per zero, likely due to empty alignment.</small></p>"); - if ( embedded != true ) writer.println("</body></html>"); - } catch (Exception ex) { - ex.printStackTrace(); - } finally { - writer.close(); } - } + writer.print("<tr bgcolor=\"yellow\"><td>H-mean</td>"); + // Here we are computing a sheer average. + // While in the column results we print NaN when the returned + // alignment is empty, + // here we use the real values, i.e., add 0 to both correctVect and + // foundVect, so this is OK for computing the average. + int k = 0; + // ??? + for ( String m : listAlgo ) { + double precision = 1. - (double)correctFoundVect[k]/foundVect[k]; + double recall = 1. - (double)correctExpVect[k]/expected; + for ( int i = 0 ; i < fsize; i++){ + writer.print("<td>"); + if ( format.charAt(i) == 'p' ) { + formatter.format("%1.2f", precision); + } else if ( format.charAt(i) == 'f' ) { + formatter.format("%1.2f", 2 * precision * recall / (precision + recall)); + } else if ( format.charAt(i) == 'o' ) { + formatter.format("%1.2f", recall * (2 - (1 / precision))); + } else if ( format.charAt(i) == 't' ) { + if ( timeVect[k] == 0 ){ + writer.print("-"); + } else { + formatter.format("%1.2f", timeVect[k]); + } + } else if ( format.charAt(i) == 'r' ) { + formatter.format("%1.2f", recall); + } + writer.println("</td>"); + }; + k++; + } + writer.println("</tr>"); + writer.println("</tbody></table>"); + writer.println("<p><small>n/a: result alignment not provided or not readable<br />"); + writer.println("NaN: division per zero, likely due to empty alignment.</small></p>"); + if ( embedded != true ) writer.println("</body></html>"); + } public void usage() { - System.out.println("usage: WGroupEval [options]"); - System.out.println("options are:"); - System.out.println("\t--format=prfot -f prfot\tSpecifies the output order (precision/recall/f-measure/overall/time)"); - // Apparently not implemented - //System.out.println("\t--sup=algo -s algo\tSpecifies if dominant columns are algorithms or measure"); - System.out.println("\t--output=filename -o filename\tSpecifies a file to which the output will go"); - System.out.println("\t--reference=filename -r filename\tSpecifies the name of the reference alignment file (default: refalign.rdf)"); - - System.out.println("\t--type=html|xml|tex|ascii|triangle -t html|xml|tex|ascii\tSpecifies the output format"); - System.out.println("\t--list=algo1,...,algon -l algo1,...,algon\tSequence of the filenames to consider"); - System.out.println("\t--color=color -c color\tSpecifies if the output must color even lines of the output"); - System.out.println("\t--debug[=n] -d [n]\t\tReport debug info at level n"); - System.out.println("\t--help -h\t\t\tPrint this message"); - System.err.print("\n"+WGroupEval.class.getPackage().getImplementationTitle()+" "+WGroupEval.class.getPackage().getImplementationVersion()); - System.err.println(" ($Id$)\n"); + usage( "java "+this.getClass().getName()+" [options]\nEvaluates (with weighted measures) in parallel several matching results on several tests in subdirectories" ); } } diff --git a/src/fr/inrialpes/exmo/align/gen/AlteratorFactory.java b/src/fr/inrialpes/exmo/align/gen/AlteratorFactory.java index d80cd615fa16355a456df434b54a4f5fea110828..a3277c3b2f0c570f1a47a1605cb4face1905b576 100644 --- a/src/fr/inrialpes/exmo/align/gen/AlteratorFactory.java +++ b/src/fr/inrialpes/exmo/align/gen/AlteratorFactory.java @@ -1,7 +1,7 @@ /** * $Id$ * - * Copyright (C) INRIA, 2011 + * Copyright (C) INRIA, 2011, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -23,10 +23,13 @@ package fr.inrialpes.exmo.align.gen; import java.util.Map; import java.util.HashMap; import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.lang.reflect.InvocationTargetException; public class AlteratorFactory { + final static Logger logger = LoggerFactory.getLogger( AlteratorFactory.class ); // The parameter Ids should be here //public static final int ANY = 0; @@ -35,7 +38,7 @@ public class AlteratorFactory { private static Map<String,String> alterators = null; public static Alterator newInstance( String id, Alterator om ) { - //System.err.println( ">>>>>>>> "+id ); + //logger.trace( ">>>>>>>> {}", id ); if ( alterators == null ) init(); String classname = alterators.get( id ); Alterator alt = null; @@ -48,15 +51,15 @@ public class AlteratorFactory { Object[] mparams = { om }; alt = (Alterator)altConstructor.newInstance(mparams); } catch (ClassNotFoundException cnfex ) { - cnfex.printStackTrace(); // better raise errors + logger.debug( "IGNORED Exception", cnfex ); // better raise errors } catch (NoSuchMethodException nsmex) { - nsmex.printStackTrace(); + logger.debug( "IGNORED Exception", nsmex ); } catch (InstantiationException ieex) { - ieex.printStackTrace(); + logger.debug( "IGNORED Exception", ieex ); } catch (IllegalAccessException iaex) { - iaex.printStackTrace(); + logger.debug( "IGNORED Exception", iaex ); } catch (InvocationTargetException itex) { - itex.printStackTrace(); + logger.debug( "IGNORED Exception", itex ); } } return alt; @@ -151,7 +154,7 @@ public class AlteratorFactory { /* for( String key : params.stringPropertyNames() ) { String value = params.getProperty(key); - //if ( debug ) System.out.println( "[" +key + "] => [" + value + "]"); + //logger.trace( "[{}] = [{}]", key, value ); modifier.modifyOntology( key, value ); //modify the ontology according to it } */ diff --git a/src/fr/inrialpes/exmo/align/gen/BenchmarkGenerator.java b/src/fr/inrialpes/exmo/align/gen/BenchmarkGenerator.java index 10a35ea5164df36b5005576c868291040272b821..5bcad12904f952ec7764b1f30cf243b3e60abc7e 100644 --- a/src/fr/inrialpes/exmo/align/gen/BenchmarkGenerator.java +++ b/src/fr/inrialpes/exmo/align/gen/BenchmarkGenerator.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2011, INRIA + * Copyright (C) 2011, 2013, INRIA * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -29,11 +29,14 @@ package fr.inrialpes.exmo.align.gen; import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class BenchmarkGenerator extends TestSet { + final static Logger logger = LoggerFactory.getLogger( BenchmarkGenerator.class ); public void initTestCases( Properties params ) { // Process params - debug = ( params.getProperty( "debug" ) != null ); // JE: ugly secondOntoFile = params.getProperty( "outdir" )+"/101/onto.rdf"; @@ -47,11 +50,11 @@ public class BenchmarkGenerator extends TestSet { try { if ( hard != null && !hard.equals("") ) incr = Float.parseFloat( hard ); } catch ( Exception ex ) { - ex.printStackTrace(); // continue with the default + logger.debug( "IGNORED Exception (continue with default)", ex ); } String max = params.getProperty( "maximum" ); if ( max != null ) maximum = Integer.parseInt( max ); - if ( debug ) System.err.println( " Mod: "+mod+" / Incr: "+incr+" / Max: "+maximum ); + logger.trace( " Mod: {} / Incr: {} / Max: {}", mod, incr, maximum ); /* Test 101 Generate the initial situation */ initTests( "101" ); @@ -65,7 +68,7 @@ public class BenchmarkGenerator extends TestSet { if ( i > 0 ) PREVTEST = "201"+SUFFIX; // The previous suffix if ( !multModality ) i1 += incr; // traditional else i1 += (1. - i1) * incr; // hardened - //if ( debug ) System.err.println( " ******************************************************** "+i+": i1 = "+i1 ); + //logger.trace( " ******************************************************** {}: i1 = {}", i, i1 ); if ( i1 < 1.0f ) { SUFFIX = "-"+(i+1)*2; //((Float)i1).toString().substring(2, 3); // 2 4 6 8 diff --git a/src/fr/inrialpes/exmo/align/gen/ClassHierarchy.java b/src/fr/inrialpes/exmo/align/gen/ClassHierarchy.java index 5a57f0784e48f554b5f2b22bebc154734ebf344c..d5aeea90cbb123a9143ced5d21456663cca8b015 100644 --- a/src/fr/inrialpes/exmo/align/gen/ClassHierarchy.java +++ b/src/fr/inrialpes/exmo/align/gen/ClassHierarchy.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2011-2012, INRIA + * Copyright (C) 2011-2013, INRIA * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -43,7 +43,12 @@ import java.util.ArrayList; import java.util.Random; import java.util.Iterator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class ClassHierarchy { + final static Logger logger = LoggerFactory.getLogger( ClassHierarchy.class ); + private URITree root; //the root of the tree private Map<AnonId,String> m_anonIDs = new HashMap<AnonId,String>(); private int m_anonCount = 0; @@ -119,23 +124,23 @@ public class ClassHierarchy { } /* if ( childClasses.get(childClasses.size()-1) != null ) { - System.err.print( childClasses.get(childClasses.size()-1).getURI() ); + logger.trace( childClasses.get(childClasses.size()-1).getURI() ); } else { - System.err.print( "**NULL**" ); + logger.trace( "**NULL**" ); } System.err.print( " < "); if ( parentClasses.get(childClasses.size()-1) != null ) { - System.err.print( parentClasses.get(childClasses.size()-1).getURI() ); + logger.trace( parentClasses.get(childClasses.size()-1).getURI() ); } else { - System.err.print( "**NULL**" ); + logger.trace( "**NULL**" ); } - System.err.print( " < "); + logger.trace( " < "); if ( superLevelClasses.get(childClasses.size()-1) != null ) { - System.err.print( superLevelClasses.get(childClasses.size()-1).getURI() ); + logger.trace( superLevelClasses.get(childClasses.size()-1).getURI() ); } else { - System.err.print( "**NULL**" ); + logger.trace( "**NULL**" ); } - System.err.println(); + logger.trace("------------------"); */ childNode.setParent( superNode ); //change the parent of my superclass to the [parent of the "parent node"] // JE : likely wrong in multiple inheritance diff --git a/src/fr/inrialpes/exmo/align/gen/DiscriminantGenerator.java b/src/fr/inrialpes/exmo/align/gen/DiscriminantGenerator.java index 54a9347ac6af2490751716c1699f26b99a383fe7..412bfc27f949763a9b48c50efebb4d10a5cfa7b3 100644 --- a/src/fr/inrialpes/exmo/align/gen/DiscriminantGenerator.java +++ b/src/fr/inrialpes/exmo/align/gen/DiscriminantGenerator.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2012, INRIA + * Copyright (C) 2012-2013, INRIA * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -29,6 +29,9 @@ package fr.inrialpes.exmo.align.gen; import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * This class serves as an example for systematically generating the * alteration space at a particular resolution. @@ -38,10 +41,10 @@ import java.util.Properties; * All this could be achieved by using the parameters which could be Alterator/Step */ public class DiscriminantGenerator extends TestSet { + final static Logger logger = LoggerFactory.getLogger( DiscriminantGenerator.class ); public void initTestCases( Properties params ) { // Process params - debug = ( params.getProperty( "debug" ) != null ); // JE: ugly secondOntoFile = params.getProperty( "outdir" )+"/000/onto.rdf"; @@ -52,10 +55,10 @@ public class DiscriminantGenerator extends TestSet { try { if ( stepval != null && !stepval.equals("") ) STEP = Integer.parseInt( stepval ); } catch ( Exception ex ) { - ex.printStackTrace(); // continue with the default + logger.debug( "IGNORED Exception (continue with defaults)", ex ); } final float INCR = 1.0f/(STEP-1); - if ( debug ) System.err.println( " STEP: "+STEP+" / INCR: "+INCR ); + //logger.trace( " STEP: {} / INCR: {}", STEP, INCR ); /* Test 000 Generate the initial situation */ initTests( "000" ); diff --git a/src/fr/inrialpes/exmo/align/gen/NetworkAlignmentDropper.java b/src/fr/inrialpes/exmo/align/gen/NetworkAlignmentDropper.java index 98437ff324fe0ad358c46ddd67beca2285189166..fe068502bac6918e7ecfd6df79c268054dc5e2aa 100644 --- a/src/fr/inrialpes/exmo/align/gen/NetworkAlignmentDropper.java +++ b/src/fr/inrialpes/exmo/align/gen/NetworkAlignmentDropper.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2009-2011 + * Copyright (C) INRIA, 2009-2011, 2013 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -34,6 +34,9 @@ import java.util.Set; import java.util.Collections; import java.util.ArrayList; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * NetworkAlignmentDropper * @@ -42,9 +45,10 @@ import java.util.ArrayList; * Returns a brand new BasicOntologyNetwork (with the initial alignments) */ public class NetworkAlignmentDropper implements OntologyNetworkWeakener { + final static Logger logger = LoggerFactory.getLogger( NetworkAlignmentDropper.class ); public OntologyNetwork weaken( OntologyNetwork on, double n, Properties p ) throws AlignmentException { - //System.err.println( " >>>> "+n ); + //logger.trace( " >>>> {}", n ); if ( on == null ) throw new AlignmentException( "cannot weaken null ontology network" ); if ( n < 0. || n > 1. ) throw new AlignmentException( "Argument must be between 0 and 1.: "+n ); @@ -52,7 +56,7 @@ public class NetworkAlignmentDropper implements OntologyNetworkWeakener { } public OntologyNetwork weaken( OntologyNetwork on, int n, Properties p ) throws AlignmentException { - //System.err.println( " >>>> "+n ); + //logger.trace( " >>>> {}", n ); if ( on == null ) throw new AlignmentException( "cannot weaken null ontology network" ); if ( n < 0 ) throw new AlignmentException( "Argument must be a positive integer: "+n ); diff --git a/src/fr/inrialpes/exmo/align/gen/NetworkCorrespondenceDropper.java b/src/fr/inrialpes/exmo/align/gen/NetworkCorrespondenceDropper.java index 2efb03f86e029570a29e99813c195228f27af263..54bc4f805cbe10b1a2c51c9e89e0cc0cc20de011 100644 --- a/src/fr/inrialpes/exmo/align/gen/NetworkCorrespondenceDropper.java +++ b/src/fr/inrialpes/exmo/align/gen/NetworkCorrespondenceDropper.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2009-2011 + * Copyright (C) INRIA, 2009-2011, 2013 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -35,6 +35,9 @@ import java.util.TreeSet; import java.util.ArrayList; import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * NetworkCorrespondenceDropper * @@ -45,6 +48,7 @@ import java.util.Properties; */ public class NetworkCorrespondenceDropper implements OntologyNetworkWeakener { + final static Logger logger = LoggerFactory.getLogger( NetworkCorrespondenceDropper.class ); public OntologyNetwork weaken( OntologyNetwork on, int n, Properties p ) throws AlignmentException { throw new AlignmentException( "Cannot weaken alignments by fixed number of correspondences" ); @@ -74,14 +78,14 @@ public class NetworkCorrespondenceDropper implements OntologyNetworkWeakener { newon.addAlignment( newal ); } // Select these correspondences to delete: either shuffle or order - //System.err.println( n+" * "+corresp.size()+" = "+n*(double)(corresp.size()) ); + //logger.trace( "{} * {} = {}", n, corresp.size(), n*(double)(corresp.size()) ); int q = (int)(n*(double)(corresp.size())); if ( !threshold ) Collections.shuffle( (ArrayList)corresp ); // Suppress the n*size() last ones or those which are under threshold for ( LCell c : corresp ) { if ( q == 0 ) break; q--; - //System.err.println( "Cell ["+c.getCell().getStrength()+"] : "+c ); + //logger.trace( "Cell [{}]: {}", c.getCell().getStrength(), c ); c.getAlignment().remCell( c.getCell() ); } // Cut diff --git a/src/fr/inrialpes/exmo/align/gen/TestGenerator.java b/src/fr/inrialpes/exmo/align/gen/TestGenerator.java index 044a75edeb685d7dddfa996621bd4529099cb5c3..37242c799c726c7bd684cbf083ff52bdd00dd8a5 100644 --- a/src/fr/inrialpes/exmo/align/gen/TestGenerator.java +++ b/src/fr/inrialpes/exmo/align/gen/TestGenerator.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2011-2012, INRIA + * Copyright (C) 2011-2013, INRIA * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -49,6 +49,9 @@ import java.io.OutputStreamWriter; import java.nio.charset.Charset; import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + //Jena API classes import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntModelSpec; @@ -61,6 +64,8 @@ import fr.inrialpes.exmo.align.gen.alt.EmptyModification; import java.util.Properties; public class TestGenerator { + final static Logger logger = LoggerFactory.getLogger( TestGenerator.class ); + private String urlprefix = "http://example.com/"; // Prefix (before testnumber) of test URL private String dirprefix = ""; // Prefix (idem) of directory private String ontoname = "onto.rdf"; // name of ontology to generate @@ -69,7 +74,6 @@ public class TestGenerator { private OntModel modifiedOntology; //modified ontology private Alignment resultAlignment; //the reference alignment private Alterator modifier = null; //the modifier - private boolean debug = false; public TestGenerator() {} @@ -82,8 +86,6 @@ public class TestGenerator { public void setAlignFilename( String a ) { alignname = a; } - public void setDebug( boolean d ) { debug = d; } - //returns the modified ontology public OntModel getModifiedOntology() { return modifiedOntology; } @@ -191,7 +193,7 @@ public class TestGenerator { * Generate a test from an ontology */ public Properties modifyOntology( String file, Properties al, String dirName, Properties params) { - if ( debug ) System.err.println( "Source: "+file+" Target "+dirName ); + logger.trace( "Source: {}; Target {}", file, dirName ); //set the TestGenerator ontology OntModel onto = loadOntology( file ); Alterator modifier = generate( onto, params, al ); @@ -209,13 +211,10 @@ public class TestGenerator { // ******************************************************* GENERATOR //generate the alingnment public Alterator generate( OntModel onto, Properties params, Properties initalign ) { - if ( debug ) { - System.err.println( "[-------------------------------------------------]" ); - System.err.println( urlprefix+" / "+dirprefix+" / "+ontoname+" / "+alignname ); - } + logger.debug( "[-------------------------------------------------]" ); + logger.debug( "{} / {} / {} / {}", urlprefix, dirprefix, ontoname, alignname ); // Load the ontology Alterator modifier = new EmptyModification( onto ); - ((EmptyModification)modifier).setDebug( debug ); // Initialize the reference alignment if ( initalign != null ) ((EmptyModification)modifier).initializeAlignment( initalign ); modifier.modify( params ); diff --git a/src/fr/inrialpes/exmo/align/gen/TestSet.java b/src/fr/inrialpes/exmo/align/gen/TestSet.java index de5b7e5df0322b41b7c4c4cd041f781547b193e6..d05f33a076ec2cee0f692f9bdab31db07474d261 100644 --- a/src/fr/inrialpes/exmo/align/gen/TestSet.java +++ b/src/fr/inrialpes/exmo/align/gen/TestSet.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2011-2012, INRIA + * Copyright (C) 2011-2013, INRIA * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -28,6 +28,10 @@ * or generate tests independently. * * Variations can also be obtained. + * + * The API is: + * initTestCases: creates the test structure (abstract) made of TestCases + * generate: generates the actual tests using a TestGenerator */ package fr.inrialpes.exmo.align.gen; @@ -37,12 +41,15 @@ import java.util.HashMap; import java.util.Set; import java.util.HashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public abstract class TestSet { + final static Logger logger = LoggerFactory.getLogger( TestSet.class ); private String initOntoFile; //the initial ontology file protected String secondOntoFile; //the secondary ontology file protected boolean continuous = false; - protected boolean debug = false; private TestGenerator generator; // a TestGenerator @@ -59,7 +66,7 @@ public abstract class TestSet { addTestChild( tests.get( from ), name, params ); } public void addTestChild( TestCase father, String name, Properties params ) { - //System.err.println( name + " ["+father+"]" ); + //logger.trace( "{} [{}]", name, father ); TestCase c = father.addSubTest( name, params ); tests.put( name, c ); } @@ -89,7 +96,6 @@ public abstract class TestSet { // Generates the test set public void generate( Properties params ) { // Generator parameters... are these OK? - generator.setDebug( debug ); initOntoFile = params.getProperty( "filename" ); // If no filename error if ( params.getProperty( "urlprefix" ) != null ) generator.setURLPrefix( params.getProperty( "urlprefix" ) ); if ( params.getProperty( "outdir" ) != null ) generator.setDirPrefix( params.getProperty( "outdir" ) ); @@ -105,7 +111,7 @@ public abstract class TestSet { // Initialises test cases tree initTestCases( params ); // Print it - if ( debug ) printTestHierarchy( root, 0 ); + // printTestHierarchy( root, 0 ); if ( params.getProperty( "alignname" ) != null ) generator.setAlignFilename( params.getProperty( "alignname" ) ); // Generate all tests startTestGeneration(); diff --git a/src/fr/inrialpes/exmo/align/gen/URITree.java b/src/fr/inrialpes/exmo/align/gen/URITree.java index fdb77700fda0a6771e23a2fcdf6c2a3b031a6f33..1526622617df631f1ccb1c8b25f828bbfb570245 100644 --- a/src/fr/inrialpes/exmo/align/gen/URITree.java +++ b/src/fr/inrialpes/exmo/align/gen/URITree.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2011-2012, INRIA + * Copyright (C) 2011-2013, INRIA * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -29,9 +29,14 @@ import java.util.ArrayList; import java.util.List; import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import fr.inrialpes.exmo.align.gen.alt.BasicAlterator; public class URITree { + final static Logger logger = LoggerFactory.getLogger( URITree.class ); + private String URI; //the URI of the node private ArrayList<URITree> children;//the list of children private URITree parent; //the parent of the node @@ -208,7 +213,7 @@ public class URITree { public void print( int depth ) { indent( getDepth() ); - System.err.println( "[" + getURI() + "]" + "->" + getDepth() ); + //logger.trace( "[{}] -> {}", getURI(), getDepth() ); for( URITree n : getChildrenList() ) { n.print( depth+1 ); } diff --git a/src/fr/inrialpes/exmo/align/gen/alt/AddClassLevel.java b/src/fr/inrialpes/exmo/align/gen/alt/AddClassLevel.java index 6e9116a9924c7f872cfe0810416071a4aa15853a..50e754f1f6dd703c4112d6b139dc8eae595a0d6e 100755 --- a/src/fr/inrialpes/exmo/align/gen/alt/AddClassLevel.java +++ b/src/fr/inrialpes/exmo/align/gen/alt/AddClassLevel.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2011-2012, INRIA + * Copyright (C) 2011-2013, INRIA * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -27,11 +27,14 @@ import java.util.Properties; import java.util.List; import java.util.ArrayList; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import fr.inrialpes.exmo.align.gen.Alterator; import fr.inrialpes.exmo.align.gen.ParametersIds; - public class AddClassLevel extends BasicAlterator { + final static Logger logger = LoggerFactory.getLogger( AddClassLevel.class ); public AddClassLevel( Alterator om ) { initModel( om ); @@ -44,8 +47,8 @@ public class AddClassLevel extends BasicAlterator { int index = p.indexOf("."); int level = Integer.valueOf( p.substring(0, index) ); int nbClasses = Integer.valueOf( p.substring(index+1, p.length()) ); - if ( debug ) System.err.println( "level " + level ); - if ( debug ) System.err.println( "nbClasses " + nbClasses ); + logger.trace( "level : {}", level ); + logger.trace( "nbClasses : {}", nbClasses ); //float percentage = 1.00f; //the parent class -> if level is 1 then we create a new class //else we get a random class from the level : level-1 to be the parent of the class diff --git a/src/fr/inrialpes/exmo/align/gen/alt/BasicAlterator.java b/src/fr/inrialpes/exmo/align/gen/alt/BasicAlterator.java index 2475e307523eac225476645302446039c2c2bcbd..14d850a7073c0afb08119d09e0ce72f55c74be12 100644 --- a/src/fr/inrialpes/exmo/align/gen/alt/BasicAlterator.java +++ b/src/fr/inrialpes/exmo/align/gen/alt/BasicAlterator.java @@ -1,7 +1,7 @@ /** * $Id$ * - * Copyright (C) 2011-2012, INRIA + * Copyright (C) 2011-2013, INRIA * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -48,7 +48,9 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.OutputStream; import java.io.StringWriter; -import com.hp.hpl.jena.rdf.model.RDFWriter; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; //Alignment API classes import org.semanticweb.owl.align.Alignment; @@ -57,6 +59,7 @@ import org.semanticweb.owl.align.AlignmentException; import fr.inrialpes.exmo.align.impl.URIAlignment; //JENA classes +import com.hp.hpl.jena.rdf.model.RDFWriter; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.RDFNode; @@ -75,14 +78,13 @@ import com.hp.hpl.jena.ontology.Restriction; import com.hp.hpl.jena.ontology.AllValuesFromRestriction; import com.hp.hpl.jena.ontology.SomeValuesFromRestriction; - //gen import fr.inrialpes.exmo.align.gen.Alterator; import fr.inrialpes.exmo.align.gen.ClassHierarchy; import fr.inrialpes.exmo.align.gen.ParametersIds; public abstract class BasicAlterator implements Alterator { - protected boolean debug = false; + final static Logger logger = LoggerFactory.getLogger( BasicAlterator.class ); protected ClassHierarchy classHierarchy; // the class hierarchy protected OntModel modifiedModel; // the modified Ontology @@ -142,8 +144,6 @@ public abstract class BasicAlterator implements Alterator { // ------------------------- // Accessors - public void setDebug( boolean d ) { debug = d; } - //returns the modified ontology after changing the namespace public OntModel getModifiedOntology () { return modifiedModel; } @@ -383,9 +383,9 @@ public abstract class BasicAlterator implements Alterator { public Alignment extractAlignment( String base1, String base2 ) { Alignment extractedAlignment = new URIAlignment(); - //System.err.println( "\n-----> "+initOntologyNS ); - //System.err.println( "-----> "+base1 ); - //System.err.println( "-----> "+base2 ); + //logger.trace( "-----> {}", initOntologyNS ); + //logger.trace( "-----> {}", base1 ); + //logger.trace( "-----> {}", base2 ); try { URI onto1 = new URI( getNameSpace( base1 ) ); URI onto2 = new URI( getNameSpace( base2 ) ); @@ -398,13 +398,13 @@ public abstract class BasicAlterator implements Alterator { for ( String key : alignment.stringPropertyNames() ) { if ( !key.equals("##") ) { String value = alignment.getProperty(key); - //if ( debug ) System.err.println( "[" + source + "][" + target + "]" ); + //logger.trace( "[{} --> {}]", source, target ); extractedAlignment.addAlignCell( URI.create( base1+key ), URI.create( base2+value ) ); } } alignment.setProperty( "##", base1 ); } catch ( Exception ex ) { - ex.printStackTrace(); + logger.debug( "IGNORED Exception", ex ); } return extractedAlignment; } @@ -481,7 +481,7 @@ public abstract class BasicAlterator implements Alterator { ByteArrayInputStream in = new ByteArrayInputStream( sout.getBytes("UTF8") ); model.read( in, null ); } catch ( Exception ex ) { //UnsupportedEncodingException; - ex.printStackTrace(); + logger.debug( "IGNORED Exception", ex ); } return model; } diff --git a/src/fr/inrialpes/exmo/align/gen/alt/EmptyModification.java b/src/fr/inrialpes/exmo/align/gen/alt/EmptyModification.java index 6edcb0023162782a952a9081c6f90a0cba934995..dd7e264985d8404582109533389458f9146cd125 100755 --- a/src/fr/inrialpes/exmo/align/gen/alt/EmptyModification.java +++ b/src/fr/inrialpes/exmo/align/gen/alt/EmptyModification.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2011-2012, INRIA + * Copyright (C) 2011-2013, INRIA * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -33,12 +33,16 @@ import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import fr.inrialpes.exmo.align.gen.Alterator; import fr.inrialpes.exmo.align.gen.ParametersIds; import org.semanticweb.owl.align.Alignment; public class EmptyModification extends BasicAlterator { + final static Logger logger = LoggerFactory.getLogger( EmptyModification.class ); protected boolean relocateSource = false; @@ -51,7 +55,7 @@ public class EmptyModification extends BasicAlterator { // Clearly here setDebug, setNamespace are important public Alterator modify( Properties params ) { - //System.err.println( "********************************************************************************************" ); + //logger.trace( "NEW MODIFICATION ------------------------------------" ); relocateSource = ( params.getProperty( "copy101" ) != null ); if ( alignment == null ) { diff --git a/src/fr/inrialpes/exmo/align/gen/alt/FlattenLevel.java b/src/fr/inrialpes/exmo/align/gen/alt/FlattenLevel.java index 632065fdbe7cf3e44f0c2e9b95271e3bd5caabdd..8b221041863d401e7033f99a9c99e82a06187504 100755 --- a/src/fr/inrialpes/exmo/align/gen/alt/FlattenLevel.java +++ b/src/fr/inrialpes/exmo/align/gen/alt/FlattenLevel.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2011-2012, INRIA + * Copyright (C) 2011-2013, INRIA * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -30,10 +30,14 @@ import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import fr.inrialpes.exmo.align.gen.Alterator; import fr.inrialpes.exmo.align.gen.ParametersIds; public class FlattenLevel extends BasicAlterator { + final static Logger logger = LoggerFactory.getLogger( FlattenLevel.class ); public FlattenLevel( Alterator om ) { initModel( om ); @@ -81,10 +85,10 @@ public class FlattenLevel extends BasicAlterator { restr.add(r); if ( r.isSomeValuesFromRestriction() ) restr.add(r); - //if ( debug ) System.err.println( cls.getURI() ); + //logger.trace( "Class {}", cls.getURI() ); } } - //if ( debug ) System.err.println( restr.size() ); + //logger.trace( "Size: {}", restr.size() ); if ( !restrictions.containsKey( parentClass.getURI() ) ) { restrictions.put( parentClass.getURI(), restr ); @@ -93,9 +97,9 @@ public class FlattenLevel extends BasicAlterator { OntClass superClass = superLevelClasses.get( i ); //parent class of the child class parents if ( superClass == null ) superClass = modifiedModel.createClass( OWL.Thing.getURI() ); //Thing class - //if ( debug ) System.err.println("SuperClass class [" + superClass.getURI() + "]"); - //if ( debug ) System.err.println("Parent class [" + parentClass.getURI() + "]"); - //if ( debug ) System.err.println("Child class [" + childClass.getURI() + "]"); + //logger.trace("SuperClass class [{}]", superClass.getURI() ); + //logger.trace("Parent class [{}]", parentClass.getURI() ); + //logger.trace("Child class [{}]", childClass.getURI() ); if ( modifiedModel.containsResource( parentClass ) ) { //to check if the class appears as unionOf, someValuesFrom, allValuesFrom .. unionOf.put( parentClass.getURI(), superClass.getURI() ); diff --git a/src/fr/inrialpes/exmo/align/gen/alt/RemoveClassLevel.java b/src/fr/inrialpes/exmo/align/gen/alt/RemoveClassLevel.java index c38b5d22c7b34e5a4f92bfae1b69aaee8ec3fa31..84dc6e7d5f08815611af375db6601ed6d380d78c 100755 --- a/src/fr/inrialpes/exmo/align/gen/alt/RemoveClassLevel.java +++ b/src/fr/inrialpes/exmo/align/gen/alt/RemoveClassLevel.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2011-2012, INRIA + * Copyright (C) 2011-2013, INRIA * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -28,10 +28,14 @@ import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import fr.inrialpes.exmo.align.gen.Alterator; import fr.inrialpes.exmo.align.gen.ParametersIds; public class RemoveClassLevel extends BasicAlterator { + final static Logger logger = LoggerFactory.getLogger( RemoveClassLevel.class ); public RemoveClassLevel( Alterator om ) { initModel( om ); @@ -42,7 +46,7 @@ public class RemoveClassLevel extends BasicAlterator { if ( p == null ) return null; int level = Integer.parseInt( p ); HashMap<String, String> uris = new HashMap<String, String>(); - //if ( debug ) System.err.println( "Level " + level ); + //logger.trace( "Level {}", level ); buildClassHierarchy(); //build the class hierarchy if necessary for ( OntClass cl : classHierarchy.getClassesFromLevel( modifiedModel, level ) ) { //remove the classes from the hierarchy String parentURI = removeClass( cl ); diff --git a/src/fr/inrialpes/exmo/align/gen/alt/RemoveProperties.java b/src/fr/inrialpes/exmo/align/gen/alt/RemoveProperties.java index 2cda9180fc7ea9887e2420baeb028f70f4032942..ebb3582244e1e1320670b88094f1ec6110ed64d7 100755 --- a/src/fr/inrialpes/exmo/align/gen/alt/RemoveProperties.java +++ b/src/fr/inrialpes/exmo/align/gen/alt/RemoveProperties.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2011-2012, INRIA + * Copyright (C) 2011-2013, INRIA * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -36,11 +36,15 @@ import java.util.List; import java.util.ArrayList; import java.util.Iterator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import fr.inrialpes.exmo.align.gen.Alterator; import fr.inrialpes.exmo.align.gen.ParametersIds; public class RemoveProperties extends BasicAlterator { + final static Logger logger = LoggerFactory.getLogger( RemoveProperties.class ); public RemoveProperties( Alterator om ) { initModel( om ); @@ -60,7 +64,7 @@ public class RemoveProperties extends BasicAlterator { int nbProperties = properties.size(); //the number of properties - //System.err.println( percentage ); + //logger.trace( "Percentage {}", percentage ); int toBeRemoved = Math.round( percentage*nbProperties ); //the number of properties to be removed //build the list of classes to be removed diff --git a/src/fr/inrialpes/exmo/align/gen/alt/RenameThings.java b/src/fr/inrialpes/exmo/align/gen/alt/RenameThings.java index 72c83853204800d0466eca45737bebb9cdf3f2d1..9c95208e543267d91250256130847c1e7cfbcc61 100755 --- a/src/fr/inrialpes/exmo/align/gen/alt/RenameThings.java +++ b/src/fr/inrialpes/exmo/align/gen/alt/RenameThings.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2011-2012, INRIA + * Copyright (C) 2011-2013, INRIA * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -52,6 +52,9 @@ import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import fr.inrialpes.exmo.align.gen.Alterator; import fr.inrialpes.exmo.align.gen.ParametersIds; @@ -59,6 +62,7 @@ import fr.inrialpes.exmo.align.gen.ParametersIds; * This is only an abstract class gathering the renaming routines */ public abstract class RenameThings extends BasicAlterator { + final static Logger logger = LoggerFactory.getLogger( RenameThings.class ); // ------------------------- // Label replacement @@ -203,7 +207,7 @@ public abstract class RenameThings extends BasicAlterator { renamedClasses = nbClasses - notRenamedClasses.size(); //the number of renamed classes toBeRenamed = Math.round(percentage*nbClasses) - renamedClasses; // -renamedClasses -> for Benchmark - //System.err.println( "NbClasses = "+nbClasses+ " YetToRename = "+notRenamedClasses.size()+" I will rename = "+toBeRenamed ); + //logger.trace( "NbClasses = {}; YetToRename = {}; I will rename = {};", nbClasses, notRenamedClasses.size(), toBeRenamed ); // toBeRenamed is negative when classes have been added to the model if ( toBeRenamed < 0 ) toBeRenamed = 0; @@ -451,7 +455,7 @@ public abstract class RenameThings extends BasicAlterator { try { translatedText = Translate.execute(source, Language.ENGLISH, Language.FRENCH); } catch (Exception e) { - System.err.println( "Exception " + e.getMessage() ); + logger.debug( "IGNORED Exception", e ); } return removeSpaces ( translatedText ); } @@ -486,7 +490,7 @@ public abstract class RenameThings extends BasicAlterator { */ public String parseString (String str, boolean activeTranslateString, boolean activeSynonym) { - // if ( debug ) System.err.println ( "str = [" + str + "]" ); + // logger.trace( "str = [{}]", str ); char [] parsed = str.toCharArray(); String newString = ""; diff --git a/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java b/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java index 31979f255a1f6052d7bd8ebfc1f74dfda8281a05..1a4645753e706ffd4fc2e72d875b98e785391ed8 100644 --- a/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java @@ -34,6 +34,9 @@ import java.util.Set; import java.util.ArrayList; import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.xml.sax.ContentHandler; import org.semanticweb.owl.align.Alignment; @@ -54,11 +57,12 @@ import fr.inrialpes.exmo.ontowrap.OntowrapException; * In version 3.0 this class is virtually abstract. * But it cannot be declared abstract because it uses its own constructor. * - * @author J�r�me Euzenat, David Loup, Rapha�l Troncy + * @author Jérôme Euzenat, David Loup, Raphaël Troncy * @version $Id$ */ public class BasicAlignment implements Alignment { + final static Logger logger = LoggerFactory.getLogger( BasicAlignment.class ); public void accept( AlignmentVisitor visitor ) throws AlignmentException { visitor.visit( this ); @@ -67,8 +71,6 @@ public class BasicAlignment implements Alignment { protected Ontology<Object> onto1 = null; protected Ontology<Object> onto2 = null; - protected int debug = 0; - protected String level = "0"; protected String type = "**"; @@ -676,8 +678,10 @@ public class BasicAlignment implements Alignment { if ( pretty != null ){ newext.setExtension( Namespace.ALIGNMENT.uri, Annotations.PRETTY, pretty+"/"+label ); }; - newext.setExtension( Namespace.ALIGNMENT.uri, Annotations.PROVENANCE, - extensions.getExtension( Namespace.ALIGNMENT.uri, Annotations.PROVENANCE )+"" ); + if ( extensions.getExtension( Namespace.ALIGNMENT.uri, Annotations.PROVENANCE ) != null ) { + newext.setExtension( Namespace.ALIGNMENT.uri, Annotations.PROVENANCE, + extensions.getExtension( Namespace.ALIGNMENT.uri, Annotations.PROVENANCE ) ); + } newext.setExtension( Namespace.ALIGNMENT.uri, Annotations.METHOD, method ); return newext; } @@ -731,7 +735,10 @@ public class BasicAlignment implements Alignment { public Object clone() { BasicAlignment align; try { align = createNewAlignment( onto1, onto2 ); } - catch (AlignmentException ae) { ae.printStackTrace(); return null; } + catch (AlignmentException ae) { + logger.debug( "IGNORED Exception: alignment not cloned", ae ); + return null; + } align.setType( getType() ); align.setLevel( getLevel() ); align.setFile1( getFile1() ); @@ -743,7 +750,9 @@ public class BasicAlignment implements Alignment { align.setXNamespace( label, getXNamespace( label ) ); } try { align.ingest( this ); } - catch (AlignmentException ex) { ex.printStackTrace(); } + catch (AlignmentException ex) { + logger.debug( "IGNORED Exception: alignment not ingested", ex ); + } return align; } diff --git a/src/fr/inrialpes/exmo/align/impl/BasicParameters.java b/src/fr/inrialpes/exmo/align/impl/BasicParameters.java index 837c7d3d865b85338840188f46a90275a057c926..0cbaa053c38d5a9d579a371107817773109b993a 100644 --- a/src/fr/inrialpes/exmo/align/impl/BasicParameters.java +++ b/src/fr/inrialpes/exmo/align/impl/BasicParameters.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2004-2005, 2008-2010, 2012 + * Copyright (C) INRIA, 2004-2005, 2008-2010, 2012-2014 * Copyright (C) University of Montréal, 2004 * * This program is free software; you can redistribute it and/or @@ -30,6 +30,9 @@ import java.util.Properties; import java.io.PrintStream; import java.io.File; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.w3c.dom.Document; import org.w3c.dom.NodeList; import org.w3c.dom.Element; @@ -63,8 +66,9 @@ import org.semanticweb.owl.align.Parameters; * @version $Id$ */ -//@Deprecated +@Deprecated public class BasicParameters extends Properties implements Parameters, Cloneable { + final static Logger logger = LoggerFactory.getLogger( BasicParameters.class ); static final long serialVersionUID = 400L; @@ -153,13 +157,13 @@ public class BasicParameters extends Properties implements Parameters, Cloneable String paramValue = paramContent.item(0).getNodeValue().trim(); p.setParameter(paramName, paramValue); } - } catch (SAXParseException err) { - System.err.println("** Parsing error: ["+ err.getLineNumber()+"]: "+err.getSystemId()); - System.err.println(" " + err.getMessage()); - } catch (SAXException e) { - Exception x = e.getException(); - ((x == null) ? e : x).printStackTrace(); - } catch (Throwable t) { t.printStackTrace(); } + } catch ( SAXParseException err ) { + logger.debug( "IGNORED SAX Parsing exception", err ); + } catch ( SAXException e ) { + logger.debug( "IGNORED SAX exception", e ); + } catch ( Throwable t ) { + logger.debug( "IGNORED Exception", t ); + } return p; } diff --git a/src/fr/inrialpes/exmo/align/impl/BasicRelation.java b/src/fr/inrialpes/exmo/align/impl/BasicRelation.java index 1370d674819793a72404ba3100da1203f9dd6247..f1dc96919c37adc5ea2ca3a7848e6672b66355cc 100644 --- a/src/fr/inrialpes/exmo/align/impl/BasicRelation.java +++ b/src/fr/inrialpes/exmo/align/impl/BasicRelation.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2003-2005, 2007, 2009-2012 + * Copyright (C) INRIA, 2003-2005, 2007, 2009-2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -35,6 +35,9 @@ import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Represents an ontology alignment relation. * @@ -43,6 +46,7 @@ import java.util.Map; */ public class BasicRelation implements Relation { + final static Logger logger = LoggerFactory.getLogger( BasicRelation.class ); private static Map<String, Class<?>> classIndex = null; @@ -87,7 +91,7 @@ public class BasicRelation implements Relation { classIndex.put( "~>", nti ); classIndex.put( "~>", nti ); } catch ( ClassNotFoundException cnfe ) { - cnfe.printStackTrace(); // should never occur + logger.debug( "IGNORED Exception (should never occur)", cnfe ); } } return classIndex.get(label); @@ -150,7 +154,7 @@ public class BasicRelation implements Relation { Constructor relationConstructor = relationClass.getConstructor((Class[])null); return (Relation)relationConstructor.newInstance((Object[])null); } catch ( Exception ex ) { - //ex.printStackTrace(); + logger.debug( "IGNORED Exception: created Basic Relation)", ex ); //Otherwise, just create a Basic relation return new BasicRelation( rel ); } diff --git a/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java b/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java index 76385ec77ed013c1f52770410ba21ecccdfeb23d..fd124508be8fb16453e46457741fc5137ab829a8 100644 --- a/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2003-2011 + * Copyright (C) INRIA, 2003-2011, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -28,6 +28,9 @@ import java.util.SortedSet; import java.util.Comparator; import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentProcess; import org.semanticweb.owl.align.AlignmentException; @@ -51,6 +54,7 @@ import fr.inrialpes.exmo.ontosim.util.HungarianAlgorithm; */ public abstract class DistanceAlignment extends ObjectAlignment implements AlignmentProcess { + final static Logger logger = LoggerFactory.getLogger( DistanceAlignment.class ); Similarity sim; /** Creation **/ @@ -134,7 +138,7 @@ public abstract class DistanceAlignment extends ObjectAlignment implements Align if ( params.getProperty("threshold") != null ) threshold = Double.parseDouble( params.getProperty("threshold") ); - //System.err.println("The type is "+type+" with length = "+type.length()); + //logger.trace("The type is {} with length = {}", type, type.length() ); if ( type.equals("?*") || type.equals("1*") || type.equals("?+") || type.equals("1+") ) return extractqs( threshold, params ); else if ( type.equals("??") || type.equals("1?") || type.equals("?1") || type.equals("11") ) return extractqq( threshold, params ); else if ( type.equals("*?") || type.equals("+?") || type.equals("*1") || type.equals("+1") ) return extractqs( threshold, params ); @@ -209,8 +213,11 @@ public abstract class DistanceAlignment extends ObjectAlignment implements Align } } } - } catch (OntowrapException owex) { owex.printStackTrace(); //} - } catch (AlignmentException alex) { alex.printStackTrace(); } + } catch (OntowrapException owex) { + logger.debug( "IGNORED Exception", owex ); + } catch (AlignmentException alex) { + logger.debug( "IGNORED Exception", alex ); + } return((Alignment)this); } @@ -259,8 +266,11 @@ public abstract class DistanceAlignment extends ObjectAlignment implements Align } } } - } catch (OntowrapException owex) { owex.printStackTrace(); //} - } catch (AlignmentException alex) { alex.printStackTrace(); } + } catch (OntowrapException owex) { + logger.debug( "IGNORED Exception", owex ); + } catch (AlignmentException alex) { + logger.debug( "IGNORED Exception", alex ); + } return((Alignment)this); } @@ -316,8 +326,11 @@ public abstract class DistanceAlignment extends ObjectAlignment implements Align } } } - } catch ( AlignmentException alex) { alex.printStackTrace(); } - catch ( OntowrapException owex) { owex.printStackTrace(); } + } catch (OntowrapException owex) { + logger.debug( "IGNORED Exception", owex ); + } catch (AlignmentException alex) { + logger.debug( "IGNORED Exception", alex ); + } // For properties try{ int nbprop1 = ontology1().nbProperties(); @@ -358,8 +371,11 @@ public abstract class DistanceAlignment extends ObjectAlignment implements Align } } } - } catch (AlignmentException alex) { alex.printStackTrace(); } - catch (OntowrapException owex) { owex.printStackTrace(); } + } catch (OntowrapException owex) { + logger.debug( "IGNORED Exception", owex ); + } catch (AlignmentException alex) { + logger.debug( "IGNORED Exception", alex ); + } // For individuals if ( params.getProperty("noinst") == null ){ try { @@ -405,8 +421,11 @@ public abstract class DistanceAlignment extends ObjectAlignment implements Align } } } - } catch (AlignmentException alex) { alex.printStackTrace(); //} - } catch (OntowrapException owex) { owex.printStackTrace(); } + } catch (OntowrapException owex) { + logger.debug( "IGNORED Exception", owex ); + } catch (AlignmentException alex) { + logger.debug( "IGNORED Exception", alex ); + } } return((Alignment)this); } @@ -451,7 +470,7 @@ public abstract class DistanceAlignment extends ObjectAlignment implements Align public int compare( Cell o1, Cell o2 ) throws ClassCastException{ try { - //System.err.println(o1.getObject1()+" -- "+o1.getObject2()+" // "+o2.getObject1()+" -- "+o2.getObject2()); + //logger.trace("{} -- {} // {} -- {}", o1.getObject1(), o1.getObject2(), o2.getObject1(), o2.getObject2()); if ( o1.getStrength() > o2.getStrength() ){ return -1; } else if ( o1.getStrength() < o2.getStrength() ){ @@ -533,11 +552,11 @@ public abstract class DistanceAlignment extends ObjectAlignment implements Align } }; - } catch (AlignmentException alex) { - alex.printStackTrace(); - } catch (OntowrapException owex) { - owex.printStackTrace(); - }; + } catch (OntowrapException owex) { + logger.debug( "IGNORED Exception", owex ); + } catch (AlignmentException alex) { + logger.debug( "IGNORED Exception", alex ); + } return((Alignment)this); } diff --git a/src/fr/inrialpes/exmo/align/impl/InstanceBasedMatrixMeasure.java b/src/fr/inrialpes/exmo/align/impl/InstanceBasedMatrixMeasure.java index 72fd167ae6c58145f605840e8effed235dace60d..e1de26d89a3380a4c8cbb990ad52707c160a9aef 100644 --- a/src/fr/inrialpes/exmo/align/impl/InstanceBasedMatrixMeasure.java +++ b/src/fr/inrialpes/exmo/align/impl/InstanceBasedMatrixMeasure.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2010 + * Copyright (C) INRIA, 2010, 2013 * * Modifications to the initial code base are copyright of their * respective authors, or their employers as appropriate. Authorship @@ -43,6 +43,9 @@ import java.util.Set; import java.util.Properties; import java.util.Vector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * InstanceBasedMatrixMeasure * @@ -59,6 +62,7 @@ import java.util.Vector; */ public abstract class InstanceBasedMatrixMeasure extends MatrixMeasure { + final static Logger logger = LoggerFactory.getLogger( InstanceBasedMatrixMeasure.class ); Set<Object>[] classinst1 = null; Set<Object>[] classinst2 = null; @@ -89,9 +93,9 @@ public abstract class InstanceBasedMatrixMeasure extends MatrixMeasure { classinst2[ classlist2.get( cl2 ).intValue() ] = ontology2.getInstances( cl2, OntologyFactory.LOCAL, OntologyFactory.FULL, OntologyFactory.NAMED ); } } catch (OntowrapException owex) { - owex.printStackTrace(); + logger.debug( "IGNORED Exception", owex ); } catch (AlignmentException alex) { - alex.printStackTrace(); + logger.debug( "IGNORED Exception", alex ); } } @@ -208,7 +212,7 @@ public abstract class InstanceBasedMatrixMeasure extends MatrixMeasure { return 0.; } public double individualMeasure( Object id1, Object id2 ) throws Exception { - //if ( debug > 4 ) System.err.println( "ID:"+id1+" -- "+id2); + //logger.trace( "ID: {} -- {}", id1, id2 ); // compute edit distance between both norms //norm1[indlist1.get(ob1).intValue()], norm2[indlist2.get(ob2).intValue()] return 0.; diff --git a/src/fr/inrialpes/exmo/align/impl/MatrixMeasure.java b/src/fr/inrialpes/exmo/align/impl/MatrixMeasure.java index 04d3002c740c91b4b9776c11ef2fb0efb3d13a74..5c844fdbe07b4d8882c7ab04df2039d0b9d6b481 100644 --- a/src/fr/inrialpes/exmo/align/impl/MatrixMeasure.java +++ b/src/fr/inrialpes/exmo/align/impl/MatrixMeasure.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2003-2010 + * Copyright (C) INRIA, 2003-2010, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -26,6 +26,9 @@ import java.util.Properties; import java.util.Set; import java.text.NumberFormat; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentProcess; import org.semanticweb.owl.align.AlignmentException; @@ -47,6 +50,7 @@ import fr.inrialpes.exmo.align.impl.ObjectAlignment; public abstract class MatrixMeasure implements Similarity { + final static Logger logger = LoggerFactory.getLogger( MatrixMeasure.class ); public boolean similarity = true; @@ -126,7 +130,7 @@ public abstract class MatrixMeasure implements Similarity { proplist1 = new HashMap<Object,Integer>(); // onto1 properties indlist2 = new HashMap<Object,Integer>(); // onto2 instances indlist1 = new HashMap<Object,Integer>(); // onto1 instances - //System.err.println(" >> "+onto1+"/"+onto2 ); + //logger.trace(" >> {}/{}", onto1, onto2 ); try { // Create class lists @@ -136,7 +140,7 @@ public abstract class MatrixMeasure implements Similarity { for( Object cl : onto1.getClasses() ){ classlist1.put( cl, new Integer(nbclass1++) ); } - //System.err.println(" >> NbClasses: "+nbclass1+"/"+nbclass2 ); + //logger.trace(" >> NbClasses: {}/{}", nbclass1, nbclass2 ); clmatrix = new double[nbclass1+1][nbclass2+1]; // Create property lists @@ -152,7 +156,7 @@ public abstract class MatrixMeasure implements Similarity { for( Object pr : onto1.getDataProperties() ){ proplist1.put( pr, new Integer(nbprop1++) ); } - //System.err.println(" >> NbProp: "+nbprop1+"/"+nbprop2 ); + //logger.trace(" >> NbProp: {}/{}", nbprop1, nbprop2 ); prmatrix = new double[nbprop1+1][nbprop2+1]; // Create individual lists @@ -168,9 +172,11 @@ public abstract class MatrixMeasure implements Similarity { indlist1.put( ind, new Integer(nbind1++) ); } } - //System.err.println(" >> NbInd: "+nbind1+"/"+nbind2 ); + //logger.trace(" >> NbInd: {}/{}", nbind1, nbind2 ); indmatrix = new double[nbind1+1][nbind2+1]; - } catch (OntowrapException e) { e.printStackTrace(); }; + } catch (OntowrapException e) { + logger.debug( "IGNORED Exception", e ); + }; } @SuppressWarnings("unchecked") //ConcatenatedIterator @@ -206,7 +212,9 @@ public abstract class MatrixMeasure implements Similarity { } } // What is caught is really Exceptions - } catch (Exception e) { e.printStackTrace(); } + } catch (Exception e) { + logger.debug( "IGNORED Exception", e ); + } } public double getIndividualSimilarity( Object i1, Object i2 ){ @@ -241,7 +249,9 @@ public abstract class MatrixMeasure implements Similarity { } System.out.println("\\\\"); } - } catch (OntowrapException e) { e.printStackTrace(); }; + } catch (OntowrapException e) { + logger.debug( "IGNORED Exception", e ); + }; System.out.println("\n\\end{tabular}"); } diff --git a/src/fr/inrialpes/exmo/align/impl/ObjectAlignment.java b/src/fr/inrialpes/exmo/align/impl/ObjectAlignment.java index 37a43cc5d585d20f9593126fa24662097a1b33b5..ab3334affd3f1fa7a12cf4a65fceb05bcb2ff622 100644 --- a/src/fr/inrialpes/exmo/align/impl/ObjectAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/ObjectAlignment.java @@ -28,6 +28,9 @@ import java.util.Set; import java.util.Collection; import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.xml.sax.SAXException; import org.semanticweb.owl.align.Alignment; @@ -52,13 +55,14 @@ import fr.inrialpes.exmo.ontowrap.OntowrapException; */ public class ObjectAlignment extends BasicAlignment { + final static Logger logger = LoggerFactory.getLogger( ObjectAlignment.class ); protected ObjectAlignment init = null; public ObjectAlignment() {} - public void init(Object onto1, Object onto2) throws AlignmentException { - if ( (onto1 instanceof LoadedOntology && onto2 instanceof LoadedOntology) ){ + public void init( Object onto1, Object onto2 ) throws AlignmentException { + if ( (onto1 instanceof LoadedOntology) && (onto2 instanceof LoadedOntology) ){ super.init( onto1, onto2 ); } else if ( onto1 instanceof URI && onto2 instanceof URI ) { super.init( loadOntology( (URI)onto1 ), @@ -161,7 +165,7 @@ public class ObjectAlignment extends BasicAlignment { } catch ( NullPointerException npe ) { throw new AlignmentException( "Cannot dereference entity "+c.getObject2AsURI( alignment ), npe ); } - //System.err.println( obj1+" "+obj2+" "+c.getRelation()+" "+c.getStrength() ); + //logger.trace( "{} {} {} {}", obj1, obj2, c.getRelation(), c.getStrength() ); if ( obj1 == null ) throw new AlignmentException( "Cannot dereference entity "+c.getObject1AsURI( alignment ) ); if ( obj2 == null ) throw new AlignmentException( "Cannot dereference entity "+c.getObject2AsURI( alignment ) ); Cell newc = alignment.addAlignCell( c.getId(), obj1, obj2, diff --git a/src/fr/inrialpes/exmo/align/impl/aggr/ConsensusAggregator.java b/src/fr/inrialpes/exmo/align/impl/aggr/ConsensusAggregator.java index f29e70213c9726840cb2f7d0ffd3aeefeabc91ed..154cb29fa6b24a6c1b9b5b5c4213232f5b4d674a 100644 --- a/src/fr/inrialpes/exmo/align/impl/aggr/ConsensusAggregator.java +++ b/src/fr/inrialpes/exmo/align/impl/aggr/ConsensusAggregator.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2010 + * Copyright (C) INRIA, 2010, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -24,6 +24,9 @@ import java.util.Hashtable; import java.util.Set; import java.util.HashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentException; import org.semanticweb.owl.align.Cell; @@ -54,6 +57,7 @@ import fr.inrialpes.exmo.align.impl.BasicAlignment; */ public class ConsensusAggregator extends BasicAlignment { + final static Logger logger = LoggerFactory.getLogger( ConsensusAggregator.class ); int nbAlignments = 0; Hashtable<Cell, CountCell> count; @@ -144,7 +148,7 @@ public class ConsensusAggregator extends BasicAlignment { } } } catch (Exception ex) { - ex.printStackTrace(); + logger.debug( "IGNORED Exception", ex ); } return null; } diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/EDOALAlignment.java b/src/fr/inrialpes/exmo/align/impl/edoal/EDOALAlignment.java index 095151a17c659f072d17686dd3081a60577e4d16..108771a998032a4082924aff6c3c56c0bcfcfd42 100644 --- a/src/fr/inrialpes/exmo/align/impl/edoal/EDOALAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/edoal/EDOALAlignment.java @@ -2,7 +2,7 @@ * $Id$ * * Sourceforge version 1.6 - 2008 - was OMWGAlignment - * Copyright (C) INRIA, 2007-2012 + * Copyright (C) INRIA, 2007-2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -29,12 +29,16 @@ import java.util.Collection; import java.util.Set; import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.align.AlignmentException; import org.semanticweb.owl.align.AlignmentVisitor; import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.Cell; import org.semanticweb.owl.align.Relation; +import fr.inrialpes.exmo.ontowrap.OntologyFactory; import fr.inrialpes.exmo.ontowrap.Ontology; import fr.inrialpes.exmo.ontowrap.LoadedOntology; import fr.inrialpes.exmo.ontowrap.OntologyFactory; @@ -56,6 +60,7 @@ import fr.inrialpes.exmo.align.parser.TypeCheckingVisitor; * */ public class EDOALAlignment extends BasicAlignment { + final static Logger logger = LoggerFactory.getLogger( EDOALAlignment.class ); /* * An eventual initial alignment @@ -82,20 +87,13 @@ public class EDOALAlignment extends BasicAlignment { public void init( Object onto1, Object onto2 ) throws AlignmentException { if ( (onto1 == null) || (onto2 == null) ) throw new AlignmentException("The source and target ontologies must not be null"); - if ( (onto1 instanceof Ontology && onto2 instanceof Ontology) ){ - super.init( onto1, onto2 ); - } - else if ((onto1 instanceof URI && onto2 instanceof URI)) { - OntologyFactory fact = OntologyFactory.getFactory(); - try { - super.init(fact.loadOntology((URI) onto1), fact.loadOntology((URI) onto2)); - } catch (OntowrapException e) { - throw new AlignmentException("Could not load ontologies",e); - } - } - else { - throw new AlignmentException("arguments must be LoadedOntology or deferencable URIs"); - }; + Ontology o1 = null; + if ( onto1 instanceof Ontology ) o1 = (Ontology)onto1; + else o1 = loadOntology( (URI)onto1 ); + Ontology o2 = null; + if ( onto2 instanceof Ontology ) o2 = (Ontology)onto2; + else o2 = loadOntology( (URI)onto2 ); + super.init( o1, o2 ); } public void loadInit( Alignment al ) throws AlignmentException { @@ -259,30 +257,61 @@ public class EDOALAlignment extends BasicAlignment { // It would be better to implement this for ObjectAlignment // and to use return toEDOALAlignment( ObjectAlignment.toObjectAlignment( al ) ); // for URIAlignment + // + // Basic -> URI + // -> Object + // -> EDOAL + public static LoadedOntology loadOntology( URI onto ) throws AlignmentException { + if ( onto == null ) throw new AlignmentException("The source and target ontologies must not be null"); + try { + OntologyFactory fact = OntologyFactory.getFactory(); + return fact.loadOntology( onto ); + } catch ( OntowrapException owex ) { + throw new AlignmentException( "Cannot load ontologies", owex ); + } + } + public static LoadedOntology loadOntology( Ontology onto ) throws AlignmentException { + if ( onto == null ) throw new AlignmentException("The source and target ontologies must not be null"); + if ( onto instanceof LoadedOntology ) return (LoadedOntology)onto; + try { + OntologyFactory fact = OntologyFactory.getFactory(); + return fact.loadOntology( onto ); + } catch ( OntowrapException owex ) { + throw new AlignmentException( "Cannot load ontologies", owex ); + } + } + public static EDOALAlignment toEDOALAlignment( URIAlignment al ) throws AlignmentException { return toEDOALAlignment( (BasicAlignment)al ); } public static EDOALAlignment toEDOALAlignment( ObjectAlignment al ) throws AlignmentException { - return toEDOALAlignment( (BasicAlignment)al ); + logger.debug( "Converting ObjectAlignment to EDOALAlignment" ); + EDOALAlignment alignment = new EDOALAlignment(); + // They are obviously loaded + alignment.init( al.getOntologyObject1(), al.getOntologyObject2() ); + alignment.convertToEDOAL( al ); + return alignment; } public static EDOALAlignment toEDOALAlignment( BasicAlignment al ) throws AlignmentException { + logger.debug( "Converting BasicAlignment to EDOALAlignment" ); EDOALAlignment alignment = new EDOALAlignment(); - try { - alignment.init( al.getFile1(), al.getFile2() ); - } catch ( AlignmentException aex ) { - try { // Really a friendly fallback - alignment.init( al.getOntology1URI(), al.getOntology2URI() ); - } catch ( AlignmentException xx ) { - throw aex; - } - } - alignment.setType( al.getType() ); - alignment.setExtensions( al.convertExtension( "EDOALConverted", "fr.inrialpes.exmo.align.edoal.EDOALAlignment#toEDOAL" ) ); - LoadedOntology<Object> o1 = (LoadedOntology<Object>)alignment.getOntologyObject1(); // [W:unchecked] - LoadedOntology<Object> o2 = (LoadedOntology<Object>)alignment.getOntologyObject2(); // [W:unchecked] + LoadedOntology onto1 = loadOntology( al.getOntologyObject1() ); + LoadedOntology onto2 = loadOntology( al.getOntologyObject2() ); + alignment.init( onto1, onto2 ); + alignment.convertToEDOAL( al ); + return alignment; + } + /** + * The EDOALAlignment has LoadedOntologies as ontologies + */ + public void convertToEDOAL( BasicAlignment al ) throws AlignmentException { + setType( al.getType() ); + setExtensions( al.convertExtension( "toEDOAL", "fr.inrialpes.exmo.align.edoal.EDOALAlignment#toEDOAL" ) ); + LoadedOntology<Object> o1 = (LoadedOntology<Object>)getOntologyObject1(); // [W:unchecked] + LoadedOntology<Object> o2 = (LoadedOntology<Object>)getOntologyObject2(); // [W:unchecked] for ( Cell c : al ) { try { - Cell newc = alignment.addAlignCell( c.getId(), + Cell newc = addAlignCell( c.getId(), createEDOALExpression( o1, c.getObject1AsURI( al ) ), createEDOALExpression( o2, c.getObject2AsURI( al ) ), c.getRelation(), @@ -294,12 +323,11 @@ public class EDOALAlignment extends BasicAlignment { } } } catch ( AlignmentException aex ) { - aex.printStackTrace(); // continue to concert the rest + logger.debug( "IGNORED Exception (continue importing)", aex ); } catch ( OntowrapException owex ) { throw new AlignmentException( "Cannot dereference entity", owex ); } } - return alignment; } private static Id createEDOALExpression( LoadedOntology<Object> o, URI u ) throws OntowrapException, AlignmentException { @@ -312,7 +340,7 @@ public class EDOALAlignment extends BasicAlignment { return new RelationId( u ); } else if ( o.isIndividual( e ) ) { return new InstanceId( u ); - } else throw new AlignmentException( "Cannot interpret URI" ); + } else throw new AlignmentException( "Cannot interpret URI "+u ); } @@ -335,7 +363,9 @@ public class EDOALAlignment extends BasicAlignment { align.setExtensions( convertExtension( "cloned", this.getClass().getName()+"#clone" ) ); try { align.ingest( this ); - } catch (AlignmentException ex) { ex.printStackTrace(); } + } catch (AlignmentException ex) { + logger.debug( "IGNORED Exception", ex ); + } return align; } diff --git a/src/fr/inrialpes/exmo/align/impl/eval/AveragePRGraphEvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/AveragePRGraphEvaluator.java index 2fce49742929c96d82c41c0d2247a240677e9499..afbb08a912541ea94f5c338a0b25500bf4addb08 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/AveragePRGraphEvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/AveragePRGraphEvaluator.java @@ -1,7 +1,7 @@ /* * $Id: AveragePRGraphEvaluator.java 1196 2010-01-10 19:58:52Z euzenat $ * - * Copyright (C) INRIA, 2004-2005, 2007-2010 + * Copyright (C) INRIA, 2004-2005, 2007-2010, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -36,6 +36,9 @@ import java.util.Vector; import java.io.PrintWriter; import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Compute the precision recall graph on 11 points * The first alignment is thus the expected one. @@ -72,6 +75,7 @@ import java.net.URI; */ public class AveragePRGraphEvaluator extends GraphEvaluator { + final static Logger logger = LoggerFactory.getLogger( AveragePRGraphEvaluator.class ); private int size = 0; // for averaging @@ -93,10 +97,10 @@ public class AveragePRGraphEvaluator extends GraphEvaluator { public Vector<Pair> eval(){ Vector<Pair> result = new Vector<Pair>(STEP+1); // Compute the average and build the vector pair - //System.err.println( " Size: "+size ); + //logger.trace( " Size: {}", size ); for( int j = 0; j <= STEP; j++ ) { // JE: better with j/10 - //System.err.println( " prec at "+j+" : "+precisions[j] ); + //logger.trace( " prec at {} : {} ", j, precisions[j] ); result.add( new Pair( ((double)j)/10, precisions[j] / size ) ); } map = rawmap / size; // average map @@ -115,7 +119,7 @@ public class AveragePRGraphEvaluator extends GraphEvaluator { try { evalAlignment( reference, al ); } catch ( AlignmentException aex ) { - aex.printStackTrace(); + logger.debug( "IGNORED Exception", aex ); } } @@ -166,7 +170,7 @@ public class AveragePRGraphEvaluator extends GraphEvaluator { // It works backward in the vector, // (in the same spirit as before, the maximum value so far -best- is retained) int j = inflexion.size()-1; // index in recall-ordered vector of points - //System.err.println( "Inflexion: "+j); + //logger.trace( "Inflexion: {}", j); int i = STEP; // index of the current recall interval double level = (double)i/STEP; // max level of that interval double best = 0.; // best value found for that interval diff --git a/src/fr/inrialpes/exmo/align/impl/eval/DiffEvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/DiffEvaluator.java index 5d35ff1dee8d4035d91ea6b88d049f5c7dd8f092..a3c73934574daddcd40c1e87923c765bf7498349 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/DiffEvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/DiffEvaluator.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2010, 2012 + * Copyright (C) INRIA, 2010, 2012-2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -39,16 +39,25 @@ import java.util.HashSet; import java.io.PrintWriter; import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Evaluate proximity between two alignments. * This function implements Precision/Recall/Fallout. The first alignment * is thus the expected one. * + * @author: Cassia Trojahn dos Santos * @version $Id$ + * + * Possible improvements: + * (1) make it work with EDOAL + * (2) write a tool that is able to pair falsenegative and falsepositive (this has been returned instead of ...) + * */ public class DiffEvaluator extends BasicEvaluator implements Evaluator { + final static Logger logger = LoggerFactory.getLogger( DiffEvaluator.class ); Set<Cell> truepositive; Set<Cell> falsenegative; @@ -103,7 +112,7 @@ public class DiffEvaluator extends BasicEvaluator implements Evaluator { } } } catch (Exception e) { - e.printStackTrace(); + logger.debug( "IGNORED Exception", e ); } // False negative @@ -133,7 +142,7 @@ public class DiffEvaluator extends BasicEvaluator implements Evaluator { } } } catch (Exception e) { - e.printStackTrace(); + logger.debug( "IGNORED Exception", e ); } } @@ -167,7 +176,7 @@ public class DiffEvaluator extends BasicEvaluator implements Evaluator { } result += "</dd>\n"; } catch (AlignmentException e) { - e.printStackTrace(); + logger.debug( "IGNORED Exception", e ); } return result; } diff --git a/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java index f2a414820fa862fa027fe39d68f6343efacb24f6..34dd560d9d35987189fdc80b95879e261ba62f9f 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java @@ -43,6 +43,9 @@ import java.io.PrintWriter; import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Implements extended precision and recall between alignments. * These are the measures corresponding to [Ehrig&Euzenat2005]. @@ -75,6 +78,7 @@ import java.net.URI; */ public class ExtPREvaluator extends BasicEvaluator implements Evaluator { + final static Logger logger = LoggerFactory.getLogger( ExtPREvaluator.class ); private HeavyLoadedOntology<Object> onto1; private HeavyLoadedOntology<Object> onto2; @@ -194,8 +198,9 @@ public class ExtPREvaluator extends BasicEvaluator implements Evaluator { if ( nbexpected != 0 ) precorientrec = orientPrecsimilarity / (double) nbexpected; if ( nbfound != 0 ) recorientprec = orientRecsimilarity / (double) nbfound; if ( nbexpected != 0 ) recorientrec = orientRecsimilarity / (double) nbexpected; - //System.err.println(">>>> " + nbcorrect + " : " + nbfound + " : " + nbexpected); - //System.err.println(">>>> " + symsimilarity + " : " + effsimilarity + " : " + orientRecsimilarity + " : " + orientPrecsimilarity); + //logger.trace(">>>> {} : {} : {}", nbcorrect, nbfound, nbexpected); + //logger.trace(">>>> {} : {}", symsimilarity, effsimilarity ); + //logger.trace(">>>> {} : {}", orientRecsimilarity, orientPrecsimilarity); return (result); } @@ -216,19 +221,20 @@ public class ExtPREvaluator extends BasicEvaluator implements Evaluator { val1 = 0; } else { val1 = Math.abs( relativePosition( c1.getObject1(), c2.getObject1(), onto1 ) ); - //System.err.println( c1.getObject1()+" -- "+c2.getObject1()+" = "+val1 ); + //logger.trace( "{} -- {} = {}", c1.getObject1(), c2.getObject1(), val1 ); if ( val1 == 0 ) continue; } if ( onto2.getEntityURI( c1.getObject2() ).equals( onto2.getEntityURI(c2.getObject2()) ) ){ val2 = 0; } else { val2 = Math.abs( relativePosition( c1.getObject2(), c2.getObject2(), onto2 ) ); - //System.err.println( c1.getObject2()+" -- "+c2.getObject2()+" = "+val2 ); + //logger.trace( "{} -- {} = {}", c1.getObject2(), c2.getObject2(), val2 ); if ( val2 == 0 ) continue; } double val = Math.pow( symALPHA, val1 + val2 ); if ( withConfidence ) val *= 1. - Math.abs( c1.getStrength() - c2.getStrength() ); - //System.err.println( " => "+symALPHA+"^"+val1+"+"+val2+" * "+(1. - Math.abs( c1.getStrength() - c2.getStrength() ))+" = "+val ); + // Does not write 5 {} + //logger.trace( " => {}^{}+{}*{} = {}", symALPHA, val1, val2, (1. - Math.abs( c1.getStrength() - c2.getStrength() )), val ); if ( relsensitive && !c1.getRelation().equals( c2.getRelation() ) ) { if ( ( c1.getRelation().getRelation().equals("=") && ( c2.getRelation().getRelation().equals("<") || c2.getRelation().getRelation().equals(">") )) diff --git a/src/fr/inrialpes/exmo/align/impl/eval/GraphEvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/GraphEvaluator.java index e96157ca459102b551949758c4cf7d7dd826802c..821cc29461fc380483175e5c44a800fb7afe084f 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/GraphEvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/GraphEvaluator.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2004-2005, 2007-2010 + * Copyright (C) INRIA, 2004-2005, 2007-2010, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -38,6 +38,9 @@ import java.util.Comparator; import java.io.PrintWriter; import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * GraphEvaluator: an abstraction that is used for providing evaluation curves * instead of values (or sets of values) @@ -57,6 +60,7 @@ import java.net.URI; */ public abstract class GraphEvaluator { + final static Logger logger = LoggerFactory.getLogger( GraphEvaluator.class ); /** * The resolution of the provided result: by STEP steps @@ -181,7 +185,7 @@ public abstract class GraphEvaluator { } } } catch ( AlignmentException aex ) { - aex.printStackTrace(); + logger.debug( "IGNORED Exception", aex ); } return false; } diff --git a/src/fr/inrialpes/exmo/align/impl/eval/PRGraphEvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/PRGraphEvaluator.java index 5fb62cbcafdd73663d0e189454b927b62a08cb64..1b321b8e26919eb23ec83c074d8cf132c0e12aff 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/PRGraphEvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/PRGraphEvaluator.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2004-2005, 2007-2010 + * Copyright (C) INRIA, 2004-2005, 2007-2010, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -39,6 +39,9 @@ import java.util.Vector; import java.io.PrintWriter; import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Compute the precision recall graph on 11 points * @@ -65,6 +68,7 @@ import java.net.URI; */ public class PRGraphEvaluator extends GraphEvaluator { + final static Logger logger = LoggerFactory.getLogger( PRGraphEvaluator.class ); private int STEP = 10; @@ -105,7 +109,7 @@ public class PRGraphEvaluator extends GraphEvaluator { int nbcorrect = 0; int nbfound = 0; int increment = (STEP*nbexpected)/100; // 2010 should be computed with the total expected (in negrapheval) - //System.err.println(" INCREMENT SET "+increment ); + //logger.trace(" INCREMENT SET {}", increment ); int next = 0; points.add( new Pair( 0., 1. ) ); // [R=0%] next += increment; @@ -148,7 +152,7 @@ public class PRGraphEvaluator extends GraphEvaluator { int nbfound = 0; int increment = (STEP*nbexpected)/100; // 2010 should be computed with the total expected (in negrapheval) Vector<Pair> inflexion = new Vector<Pair>(); - //System.err.println(" INCREMENT SET "+increment ); + //logger.trace(" INCREMENT SET {}", increment ); int next = 0; // Collect the points that change recall // (the other provide lower precision from the same recall and are not considered) @@ -181,7 +185,7 @@ public class PRGraphEvaluator extends GraphEvaluator { // It works backward in the vector, // (in the same spirit as before, the maximum value so far -best- is retained) int j = inflexion.size()-1; // index in recall-ordered vector of points - //System.err.println( "Inflexion: "+j); + //logger.trace( "Inflexion: {}", j); int i = STEP; // index of the current recall interval double level = (double)i/STEP; // max level of that interval double best = 0.; // best value found for that interval @@ -199,7 +203,7 @@ public class PRGraphEvaluator extends GraphEvaluator { for( i = 0; i <= STEP; i++ ) { // JE: better with j/10 - //System.err.println( " prec at "+j+" : "+precisions[j] ); + //logger.trace( " prec at {} : {}", j, precisions[j] ); points.add( new Pair( ((double)i)/10, precisions[i] ) ); } diff --git a/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java index c5faa40d221985c8c12fe83dc02664456a8d7f4f..0817f36b7a7c039d254a561882e08de5ff573138 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java @@ -38,6 +38,8 @@ import java.util.Set; import java.io.PrintWriter; import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Evaluate proximity between two alignments. @@ -51,6 +53,7 @@ import java.net.URI; */ public class PRecEvaluator extends BasicEvaluator implements Evaluator { + final static Logger logger = LoggerFactory.getLogger( PRecEvaluator.class ); protected double precision = 1.; @@ -148,7 +151,7 @@ public class PRecEvaluator extends BasicEvaluator implements Evaluator { } else { result = 0.; } String timeExt = align2.getExtension( Namespace.ALIGNMENT.uri, Annotations.TIME ); if ( timeExt != null ) time = Long.parseLong(timeExt); - //System.err.println(">>>> " + nbcorrect + " : " + nbfound + " : " + nbexpected); + //logger.trace(">>>> {} : {} : {}", nbcorrect, nbfound, nbexpected); return (result); } @@ -162,7 +165,9 @@ public class PRecEvaluator extends BasicEvaluator implements Evaluator { try { result += " <dt>input1</dt><dd rel=\""+Namespace.ATLMAP.shortCut+":input1\" href=\""+align1.getOntology1URI()+"\">"+align1.getOntology1URI()+"</dd>"; result += " <dt>input2</dt><dd rel=\""+Namespace.ATLMAP.shortCut+":input2\" href=\""+align1.getOntology2URI()+"\">"+align1.getOntology2URI()+"</dd>"; - } catch (AlignmentException e) { e.printStackTrace(); }; + } catch (AlignmentException e) { + logger.debug( "IGNORED Exception", e ); + }; // Other missing items (easy to get) // result += " <"+Namespace.ATLMAP.shortCut+":falseNegative>"); // result += " <"+Namespace.ATLMAP.shortCut+":falsePositive>"); diff --git a/src/fr/inrialpes/exmo/align/impl/eval/SemPRecEvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/SemPRecEvaluator.java index 58f9281aa5d7a281a7b646884cbc4aa84f034503..7faad399bc84d90a24cca513670a4eac9a661a45 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/SemPRecEvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/SemPRecEvaluator.java @@ -264,8 +264,9 @@ public class SemPRecEvaluator extends PRecEvaluator implements Evaluator { manager.addIRIMapper(new SimpleIRIMapper( IRI.create( align.getOntology2URI() ), IRI.create( align.getFile2() ) ) ); try { - manager.loadOntologyFromOntologyDocument( IRI.create( align.getFile1() ) ); - manager.loadOntologyFromOntologyDocument( IRI.create( align.getFile2() ) ); + // JE: The two next lines should be useless + //manager.loadOntologyFromOntologyDocument( IRI.create( align.getFile1() ) ); + //manager.loadOntologyFromOntologyDocument( IRI.create( align.getFile2() ) ); // Load the ontology stream OWLOntology ontology = manager.loadOntologyFromOntologyDocument( in ); reasoner = new Reasoner( ontology ); @@ -310,8 +311,9 @@ public class SemPRecEvaluator extends PRecEvaluator implements Evaluator { manager.addIRIMapper(new SimpleIRIMapper( IRI.create( align.getOntology2URI() ), IRI.create( align.getFile2() ) ) ); try { - manager.loadOntologyFromOntologyDocument( IRI.create( align.getFile1() ) ); - manager.loadOntologyFromOntologyDocument( IRI.create( align.getFile2() ) ); + // JE: The two next lines should be useless + //manager.loadOntologyFromOntologyDocument( IRI.create( align.getFile1() ) ); + //manager.loadOntologyFromOntologyDocument( IRI.create( align.getFile2() ) ); OWLOntology ontology = manager.loadOntologyFromOntologyDocument( merged ); reasoner = new Reasoner( ontology ); } catch ( OWLOntologyCreationException ooce ) { diff --git a/src/fr/inrialpes/exmo/align/impl/eval/ThresholdGraphEvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/ThresholdGraphEvaluator.java index 76e260f868b7e8c007909ec46b4e30ef0f233823..6b7c332a5337f2b9f3d5acf707443fc07d42834e 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/ThresholdGraphEvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/ThresholdGraphEvaluator.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2004-2005, 2007-2010 + * Copyright (C) INRIA, 2004-2005, 2007-2010, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -39,6 +39,9 @@ import java.util.Vector; import java.io.PrintWriter; import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Compute the F-measure/precision/recall at various thresholds * @@ -48,6 +51,7 @@ import java.net.URI; */ public class ThresholdGraphEvaluator extends GraphEvaluator { + final static Logger logger = LoggerFactory.getLogger( ThresholdGraphEvaluator.class ); private int STEP = 50; @@ -106,7 +110,7 @@ public class ThresholdGraphEvaluator extends GraphEvaluator { // This is the version with increment // Determine what the increment is double increment = 1./(double)STEP; - //System.err.println(" INCREMENT SET "+increment ); + //logger.trace(" INCREMENT SET {}", increment ); double next = 1.; next -= increment; for ( EvalCell c : cellSet ) { diff --git a/src/fr/inrialpes/exmo/align/impl/eval/WeightedPREvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/WeightedPREvaluator.java index 6d22c9e008f246b1629b5f64430ccf2a0807b2e4..e91fbed139c84d9a2b167d18b495fa197ef5566e 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/WeightedPREvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/WeightedPREvaluator.java @@ -38,11 +38,13 @@ import java.util.Set; import java.io.PrintWriter; import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Evaluate proximity between two alignments. - * This function implements Precision/Recall. The first alignment - * is thus the expected one. + * This function implements weighted Precision/Recall. + * The first alignment is thus the expected one. * * Basic relation sensitivity has been implemented * @@ -51,10 +53,11 @@ import java.net.URI; */ public class WeightedPREvaluator extends BasicEvaluator implements Evaluator { + final static Logger logger = LoggerFactory.getLogger( WeightedPREvaluator.class ); protected double precision = 1.; - protected double recall = 1.; + protected double recall = 0.; protected double overall = 0.; @@ -85,7 +88,7 @@ public class WeightedPREvaluator extends BasicEvaluator implements Evaluator { public void init(){ precision = 1.; - recall = 1.; + recall = 0.; overall = 0.; fmeasure = 0.; time = 0; @@ -117,39 +120,51 @@ public class WeightedPREvaluator extends BasicEvaluator implements Evaluator { for ( Cell c1 : align1 ) { URI uri1 = c1.getObject2AsURI(); - nbexpected += c1.getStrength(); + // measure 1 + nbexpected += 1.; + // measure 2 + //nbexpected += c1.getStrength(); Set<Cell> s2 = align2.getAlignCells1( c1.getObject1() ); - double diff = -1.0; + double diff = -2.0; if( s2 != null ){ for( Cell c2 : s2 ) { URI uri2 = c2.getObject2AsURI(); if ( uri1.equals( uri2 ) && ( !relsensitive || c1.getRelation().equals( c2.getRelation() ) ) ) { diff = c1.getStrength() - c2.getStrength(); - nbcorrect1 += ((diff>0.)?diff:-diff); //1. - + // measure 1 + nbcorrect1 += ((diff>0.)?diff:-diff); + // measure 2 + //nbcorrect1 += Math.min( c1.getStrength(), ((diff>0.)?diff:-diff) ); break; } } } - if ( diff == -1.0 ) nbcorrect1 += c1.getStrength(); // the c1 not found + if ( diff == -2.0 ) nbcorrect1 += c1.getStrength(); // the c1 not found } for ( Cell c2 : align2 ) { URI uri2 = c2.getObject2AsURI(); - nbfound += c2.getStrength(); + // measure 1 + nbfound += 1.; + // measure 2 + //nbfound += c2.getStrength(); Set<Cell> s1 = align1.getAlignCells1( c2.getObject1() ); - double diff = -1.0; + double diff = -2.0; if( s1 != null ){ for( Cell c1 : s1 ) { URI uri1 = c1.getObject2AsURI(); if ( uri2.equals( uri1 ) && ( !relsensitive || c1.getRelation().equals( c2.getRelation() ) ) ) { diff = c1.getStrength() - c2.getStrength(); - nbcorrect2 += ((diff>0.)?diff:-diff); //1. - + // measure 1 + nbcorrect2 += ((diff>0.)?diff:-diff); + // measure 2 + //nbcorrect2 += Math.min( c2.getStrength(), ((diff>0.)?diff:-diff) ); break; } } } - if ( diff == -1.0 ) nbcorrect2 += c2.getStrength(); // the c2 not found + if ( diff == -2.0 ) nbcorrect2 += c2.getStrength(); // the c2 not found } // What is the definition if: @@ -159,6 +174,7 @@ public class WeightedPREvaluator extends BasicEvaluator implements Evaluator { // precision is 0 [= nbcorrect is 0] if ( nbfound != 0. ) precision = 1. - (nbcorrect2 / nbfound); if ( nbexpected != 0. ) recall = 1. - (nbcorrect1 / nbexpected); + else { recall = 1.; precision = 0.; } return computeDerived(); } public double eval( Properties params, Object cache ) throws AlignmentException { @@ -173,7 +189,7 @@ public class WeightedPREvaluator extends BasicEvaluator implements Evaluator { } else { result = 0.; } String timeExt = align2.getExtension( Namespace.ALIGNMENT.uri, Annotations.TIME ); if ( timeExt != null ) time = Long.parseLong(timeExt); - //System.err.println(">>>> " + nbcorrect + " : " + nbfound + " : " + nbexpected); + //logger.trace(">>>> {} : {} : {}", nbcorrect, nbfound, nbexpected); return (result); } @@ -187,7 +203,8 @@ public class WeightedPREvaluator extends BasicEvaluator implements Evaluator { try { result += " <dt>input1</dt><dd rel=\""+Namespace.ATLMAP.shortCut+":input1\" href=\""+align1.getOntology1URI()+"\">"+align1.getOntology1URI()+"</dd>"; result += " <dt>input2</dt><dd rel=\""+Namespace.ATLMAP.shortCut+":input2\" href=\""+align1.getOntology2URI()+"\">"+align1.getOntology2URI()+"</dd>"; - } catch (AlignmentException e) { e.printStackTrace(); }; + } catch (AlignmentException e) { + logger.debug( "IGNORED exception", e ); }; // Other missing items (easy to get) // result += " <"+Namespace.ATLMAP.shortCut+":falseNegative>"); // result += " <"+Namespace.ATLMAP.shortCut+":falsePositive>"); @@ -256,8 +273,8 @@ return result; public double getFound() { return nbfound; } // JE 2013: does not fit in WGroupEval anymore public double getCorrect() { return nbcorrect1; } - public double getCorrect1() { return nbcorrect1; } - public double getCorrect2() { return nbcorrect2; } + public double getCorrectExpected() { return nbcorrect1; } + public double getCorrectFound() { return nbcorrect2; } public long getTime() { return time; } } diff --git a/src/fr/inrialpes/exmo/align/impl/method/ClassStructAlignment.java b/src/fr/inrialpes/exmo/align/impl/method/ClassStructAlignment.java index 294d042d9590678848eb83c2f031f85deecc1193..9c91fb022032381902fc0936bd7a2a2e5cc55f62 100644 --- a/src/fr/inrialpes/exmo/align/impl/method/ClassStructAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/method/ClassStructAlignment.java @@ -1,7 +1,7 @@ /* * $id: ClassStructAlignment.java 1189 2010-01-03 17:57:13Z euzenat $ * - * Copyright (C) INRIA, 2003-2004, 2007-2010 + * Copyright (C) INRIA, 2003-2004, 2007-2010, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -24,6 +24,9 @@ import java.util.Vector; import java.util.Set; import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentProcess; import org.semanticweb.owl.align.Cell; @@ -54,11 +57,12 @@ import fr.inrialpes.exmo.ontosim.string.StringDistances; * - pia3 [ignored=0]: weigth for property domain * - pia4 [ignored=0]: weigth for property range * - * @author J�r�me Euzenat + * @author Jérôme Euzenat * @version $Id$ */ public class ClassStructAlignment extends DistanceAlignment implements AlignmentProcess { + final static Logger logger = LoggerFactory.getLogger( ClassStructAlignment.class ); private HeavyLoadedOntology<Object> honto1 = null; private HeavyLoadedOntology<Object> honto2 = null; @@ -109,7 +113,7 @@ public class ClassStructAlignment extends DistanceAlignment implements Alignment } classmatrix = new double[nbclass1+1][nbclass2+1]; - if (debug > 0) System.err.println("Initializing class distances"); + logger.debug("Initializing class distances"); // Initialize class distances // JE: Here AlignmentException is raised if cl or classlist2.get(j) @@ -126,7 +130,7 @@ public class ClassStructAlignment extends DistanceAlignment implements Alignment throw new AlignmentException( "Cannot find entity URI", owex ); } - if (debug > 0) System.err.print("Computing class distances\n"); + logger.debug("Computing class distances"); // Compute classes distances // -- for all of its attribute, find the best match if possible... easy // -- simply replace in the matrix the value by the value plus the diff --git a/src/fr/inrialpes/exmo/align/impl/method/NameAndPropertyAlignment.java b/src/fr/inrialpes/exmo/align/impl/method/NameAndPropertyAlignment.java index d5092eabba7414ec83fe085ecb73192729de8de0..c7abb0bcac97ad62166567d89dc1984cfe73c814 100644 --- a/src/fr/inrialpes/exmo/align/impl/method/NameAndPropertyAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/method/NameAndPropertyAlignment.java @@ -1,7 +1,7 @@ /* * $id: NameAndPropertyAlignment.java 1189 2010-01-03 17:57:13Z euzenat $ * - * Copyright (C) INRIA, 2003-2004, 2007-2010 + * Copyright (C) INRIA, 2003-2004, 2007-2010, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -26,6 +26,9 @@ import java.util.Vector; import java.util.Set; import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentProcess; import org.semanticweb.owl.align.AlignmentException; @@ -50,11 +53,12 @@ import fr.inrialpes.exmo.ontosim.string.StringDistances; * - pia3 [ignored=0]: weigth for property domain * - pia4 [ignored=0]: weigth for property range * - * @author J�r�me Euzenat / Jerome Pierson + * @author Jérôme Euzenat / Jérôme Pierson * @version $Id$ */ public class NameAndPropertyAlignment extends DistanceAlignment implements AlignmentProcess { + final static Logger logger = LoggerFactory.getLogger( NameAndPropertyAlignment.class ); private HeavyLoadedOntology<Object> honto1 = null; private HeavyLoadedOntology<Object> honto2 = null; @@ -97,9 +101,6 @@ public class NameAndPropertyAlignment extends DistanceAlignment implements Align double pia1 = 1.; // relation weight for name double epsillon = 0.05; // stoping condition - if ( params.getProperty("debug") != null ) - debug = Integer.parseInt( params.getProperty("debug") ); - try { // Create property lists and matrix for ( Object prop : honto1.getObjectProperties() ){ @@ -131,7 +132,7 @@ public class NameAndPropertyAlignment extends DistanceAlignment implements Align } classmatrix = new double[nbclass1+1][nbclass2+1]; - if (debug > 0) System.err.println("Initializing property distances"); + logger.debug("Initializing property distances"); for ( i=0; i<nbprop1; i++ ){ Object cl1 = proplist1.get(i); String st1 = honto1.getEntityName( cl1 ); @@ -149,7 +150,7 @@ public class NameAndPropertyAlignment extends DistanceAlignment implements Align } // Initialize class distances - if (debug > 0) System.err.println("Initializing class distances"); + logger.debug("Initializing class distances"); for ( i=0; i<nbclass1; i++ ){ Object cl1 = classlist1.get(i); for ( j=0; j<nbclass2; j++ ){ @@ -168,7 +169,7 @@ public class NameAndPropertyAlignment extends DistanceAlignment implements Align // Here create the best matches for property distance already // -- FirstExp: goes directly in the alignment structure // since it will never be refined anymore... - if (debug > 0) System.err.print("Storing property alignment\n"); + logger.debug("Storing property alignment"); for ( i=0; i<nbprop1; i++ ){ boolean found = false; int best = 0; @@ -182,7 +183,7 @@ public class NameAndPropertyAlignment extends DistanceAlignment implements Align } if ( found && max < 0.5) { addAlignCell( proplist1.get(i), proplist2.get(best), "=", 1.-max ); } } - if (debug > 0) System.err.print("Computing class distances\n"); + logger.debug("Computing class distances"); // Compute classes distances // -- for all of its attribute, find the best match if possible... easy // -- simply replace in the matrix the value by the value plus the @@ -230,7 +231,7 @@ public class NameAndPropertyAlignment extends DistanceAlignment implements Align // 1:1: get the best discard lines and columns and iterate // Here we basically implement ?:* because the algorithm // picks up the best matching object above threshold for i. - if (debug > 0) System.err.print("Storing class alignment\n"); + logger.debug("Storing class alignment"); for ( i=0; i<nbclass1; i++ ){ boolean found = false; diff --git a/src/fr/inrialpes/exmo/align/impl/method/StringDistAlignment.java b/src/fr/inrialpes/exmo/align/impl/method/StringDistAlignment.java index 39dc78132aac44ee99e5e8d317ae5dcd8b4fa05d..78b76d4a96a7e38a268df47ebd3a8a01c66c11b1 100644 --- a/src/fr/inrialpes/exmo/align/impl/method/StringDistAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/method/StringDistAlignment.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2003-2011 + * Copyright (C) INRIA, 2003-2011, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,6 +24,9 @@ import java.net.URI; import java.util.Properties; import java.lang.reflect.Method; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentProcess; import org.semanticweb.owl.align.AlignmentException; @@ -45,6 +48,7 @@ import fr.inrialpes.exmo.align.impl.MatrixMeasure; */ public class StringDistAlignment extends DistanceAlignment implements AlignmentProcess { + final static Logger logger = LoggerFactory.getLogger( StringDistAlignment.class ); Method dissimilarity = null; String methodName = "equalDistance"; @@ -59,14 +63,13 @@ public class StringDistAlignment extends DistanceAlignment implements AlignmentP try { s1 = ontology1().getEntityName( o1 ); s2 = ontology2().getEntityName( o2 ); - } catch ( Exception owex ) { // dealt with below - if ( debug > 1 ) owex.printStackTrace(); + } catch ( Exception owex ) { + logger.debug( "IGNORED (returned 1. instead)", owex ); }; // Unnamed entity = max distance if ( s1 == null || s2 == null ) return 1.; Object[] params = { s1.toLowerCase(), s2.toLowerCase() }; - if ( debug > 4 ) - System.err.println( "OB:"+s1+" ++ "+s2+" ==> "+dissimilarity.invoke( null, params )); + //logger.trace( "OB:{} ++ {} ==> {}", s1, s2, dissimilarity.invoke( null, params ) ); return ((Double)dissimilarity.invoke( null, params )).doubleValue(); } public double classMeasure( Object cl1, Object cl2 ) throws Exception { @@ -103,7 +106,7 @@ public class StringDistAlignment extends DistanceAlignment implements AlignmentP Class[] mParams = { sClass, sClass }; dissimilarity = Class.forName("fr.inrialpes.exmo.ontosim.string.StringDistances").getMethod( methodName, mParams ); } catch (ClassNotFoundException e) { - e.printStackTrace(); // never happens + logger.debug( "IGNORED (never happens)", e ); // never happens } catch (NoSuchMethodException e) { throw new AlignmentException( "Unknown method for StringDistAlignment : "+params.getProperty("stringFunction"), e ); } diff --git a/src/fr/inrialpes/exmo/align/impl/method/StrucSubsDistAlignment.java b/src/fr/inrialpes/exmo/align/impl/method/StrucSubsDistAlignment.java index 05844d7739e8e4e7fae884422b8802a410f0d24d..7c529114976284a917cca2594f44927926540174 100644 --- a/src/fr/inrialpes/exmo/align/impl/method/StrucSubsDistAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/method/StrucSubsDistAlignment.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2003-2004, 2007-2010 + * Copyright (C) INRIA, 2003-2004, 2007-2010, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -18,7 +18,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - package fr.inrialpes.exmo.align.impl.method; import java.util.Vector; @@ -26,6 +25,9 @@ import java.util.Set; import java.util.Properties; import java.lang.Integer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentProcess; import org.semanticweb.owl.align.Cell; @@ -51,11 +53,12 @@ import fr.inrialpes.exmo.ontosim.string.StringDistances; * - pia3 [ignored=0]: weigth for property domain * - pia4 [ignored=0]: weigth for property range * - * @author J�r�me Euzenat + * @author Jérôme Euzenat * @version $Id$ */ public class StrucSubsDistAlignment extends DistanceAlignment implements AlignmentProcess { + final static Logger logger = LoggerFactory.getLogger( StrucSubsDistAlignment.class ); private HeavyLoadedOntology<Object> honto1 = null; private HeavyLoadedOntology<Object> honto2 = null; @@ -99,9 +102,6 @@ public class StrucSubsDistAlignment extends DistanceAlignment implements Alignme double pia1 = 1.; // relation weight for name double epsillon = 0.05; // stoping condition - if ( params.getProperty("debug") != null ) - debug = Integer.parseInt( params.getProperty("debug") ); - try { // Create property lists and matrix for ( Object prop : honto1.getObjectProperties() ){ @@ -133,7 +133,7 @@ public class StrucSubsDistAlignment extends DistanceAlignment implements Alignme } classmatrix = new double[nbclass1+1][nbclass2+1]; - if (debug > 0) System.err.println("Initializing property distances"); + logger.debug("Initializing property distances"); for ( i=0; i<nbprop1; i++ ){ Object cl1 = proplist1.get(i); @@ -152,7 +152,7 @@ public class StrucSubsDistAlignment extends DistanceAlignment implements Alignme } // Initialize class distances - if (debug > 0) System.err.println("Initializing class distances"); + logger.debug("Initializing class distances"); for ( i=0; i<nbclass1; i++ ){ Object cl1 = classlist1.get(i); for ( j=0; j<nbclass2; j++ ){ @@ -171,7 +171,7 @@ public class StrucSubsDistAlignment extends DistanceAlignment implements Alignme // Here create the best matches for property distance already // -- FirstExp: goes directly in the alignment structure // since it will never be refined anymore... - if (debug > 0) System.err.print("Storing property alignment\n"); + logger.debug("Storing property alignment"); for ( i=0; i<nbprop1; i++ ){ boolean found = false; int best = 0; @@ -186,7 +186,7 @@ public class StrucSubsDistAlignment extends DistanceAlignment implements Alignme if ( found ) { addAlignCell( proplist1.get(i), proplist2.get(best), "=", 1.-max ); } } - if (debug > 0) System.err.print("Computing class distances\n"); + logger.debug("Computing class distances"); // Compute classes distances // -- for all of its attribute, find the best match if possible... easy // -- simply replace in the matrix the value by the value plus the @@ -242,7 +242,7 @@ public class StrucSubsDistAlignment extends DistanceAlignment implements Alignme // 1:1: get the best discard lines and columns and iterate // Here we basically implement ?:* because the algorithm // picks up the best matching object above threshold for i. - if (debug > 0) System.err.print("Storing class alignment\n"); + logger.debug("Storing class alignment"); for ( i=0; i<nbclass1; i++ ){ boolean found = false; diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/COWLMappingRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/COWLMappingRendererVisitor.java index 8604a6d0b3e386b0c27ebc723af0fb0ceec9b22d..57551611e2d71629ec91b31a641467d38ee63af1 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/COWLMappingRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/COWLMappingRendererVisitor.java @@ -93,7 +93,7 @@ public class COWLMappingRendererVisitor extends GenericReflectiveVisitor impleme writer.print(" <cowl:targetOntology>\n"); writer.print(" <owl:Ontology rdf:about=\""+onto2.getURI()+"\"/>\n"); writer.print(" </cowl:targetOntology>\n"); - for( Cell c : align ){ + for( Cell c : alignment ){ c.accept( this ); } //end for writer.print(" </cowl:Mapping>\n"); diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/GenericReflectiveVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/GenericReflectiveVisitor.java index ea9bd4fd23514ead9ad886413ccf160f55b3fc2d..7c773f1529ccf5ea9d65fa64a3d615f622c526c5 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/GenericReflectiveVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/GenericReflectiveVisitor.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2012 + * Copyright (C) INRIA, 2012-2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -23,6 +23,9 @@ package fr.inrialpes.exmo.align.impl.renderer; import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.align.AlignmentException; /** @@ -34,6 +37,7 @@ import org.semanticweb.owl.align.AlignmentException; * and Relation may be extended. */ public class GenericReflectiveVisitor { + final static Logger logger = LoggerFactory.getLogger( GenericReflectiveVisitor.class ); /** * Finds the visit(X) method corresponding to the object class (subclass of a root class) @@ -54,7 +58,7 @@ public class GenericReflectiveVisitor { } } if ( m == null ) {//newc == Object.class ) { - // System.out.println( "Searching for interfaces" ); + // logger.trace( "Searching for interfaces" ); Class[] interfaces = c.getInterfaces(); for ( int i=0; i < interfaces.length; i++ ) { if ( interfaces[i] != root ) { @@ -83,12 +87,12 @@ public class GenericReflectiveVisitor { method.invoke( visitor, new Object[] {o} ); return true; } catch ( IllegalAccessException iaex ) { - iaex.printStackTrace(); + logger.debug( "IGNORED Exception", iaex ); } catch ( InvocationTargetException itex ) { if ( itex.getCause() instanceof AlignmentException ) { throw (AlignmentException)itex.getCause(); } else { - itex.printStackTrace(); + logger.debug( "IGNORED Exception", itex ); } } } diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/GraphPatternRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/GraphPatternRendererVisitor.java index 2d0f4ec7c9848ee55dbef1605e918924e286dc88..bd40289c2f88efe0a4ae1b402e945027bbabbc4c 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/GraphPatternRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/GraphPatternRendererVisitor.java @@ -32,6 +32,9 @@ import java.util.Iterator; import java.util.List; import java.util.Set; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentException; import org.semanticweb.owl.align.Cell; @@ -71,6 +74,7 @@ import fr.inrialpes.exmo.align.parser.SyntaxElement.Constructor; // JE: create a string... problem with increment. public abstract class GraphPatternRendererVisitor extends IndentedRendererVisitor implements EDOALVisitor { + final static Logger logger = LoggerFactory.getLogger( GraphPatternRendererVisitor.class ); Alignment alignment = null; Cell cell = null; @@ -163,7 +167,7 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito if ( out != null ) // there was at least one file out.close(); } catch(IOException ioe) { - System.err.println( ioe ); + logger.debug( "IGNORED Exception", ioe ); } } diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/OWLAxiomsRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/OWLAxiomsRendererVisitor.java index e6ab0b1886c3d02c3a86d73b25867997cbe8d5d7..4506a4d67208a0545ca1604cd2d4d385b88ea584 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/OWLAxiomsRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/OWLAxiomsRendererVisitor.java @@ -25,6 +25,9 @@ import java.util.Properties; import java.io.PrintWriter; import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentVisitor; import org.semanticweb.owl.align.AlignmentException; @@ -87,6 +90,7 @@ import fr.inrialpes.exmo.align.impl.edoal.EDOALVisitor; */ public class OWLAxiomsRendererVisitor extends IndentedRendererVisitor implements AlignmentVisitor, EDOALVisitor { + final static Logger logger = LoggerFactory.getLogger( OWLAxiomsRendererVisitor.class ); boolean heterogeneous = false; boolean edoal = false; Alignment alignment = null; @@ -108,6 +112,7 @@ public class OWLAxiomsRendererVisitor extends IndentedRendererVisitor implements public void visit( Alignment align ) throws AlignmentException { if ( subsumedInvocableMethod( this, align, Alignment.class ) ) return; // default behaviour + //logger.trace( "Alignment: {}", align ); if ( align instanceof ObjectAlignment ) { alignment = align; onto1 = (LoadedOntology)((ObjectAlignment)alignment).getOntologyObject1(); @@ -139,10 +144,10 @@ public class OWLAxiomsRendererVisitor extends IndentedRendererVisitor implements writer.print(" </owl:Ontology>"+NL+NL); try { - for( Cell c : align ){ + for( Cell c : alignment ){ Object ob1 = c.getObject1(); Object ob2 = c.getObject2(); - + //logger.trace( "Rendering {} -- {}", ob1, ob2 ); if ( heterogeneous || edoal || ( onto1.isClass( ob1 ) && onto2.isClass( ob2 ) ) || ( onto1.isDataProperty( ob1 ) && onto2.isDataProperty( ob2 ) ) || @@ -154,6 +159,9 @@ public class OWLAxiomsRendererVisitor extends IndentedRendererVisitor implements } catch ( OntowrapException owex ) { throw new AlignmentException( "Error accessing ontology", owex ); } + //logger.trace( "Heterogeneous: {}", heterogeneous); + //logger.trace( "EDOAL: {}", edoal); + //logger.trace( "onto1: {}", onto1); writer.print("</rdf:RDF>"+NL); } diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java index c7433db0a5ef73e42d31228ec682df607fee3225..59ff583ee8d68b40bcd457c323c2f109bd068daf 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2003-2010, 2012 + * Copyright (C) INRIA, 2003-2010, 2012-2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -28,6 +28,9 @@ import java.util.Properties; import java.io.PrintWriter; import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentVisitor; import org.semanticweb.owl.align.AlignmentException; @@ -87,6 +90,7 @@ import fr.inrialpes.exmo.align.impl.edoal.EDOALVisitor; */ public class RDFRendererVisitor extends IndentedRendererVisitor implements AlignmentVisitor,EDOALVisitor { + final static Logger logger = LoggerFactory.getLogger( RDFRendererVisitor.class ); Alignment alignment = null; Cell cell = null; @@ -111,6 +115,7 @@ public class RDFRendererVisitor extends IndentedRendererVisitor implements Align } public void visit( Alignment align ) throws AlignmentException { + //logger.trace( "Processing alignment {}", align ); if ( subsumedInvocableMethod( this, align, Alignment.class ) ) return; // default behaviour String extensionString = ""; @@ -224,6 +229,7 @@ public class RDFRendererVisitor extends IndentedRendererVisitor implements Align } public void visit( Cell cell ) throws AlignmentException { + //logger.trace( "Processing cell {}", cell ); if ( subsumedInvocableMethod( this, cell, Cell.class ) ) return; // default behaviour this.cell = cell; @@ -242,6 +248,7 @@ public class RDFRendererVisitor extends IndentedRendererVisitor implements Align if ( alignment.getLevel().startsWith("2EDOAL") ) { indentedOutputln("<"+SyntaxElement.ENTITY1.print(DEF)+">"); increaseIndent(); + //logger.trace( "Processing ob1 {}", cell.getObject1() ); ((Expression)(cell.getObject1())).accept( this ); decreaseIndent(); writer.print(NL); @@ -249,6 +256,7 @@ public class RDFRendererVisitor extends IndentedRendererVisitor implements Align indentedOutputln("<"+SyntaxElement.ENTITY2.print(DEF)+">"); increaseIndent(); ((Expression)(cell.getObject2())).accept( this ); + //logger.trace( "Processing ob2 {}", cell.getObject2() ); decreaseIndent(); writer.print(NL); indentedOutputln("</"+SyntaxElement.ENTITY2.print(DEF)+">"); @@ -644,7 +652,7 @@ public class RDFRendererVisitor extends IndentedRendererVisitor implements Align indentedOutput("</"+SyntaxElement.TRANSF.print(DEF)+">"); } - public void visit( final Datatype e ) throws AlignmentException { + public void visit( final Datatype e ) { indentedOutput("<"+SyntaxElement.EDATATYPE.print(DEF)+">"); writer.print("<"+SyntaxElement.DATATYPE.print(DEF)+" "+SyntaxElement.RDF_ABOUT.print(DEF)+"=\""+e.getType()+"\"/>"); writer.print("</"+SyntaxElement.EDATATYPE.print(DEF)+">"); diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/SEKTMappingRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/SEKTMappingRendererVisitor.java index 2b3fe3493e8562ebe05f1aa3b9a547b2c790ffef..d24d75a93c7867528d78f72a1280507bbf63254a 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/SEKTMappingRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/SEKTMappingRendererVisitor.java @@ -80,7 +80,7 @@ public class SEKTMappingRendererVisitor extends GenericReflectiveVisitor impleme writer.print(" source(<\""+onto1.getURI()+"\">)\n"); writer.print(" target(<\""+onto2.getURI()+"\">)\n"); - for( Cell c : align ){ + for( Cell c : alignment ){ c.accept( this ); } //end for writer.print(")\n"); diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLConstructRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLConstructRendererVisitor.java index dbf00e2b743b0530a91e6c77f9b9fe7821c09df4..3f810dfada633db008e4ea881b22fff07a0a5439 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLConstructRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLConstructRendererVisitor.java @@ -99,7 +99,7 @@ public class SPARQLConstructRendererVisitor extends GraphPatternRendererVisitor content_Corese += "<!ENTITY rul \"http://ns.inria.fr/edelweiss/2011/rule#\">" + NL; content_Corese += "]>" + NL; content_Corese += "<rdf:RDF xmlns:rdfs=\"&rdfs;\" xmlns:rdf=\"&rdf;\" xmlns = \'&rul;\' >" + NL + NL + NL; - for( Cell c : align ){ c.accept( this ); }; + for( Cell c : alignment ){ c.accept( this ); }; content_Corese += "</rdf:RDF>" + NL; if ( corese ) { if( split ) { diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLSelectRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLSelectRendererVisitor.java index 916f56887d35b5cbbd71cdcb0a3064cd00475ff9..058936d93362010f4c1406748869bc2fecfb3654 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLSelectRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLSelectRendererVisitor.java @@ -80,7 +80,7 @@ public class SPARQLSelectRendererVisitor extends GraphPatternRendererVisitor imp throw new AlignmentException("SPARQLSELECTRenderer: cannot render simple alignment. Need an EDOALAlignment", alex ); } } - for( Cell c : align ){ c.accept( this ); }; + for( Cell c : alignment ){ c.accept( this ); }; } public void visit( Cell cell ) throws AlignmentException { diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/SWRLRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/SWRLRendererVisitor.java index babf44648069ba3c23a32c504fbcef0b0ba7f4da..b4c2d42cacba6609604b8699ff3137b187bc86a1 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/SWRLRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/SWRLRendererVisitor.java @@ -25,6 +25,9 @@ import java.util.Properties; import java.io.PrintWriter; import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentVisitor; import org.semanticweb.owl.align.AlignmentException; @@ -47,6 +50,7 @@ import fr.inrialpes.exmo.ontowrap.OntowrapException; */ public class SWRLRendererVisitor extends GenericReflectiveVisitor implements AlignmentVisitor { + final static Logger logger = LoggerFactory.getLogger( SWRLRendererVisitor.class ); PrintWriter writer = null; Alignment alignment = null; LoadedOntology onto1 = null; @@ -90,7 +94,7 @@ public class SWRLRendererVisitor extends GenericReflectiveVisitor implements Ali } writer.print("\n"); writer.println(" <owlx:Imports rdf:resource=\""+onto1.getURI()+"\"/>\n"); - for( Cell c : align ){ + for( Cell c : alignment ){ c.accept( this ); } writer.println("</swrlx:Ontology>"); @@ -104,13 +108,23 @@ public class SWRLRendererVisitor extends GenericReflectiveVisitor implements Ali } public void visit( EquivRelation rel ) throws AlignmentException { - // JE: We should send warnings when dataproperties are mapped to individual properties and vice versa... Object ob1 = cell.getObject1(); Object ob2 = cell.getObject2(); - URI uri1; - URI uri2; + generateImplication( ob1, ob2 ); + generateImplication( ob2, ob1 ); + } + + public void visit( SubsumeRelation rel ) throws AlignmentException { + generateImplication( cell.getObject2(), cell.getObject1() ); + }; + public void visit( SubsumedRelation rel ) throws AlignmentException { + generateImplication( cell.getObject1(), cell.getObject2() ); + }; + + public void generateImplication( Object ob1, Object ob2 ) throws AlignmentException { + // JE: We should send warnings when dataproperties are mapped to individual properties and vice versa... try { - uri1 = onto1.getEntityURI( ob1 ); + URI uri1 = onto1.getEntityURI( ob1 ); writer.println(" <ruleml:imp>"); writer.println(" <ruleml:_body>"); if ( onto1.isClass( ob1 ) ){ @@ -131,7 +145,7 @@ public class SWRLRendererVisitor extends GenericReflectiveVisitor implements Ali } writer.println(" </ruleml:_body>"); writer.println(" <ruleml:_head>"); - uri2 = onto2.getEntityURI( ob2 ); + URI uri2 = onto2.getEntityURI( ob2 ); if ( onto2.isClass( ob2 ) ){ writer.println(" <swrlx:classAtom>"); writer.println(" <owllx:Class owllx:name=\""+uri2+"\"/>"); @@ -155,9 +169,66 @@ public class SWRLRendererVisitor extends GenericReflectiveVisitor implements Ali } } - public void visit( SubsumeRelation rel ){}; - public void visit( SubsumedRelation rel ){}; - public void visit( IncompatRelation rel ){}; + public void visit( IncompatRelation rel ) throws AlignmentException { + // JE: We should send warnings when dataproperties are mapped to individual properties and vice versa... + Object ob1 = cell.getObject1(); + Object ob2 = cell.getObject2(); + try { + URI uri1 = onto1.getEntityURI( ob1 ); + URI uri2 = onto2.getEntityURI( ob2 ); + writer.println(" <ruleml:imp>"); + if ( onto1.isClass( ob1 ) && onto2.isClass( ob2 ) ){ + writer.println(" <ruleml:_body>"); + writer.println(" <swrl:classAtom>"); + writer.println(" <owllx:Class owllx:name=\""+uri1+"\"/>"); + writer.println(" <ruleml:var>x</ruleml:var>"); + writer.println(" </swrl:classAtom>"); + writer.println(" <swrlx:classAtom>"); + writer.println(" <owllx:Class owllx:name=\""+uri2+"\"/>"); + writer.println(" <ruleml:var>x</ruleml:var>"); + writer.println(" </swrl:classAtom>"); + writer.println(" </ruleml:_body>"); + writer.println(" <ruleml:_head>"); + writer.println(" <swrlx:classAtom>"); + writer.println(" <owllx:Class owllx:name=\"owl:Nothing\"/>"); + writer.println(" <ruleml:var>x</ruleml:var>"); + writer.println(" </swrl:classAtom>"); + writer.println(" </ruleml:_head>"); + } else if ( onto1.isDataProperty( ob1 ) && onto2.isDataProperty( ob2 ) ) { + writer.println(" <ruleml:_body>"); + writer.println(" <swrl:datavaluedPropertyAtom swrlx:property=\""+uri1+"\"/>"); + writer.println(" <ruleml:var>x</ruleml:var>"); + writer.println(" <ruleml:var>y</ruleml:var>"); + writer.println(" <swrl:datavaluedPropertyAtom>"); + writer.println(" <swrl:datavaluedPropertyAtom swrlx:property=\""+uri2+"\"/>"); + writer.println(" <ruleml:var>x</ruleml:var>"); + writer.println(" <ruleml:var>y</ruleml:var>"); + writer.println(" </swrl:datavaluedPropertyAtom>"); + writer.println(" </ruleml:_body>"); + writer.println(" <ruleml:_head>"); + writer.println(" </ruleml:_head>"); + } else if ( onto1.isObjectProperty( ob1 ) && onto2.isObjectProperty( ob2 ) ) { + writer.println(" <ruleml:_body>"); + writer.println(" <swrl:individualPropertyAtom swrlx:property=\""+uri1+"\"/>"); + writer.println(" <ruleml:var>x</ruleml:var>"); + writer.println(" <ruleml:var>y</ruleml:var>"); + writer.println(" </swrl:individualPropertyAtom>"); + writer.println(" <swrl:individualPropertyAtom swrlx:property=\""+uri2+"\"/>"); + writer.println(" <ruleml:var>x</ruleml:var>"); + writer.println(" <ruleml:var>y</ruleml:var>"); + writer.println(" </swrl:individualPropertyAtom>"); + writer.println(" </ruleml:_body>"); + writer.println(" <ruleml:_head>"); + writer.println(" </ruleml:_head>"); + } else { + logger.warn( "Cannot generate heterogeneous rules" ); + } + writer.println(" </ruleml:imp>\n"); + } catch ( OntowrapException owex ) { + throw new AlignmentException( "Error accessing ontology", owex ); + } + } + public void visit( Relation rel ) throws AlignmentException { if ( subsumedInvocableMethod( this, rel, Relation.class ) ) return; // default behaviour diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/XSLTRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/XSLTRendererVisitor.java index ab1970734f838ac544a2d28ab5a1691bd07013fa..c13dc989392503ec14a4f8ee908cf34f8a621b8a 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/XSLTRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/XSLTRendererVisitor.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2003-2004, 2006-2010, 2012 + * Copyright (C) INRIA, 2003-2004, 2006-2010, 2012-2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -78,7 +78,7 @@ public class XSLTRendererVisitor extends GenericReflectiveVisitor implements Ali onto1 = (LoadedOntology)((ObjectAlignment)align).getOntologyObject1(); onto2 = (LoadedOntology)((ObjectAlignment)align).getOntologyObject2(); } - for( Cell c : align ){ + for( Cell c : alignment ){ collectURIs( c ); } alignment = align; @@ -98,7 +98,7 @@ public class XSLTRendererVisitor extends GenericReflectiveVisitor implements Ali } writer.print("\n"); - for ( Enumeration e = align.getElements() ; e.hasMoreElements(); ){ + for ( Enumeration e = alignment.getElements() ; e.hasMoreElements(); ){ Cell c = (Cell)e.nextElement(); c.accept( this ); } @@ -136,8 +136,8 @@ public class XSLTRendererVisitor extends GenericReflectiveVisitor implements Ali throw new AlignmentException( "Cannot find entity URI", owex ); } } else { - entity1URI = cell.getObject1AsURI(alignment); - entity2URI = cell.getObject2AsURI(alignment); + entity1URI = cell.getObject1AsURI( alignment ); + entity2URI = cell.getObject2AsURI( alignment ); } if ( entity1URI != null ) { String ns1 = entity1URI.getScheme()+":"+entity1URI.getSchemeSpecificPart()+"#"; @@ -163,8 +163,8 @@ public class XSLTRendererVisitor extends GenericReflectiveVisitor implements Ali throw new AlignmentException( "Cannot find entity URI", owex ); } } else { - writer.println(" <xsl:template match=\""+namespacify(cell.getObject1AsURI(alignment))+"\">"); - writer.println(" <xsl:element name=\""+namespacify(cell.getObject2AsURI(alignment))+"\">"); + writer.println(" <xsl:template match=\""+namespacify(cell.getObject1AsURI( alignment ))+"\">"); + writer.println(" <xsl:element name=\""+namespacify(cell.getObject2AsURI( alignment ))+"\">"); } writer.println(" <xsl:apply-templates select=\"*|@*|text()\"/>"); writer.println(" </xsl:element>"); diff --git a/src/fr/inrialpes/exmo/align/ling/JWNLAlignment.java b/src/fr/inrialpes/exmo/align/ling/JWNLAlignment.java index 45511c63625e98187baec2b3f949ce7fffeb2989..29f07beb925dc895424dbdee857f1d7a5c3cadbf 100644 --- a/src/fr/inrialpes/exmo/align/ling/JWNLAlignment.java +++ b/src/fr/inrialpes/exmo/align/ling/JWNLAlignment.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2003-2005, 2007, 2009-2010 + * Copyright (C) INRIA, 2003-2005, 2007, 2009-2010, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -32,12 +32,17 @@ import org.semanticweb.owl.align.AlignmentException; import java.util.Properties; import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * This Class uses JWNLDistances to align two ontologies. * @version $Id$ */ public class JWNLAlignment extends DistanceAlignment implements AlignmentProcess { + final static Logger logger = LoggerFactory.getLogger( JWNLAlignment.class ); + final static String WNVERS = "3.0"; final static int BASICSYNDIST = 0; @@ -93,7 +98,7 @@ public class JWNLAlignment extends DistanceAlignment implements AlignmentProcess return measure( pr1, pr2 ); } public double individualMeasure( Object id1, Object id2 ) throws Exception { - if ( debug > 4 ) System.err.println( "ID:"+id1+" -- "+id2); + //logger.trace( "ID: {} -- {}", id1, id2 ); return measure( id1, id2 ); } } diff --git a/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java b/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java index c84d9d15c33be47e5cda769fb6af0febbab86ba8..ce0a5cc4857062d5489a7ec795c613f52b3ddbb3 100644 --- a/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java +++ b/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2003-2005, 2007-2010, 2012 + * Copyright (C) INRIA, 2003-2005, 2007-2010, 2012-2013 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -33,6 +33,9 @@ import java.lang.Integer; import java.lang.Double; import java.util.Hashtable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.Cell; import org.semanticweb.owl.align.AlignmentException; @@ -47,7 +50,7 @@ import fr.inrialpes.exmo.align.impl.Annotations; /** * This class allows the creation of a parser for an Alignment file. * The class is called by: - * AlignmentParser parser = new AlignmentParser( debugLevel ); + * AlignmentParser parser = new AlignmentParser(); * Alignment alignment = parser.parse( input ); * input can be a URI as a String, an InputStream * This new version (January 2004) parses the alignment description in @@ -56,12 +59,8 @@ import fr.inrialpes.exmo.align.impl.Annotations; */ public class AlignmentParser { + final static Logger logger = LoggerFactory.getLogger( AlignmentParser.class ); - /** - * level of debug/warning information - */ - protected int debugMode = 0; - /** * a URI to a process */ @@ -97,11 +96,11 @@ public class AlignmentParser { /** * Creates a Parser. - * @param debugMode The value of the debug mode + * @param debugMode The value of the debug mode DEPRECATED */ - public AlignmentParser( int debugMode ) { - this.debugMode = debugMode; - } + public AlignmentParser( int debugMode ) {} + + public AlignmentParser() {} public void setEmbedded( boolean b ){ embedded = b; @@ -129,21 +128,19 @@ public class AlignmentParser { */ private Alignment callParser( Object o ) throws AlignmentException { try { - XMLParser parser = new XMLParser( debugMode ); + XMLParser parser = new XMLParser(); if ( embedded ) parser.setEmbedded( embedded ); //alignment = parser.parse( o ); alignment = callParser( parser, o ); } catch ( Exception e ) { - if ( debugMode > 0 ) { - System.err.println("XMLParser failed to parse alignment (INFO)"); - e.printStackTrace(); - } + logger.debug( "XMLParser failed to parse alignment (INFO)", e ); + logger.debug( "Using RDFParser instead" ); try { if ( !embedded ) { - RDFParser rparser = new RDFParser( debugMode ); + RDFParser rparser = new RDFParser(); alignment = callParser( rparser, o ); } else { - throw new AlignmentException( "Cannot parse "+o+" (use debug>0 for more info)", e ); + throw new AlignmentException( "Cannot parse "+o+" (use logging for more info)", e ); } } catch ( Exception ex ) { // JE: should contain both ex and e diff --git a/src/fr/inrialpes/exmo/align/parser/RDFParser.java b/src/fr/inrialpes/exmo/align/parser/RDFParser.java index 8ab22b2954da4b778f1551fe9d697f6f75ec84b0..c88cfe0453ce78fb6602f2c7e27a98a89da816f2 100644 --- a/src/fr/inrialpes/exmo/align/parser/RDFParser.java +++ b/src/fr/inrialpes/exmo/align/parser/RDFParser.java @@ -3,7 +3,7 @@ * * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck * Sourceforge version 1.7 - 2008 - * Copyright (C) INRIA, 2008-2010, 2012 + * Copyright (C) INRIA, 2008-2010, 2012-2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -84,8 +84,8 @@ import java.util.HashSet; import java.util.List; import java.util.LinkedList; -import java.util.logging.Logger; -import java.util.logging.Level; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; // Yes we are relying on Jena for parsing RDF import com.hp.hpl.jena.rdf.model.Model; @@ -116,13 +116,10 @@ import com.hp.hpl.jena.vocabulary.RDF; * @version $Revision: 1.7 $ */ public class RDFParser { - - private static Logger logger = Logger.getLogger(RDFParser.class.toString()); + final static Logger logger = LoggerFactory.getLogger( RDFParser.class ); private static Model rDFModel; - private int debug = 0; - private boolean isPattern = false; // I contain variables private boolean speedparse = false; // skip all checks @@ -131,17 +128,13 @@ public class RDFParser { /** * Creates an RDF Parser. */ - public RDFParser() { - this(0); - } + public RDFParser() {} /** * Creates an RDF Parser. - * @param debugMode The value of the debug mode + * @param debugMode The value of the debug mode (DEPRECATED) */ - public RDFParser( int debugMode ) { - debug = debugMode; - } + public RDFParser( int debugMode ) {} /** * Initialisation of the structures @@ -172,7 +165,7 @@ public class RDFParser { // Initialize the syntax description initSyntax(); // Shut up logging handling - com.hp.hpl.jena.rdf.model.impl.RDFDefaultErrorHandler.silent = true; + //com.hp.hpl.jena.rdf.model.impl.RDFDefaultErrorHandler.silent = true; // Get the statement including alignment resource as rdf:type StmtIterator stmtIt = rdfmodel.listStatements(null, RDF.type,(Resource)SyntaxElement.getResource("Alignment")); // Take the first one if it exists @@ -283,11 +276,10 @@ public class RDFParser { stmtIt = node.listProperties((Property)SyntaxElement.MAP.resource ); while (stmtIt.hasNext()) { Statement stmt = stmtIt.nextStatement(); - if ( debug > 0 ) System.err.println( " ---------------> "+stmt ); + //logger.trace( " ---------------> {}", stmt ); try { alignment.addAlignCell( parseCell( stmt.getResource() ) ); } catch ( AlignmentException ae ) { - System.err.println( "Error "+ae ); - ae.printStackTrace(); + logger.debug( "IGNORED Exception", ae ); } } @@ -394,10 +386,8 @@ public class RDFParser { Expression s = parseExpression( entity1 ); Expression t = parseExpression( entity2 ); - if ( debug > 0 ) { - System.err.println(" s : "+s); - System.err.println(" t : "+t); - } + //logger.trace(" s : {}", s); + //logger.trace(" t : {}", t); EDOALCell cell = new EDOALCell( id, s, t, type, m ); // Parse the possible transformations @@ -406,13 +396,11 @@ public class RDFParser { Statement stmt = stmtIt.nextStatement(); try { cell.addTransformation( parseTransformation( stmt.getResource() ) ); } catch ( AlignmentException ae ) { - System.err.println( "Error "+ae ); - ae.printStackTrace(); + logger.debug( "INGORED Exception", ae ); } } return cell; } catch (Exception e) { //wrap other type exception - logger.log(java.util.logging.Level.SEVERE, "The cell isn't correct: " + node.getLocalName() + " "+e.getMessage()); throw new AlignmentException("Cannot parse correspondence " + node.getLocalName(), e); } } @@ -429,13 +417,10 @@ public class RDFParser { Resource entity2 = node.getProperty((Property)SyntaxElement.TRENT2.resource).getResource(); ValueExpression s = parseValue( entity1 ); ValueExpression t = parseValue( entity2 ); - if ( debug > 0 ) { - System.err.println(" (Transf)s : "+s); - System.err.println(" (Transf)t : "+t); - } + //logger.trace(" (Transf)s : {}", s); + //logger.trace(" (Transf)t : {}", t); return new Transformation( type, s, t ); } catch (Exception e) { //wrap other type exception - logger.log(java.util.logging.Level.SEVERE, "The cell isn't correct:" + node.getLocalName() + " "+e.getMessage()); throw new AlignmentException("Cannot parse transformation " + node, e); } } @@ -476,10 +461,8 @@ public class RDFParser { } protected ClassExpression parseClass( final Resource node ) throws AlignmentException { - if ( debug > 1 ) { - StmtIterator it = node.listProperties(); - while ( it.hasNext() ) System.err.println( " > "+it.next() ); - } + //StmtIterator it = node.listProperties(); + //while ( it.hasNext() ) logger.trace( " > {}", it.next() ); Resource rdfType = node.getProperty(RDF.type).getResource(); if ( rdfType.equals( SyntaxElement.CLASS_EXPR.resource ) ) { URI id = getNodeId( node ); @@ -696,7 +679,7 @@ public class RDFParser { protected Datatype parseDatatype ( final RDFNode nn ) throws AlignmentException { String uri = null; if ( nn.isLiteral() ) { // Legacy - System.err.println( "Warning: datatypes must be Datatype objects ("+((Literal)nn).getString()+")" ); + logger.warn( "Datatypes must be Datatype objects ({})", ((Literal)nn).getString() ); uri = ((Literal)nn).getString(); } else if ( nn.isResource() ) { if ( !((Resource)nn).getProperty(RDF.type).getResource().equals( SyntaxElement.DATATYPE.resource ) ) @@ -824,7 +807,7 @@ public class RDFParser { u = new URI( ((Resource)node).getProperty( (Property)SyntaxElement.ETYPE.resource ).getLiteral().getString() ); } catch (URISyntaxException urisex) { //throw new AlignmentException( "Incorect URI for edoal:type : "+ ((Resource)node).getProperty( (Property)SyntaxElement.TYPE.resource ).getLiteral().getString() ); - urisex.printStackTrace(); + logger.debug( "IGNORED Exception", urisex ); } } if ( u != null ) { diff --git a/src/fr/inrialpes/exmo/align/parser/TypeCheckingVisitor.java b/src/fr/inrialpes/exmo/align/parser/TypeCheckingVisitor.java index 7b485fbd95ad74d5b49a1e3d8f6354dd68b44c57..3a416e5833f9e1f3150422edd80c59789405544f 100644 --- a/src/fr/inrialpes/exmo/align/parser/TypeCheckingVisitor.java +++ b/src/fr/inrialpes/exmo/align/parser/TypeCheckingVisitor.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2010-2012 + * Copyright (C) INRIA, 2010-2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -24,6 +24,9 @@ import java.util.Hashtable; import java.util.Properties; import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentVisitor; import org.semanticweb.owl.align.Cell; @@ -73,6 +76,7 @@ import fr.inrialpes.exmo.align.impl.edoal.Comparator; */ public class TypeCheckingVisitor { + final static Logger logger = LoggerFactory.getLogger( TypeCheckingVisitor.class ); public enum TYPE { CLASS, PROPERTY, RELATION, INSTANCE, VALUE, DATATYPE, ANY, ERROR }; @@ -352,7 +356,7 @@ public class TypeCheckingVisitor { public TYPE raiseError( final URI u, TYPE expT, TYPE foundT ) { error = true; - if ( print ) System.err.println( "Incorrectly typed expression "+u+": Type "+foundT+" ("+expT+" expected)"); + if ( print ) logger.error( "Incorrectly typed expression {}: Type {} ({} expected)", u, foundT, expT ); return TYPE.ERROR; } diff --git a/src/fr/inrialpes/exmo/align/parser/XMLParser.java b/src/fr/inrialpes/exmo/align/parser/XMLParser.java index 2c26e142b6604fc925950f8dc3bcfaf6923f3cb7..9d48978d69776505723ec2885c6414e3244f600e 100644 --- a/src/fr/inrialpes/exmo/align/parser/XMLParser.java +++ b/src/fr/inrialpes/exmo/align/parser/XMLParser.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2003-2005, 2007-2012 + * Copyright (C) INRIA, 2003-2005, 2007-2013 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -43,6 +43,9 @@ import java.lang.Integer; import java.lang.Double; import java.util.Hashtable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.Cell; import org.semanticweb.owl.align.AlignmentException; @@ -60,7 +63,7 @@ import fr.inrialpes.exmo.align.impl.Extensions; /** * This class allows the creation of a parser for an Alignment file. * The class is called by: - * AlignmentParser parser = new AlignmentParser( debugLevel ); + * AlignmentParser parser = new AlignmentParser(); * Alignment alignment = parser.parse( input ); * input can be a URI as a String, an InputStream * This new version (January 2004) parses the alignment description in @@ -69,12 +72,8 @@ import fr.inrialpes.exmo.align.impl.Extensions; */ public class XMLParser extends DefaultHandler { + final static Logger logger = LoggerFactory.getLogger( XMLParser.class ); - /** - * level of debug/warning information - */ - protected int debugMode = 0; - /** * a URI to a process */ @@ -171,22 +170,22 @@ public class XMLParser extends DefaultHandler { * Creates an XML Parser. */ public XMLParser() throws ParserConfigurationException, SAXException { - this(0); + this(false); } /** * Creates an XML Parser. - * @param debugMode The value of the debug mode + * @param validate 0 if non validating, more otherwise + * This should become a boolean */ - public XMLParser( int debugMode ) throws ParserConfigurationException, SAXException { - this.debugMode = debugMode; + public XMLParser( int validate ) throws ParserConfigurationException, SAXException { + this( (validate > 0) ); + } + + public XMLParser( boolean validate ) throws ParserConfigurationException, SAXException { SAXParserFactory parserFactory = SAXParserFactory.newInstance(); - if (debugMode > 0) { - parserFactory.setValidating(true); - } else { - parserFactory.setValidating(false); - } - parserFactory.setNamespaceAware(true); + parserFactory.setValidating( validate ); + parserFactory.setNamespaceAware( true ); parser = parserFactory.newSAXParser(); } @@ -264,7 +263,7 @@ public class XMLParser extends DefaultHandler { * @param atts The attributes name of the current element */ public void startElement(String namespaceURI, String pName, String qname, Attributes atts) throws SAXException { - if(debugMode > 2) System.err.println("startElement XMLParser : " + pName); + logger.debug( "startElement XMLParser : {}", pName ); parseLevel++; if( namespaceURI.equals( Namespace.ALIGNMENT.uri+"#" ) || namespaceURI.equals( Namespace.ALIGNMENT.uri ) ) { @@ -272,16 +271,14 @@ public class XMLParser extends DefaultHandler { } else if (pName.equals( SyntaxElement.SEMANTICS.name )) { } else if (pName.equals( SyntaxElement.MEASURE.name )) { } else if (pName.equals( SyntaxElement.ENTITY2.name )) { - if(debugMode > 2) - System.err.println(" resource = " + atts.getValue(SyntaxElement.RDF_RESOURCE.print())); + //logger.trace( " resource = {}", atts.getValue(SyntaxElement.RDF_RESOURCE.print()) ); try { cl2 = new URI( atts.getValue(SyntaxElement.RDF_RESOURCE.print()) ); } catch (URISyntaxException e) { throw new SAXException("Malformed URI: "+atts.getValue(SyntaxElement.RDF_RESOURCE.print())); } } else if (pName.equals( SyntaxElement.ENTITY1.name )) { - if(debugMode > 2) - System.err.println(" resource = " + atts.getValue(SyntaxElement.RDF_RESOURCE.print())); + //logger.trace(" resource = {}", atts.getValue(SyntaxElement.RDF_RESOURCE.print())); try { cl1 = new URI( atts.getValue( SyntaxElement.RDF_RESOURCE.print() ) ); } catch (URISyntaxException e) { @@ -347,7 +344,7 @@ public class XMLParser extends DefaultHandler { alignment.setExtension( Namespace.ALIGNMENT.uri, Annotations.ID, about ); }; } else { - if ( debugMode > 0 ) System.err.println("[XMLParser] Unknown element name : "+pName); + logger.warn( "Unknown element name : {}", pName ); }; } else if ( namespaceURI.equals( Namespace.SOAP_ENV.prefix )) { //"http://schemas.xmlsoap.org/soap/envelope/")) { // Ignore SOAP namespace @@ -373,8 +370,7 @@ public class XMLParser extends DefaultHandler { * Put the content in a variable public void characters(char ch[], int start, int length) { content = new String( ch, start, length ); - if(debugMode > 2) - System.err.println("content XMLParser : " + content); + //logger.trace( "content XMLParser : {}", content ); } */ @@ -393,7 +389,7 @@ public class XMLParser extends DefaultHandler { } else { content = newContent; } - if ( debugMode > 2 ) System.err.println("content XMLParser : " + content); + logger.debug( "content XMLParser : {}", content ); } /** @@ -404,8 +400,7 @@ public class XMLParser extends DefaultHandler { * @param qName The name of the current element */ public void endElement(String namespaceURI, String pName, String qName ) throws SAXException { - if(debugMode > 2) - System.err.println("endElement XMLParser : " + pName); + logger.debug( "endElement XMLParser : {}", pName ); if( namespaceURI.equals( Namespace.ALIGNMENT.uri+"#" ) || namespaceURI.equals( Namespace.ALIGNMENT.uri ) ) { try { @@ -418,17 +413,15 @@ public class XMLParser extends DefaultHandler { } else if (pName.equals( SyntaxElement.ENTITY2.name )) { } else if (pName.equals( SyntaxElement.ENTITY1.name )) { } else if (pName.equals( SyntaxElement.CELL.name )) { - if(debugMode > 1) { - System.err.print(" " + cl1); - System.err.print(" " + cl2); - System.err.print(" " + relation); - System.err.println(" " + Double.parseDouble(measure)); - } + //logger.trace( " {}", cl1 ); + //logger.trace( " {}", cl2 ); + //logger.trace( " {}", relation); + //logger.trace( " {}", Double.parseDouble(measure)); if ( cl1 == null || cl2 == null ) { // Maybe we could just print this out and fail in the end. //throw new SAXException( "Missing entity "+cl1+" "+cl2 ); // The cell is void - System.err.println("Warning (cell voided), missing entity "+cl1+" "+cl2 ); + logger.warn( "(cell voided), missing entity {} {}", cl1, cl2 ); } else if ( measure == null || relation == null ){ cell = alignment.addAlignCell( cl1, cl2); } else { @@ -497,8 +490,8 @@ public class XMLParser extends DefaultHandler { alignment.setExtension( namespaceURI, pName, content ); } else if ( parseLevel == 5 ) { extensions.setExtension( namespaceURI, pName, content ); - } else //if ( debugMode > 0 ) - System.err.println("[XMLParser("+parseLevel+")] Unknown element name : "+pName); + } else + logger.warn( "("+parseLevel+") Unknown element name : {}", pName ); //throw new SAXException("[XMLParser] Unknown element name : "+pName); }; } catch ( AlignmentException e ) { throw new SAXException("[XMLParser] Exception raised", e); }; diff --git a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java index ef6532ec83952d17aed9b2696588981a427d1259..6bfa373535f4fe36b082888153aee413a8f3fbb2 100644 --- a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java +++ b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java @@ -248,7 +248,7 @@ public class AServProtocolManager implements Service { Alignment al = null; try { //logger.trace(" Parsing alignment"); - AlignmentParser aparser = new AlignmentParser(0); + AlignmentParser aparser = new AlignmentParser(); al = aparser.parse( name ); //logger.trace(" Alignment parsed"); } catch (Exception e) { diff --git a/src/fr/inrialpes/exmo/align/service/AlignmentService.java b/src/fr/inrialpes/exmo/align/service/AlignmentService.java index 1e74ae1193cb60b50772a32cbd52bfe501d2084b..152b088e179bc5e1be90cc56d72d020b4d41ae59 100644 --- a/src/fr/inrialpes/exmo/align/service/AlignmentService.java +++ b/src/fr/inrialpes/exmo/align/service/AlignmentService.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2009, 2010, 2013 + * Copyright (C) INRIA, 2006-2009, 2010, 2013-2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -24,13 +24,15 @@ import fr.inrialpes.exmo.queryprocessor.QueryProcessor; import fr.inrialpes.exmo.queryprocessor.Result; import fr.inrialpes.exmo.queryprocessor.Type; -import fr.inrialpes.exmo.align.util.NullStream; +import fr.inrialpes.exmo.align.cli.CommonCLI; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import gnu.getopt.LongOpt; -import gnu.getopt.Getopt; +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.ParseException; import java.util.Hashtable; import java.util.Enumeration; @@ -62,12 +64,12 @@ $Id$ * @author Jérôme Euzenat */ -public class AlignmentService { +public class AlignmentService extends CommonCLI { final static Logger logger = LoggerFactory.getLogger( AlignmentService.class ); public String //DBMS Parameters DBHOST = "localhost", - DBPORT = "3306", + DBPORT = null, DBUSER = "adminAServ", DBPASS = "aaa345", DBBASE = "AServDB", @@ -91,22 +93,49 @@ public class AlignmentService { private AServProtocolManager manager; private DBService connection; + public AlignmentService() { + super(); + //options.addOption( OptionBuilder.withLongOpt( "load" ).hasArg().withDescription( "Load previous database image from FILE" ).withArgName("FILE").create( 'l' ) ); + options.addOption( OptionBuilder.withLongOpt( "impl" ).hasArg().withDescription( "Launch service corresponding to CLASS" ).withArgName("CLASS").create( 'i' ) ); + options.addOption( OptionBuilder.withLongOpt( "uriprefix" ).hasArg().withDescription( "Set alignment URIs with prefix URI" ).withArgName("URI").create( 'u' ) ); + options.addOption( OptionBuilder.withLongOpt( "host" ).hasArg().withDescription( "Set the HOSTNAME of the server" ).withArgName("HOSTNAME").create( 'S' ) ); + + options.addOption( OptionBuilder.withLongOpt( "http" ).hasOptionalArg().withDescription( "Launch HTTP service (with port PORT; default "+HTML+")" ).withArgName("PORT").create( 'H' ) ); + options.addOption( OptionBuilder.withLongOpt( "jade" ).hasOptionalArg().withDescription( "Launch JADE service (with port PORT; default "+JADE+")" ).withArgName("PORT").create( 'A' ) ); + options.addOption( OptionBuilder.withLongOpt( "wsdl" ).hasOptionalArg().withDescription( "Launch Web service (with port PORT; default "+WSDL+")" ).withArgName("PORT").create( 'W' ) ); + options.addOption( OptionBuilder.withLongOpt( "jxta" ).hasOptionalArg().withDescription( "Launch JXTA service (with port PORT; default "+JXTA+")" ).withArgName("PORT").create( 'X' ) ); + + options.addOption( "O", "oyster", false, "Register to Oyster directory" ); + //options.addOption( "U", "uddi", false, "Register to Oyster directory" ); + //options.addOption( OptionBuilder.withLongOpt( "params" ).hasArg().withDescription( "Read parameters from FILE" ).withArgName("FILE").create( 'p' ) ); + + options.addOption( OptionBuilder.withLongOpt( "dbms" ).hasArg().withDescription( "Use DBMS system (mysql,postgres; default: mysql)" ).withArgName("DBMS").create( 'B' ) ); + options.addOption( OptionBuilder.withLongOpt( "dbmshost" ).hasArg().withDescription( "Use DBMS HOST (default: "+DBHOST+")" ).withArgName("HOST").create( 'm' ) ); + options.addOption( OptionBuilder.withLongOpt( "dbmsport" ).hasArg().withDescription( "Use DBMS PORT (default: "+DBPORT+")" ).withArgName("PORT").create( 's' ) ); + options.addOption( OptionBuilder.withLongOpt( "dbmsuser" ).hasArg().withDescription( "Use DBMS USER (default: scott)" ).withArgName("USER").create( 'l' ) ); + options.addOption( OptionBuilder.withLongOpt( "dbmspass" ).hasArg().withDescription( "Use DBMS PASSword (default: tiger)" ).withArgName("PASS").create( 'p' ) ); + options.addOption( OptionBuilder.withLongOpt( "dbmsbase" ).hasArg().withDescription( "Use DBMS BASE (default: "+DBBASE+")" ).withArgName("BASE").create( 'b' ) ); + + } + public static void main(String[] args) { try { new AlignmentService().run( args ); } - catch ( Exception ex ) { - logger.error( "FATAL error", ex ); - }; + catch ( Exception ex ) { logger.error( "FATAL error", ex ); }; } public void run(String[] args) throws Exception { services = new Hashtable<String,AlignmentServiceProfile>(); directories = new Hashtable<String,Directory>(); + // Read parameters - Properties params = readParameters( args ); - if ( outfile != null ) { + readParameters( args ); + + // In principle, this is useless + if ( outputfilename != null ) { // This redirects error outout to log file given by -o - System.setErr( new PrintStream( outfile ) ); - } + System.setErr( new PrintStream( outputfilename ) ); + } + logger.debug("Parameter parsed"); // Shut down hook @@ -114,37 +143,49 @@ public class AlignmentService { public void run() { close(); } }); // Connect database - if( DBMS.equals("postgres") ) { + if ( DBMS.equals("postgres") ) { logger.debug("postgres driver"); - DBPORT = "5432"; - connection = new DBServiceImpl( "org.postgresql.Driver" , "jdbc:postgresql", DBPORT ); - } else { + if ( DBPORT == null ) DBPORT = "5432"; + connection = new DBServiceImpl( "org.postgresql.Driver", "jdbc:postgresql", DBPORT ); + } else if ( DBMS.equals("mysql") ) { logger.debug("mysql driver"); - DBPORT = "3306"; - connection = new DBServiceImpl( "com.mysql.jdbc.Driver" , "jdbc:mysql", DBPORT ); + if ( DBPORT == null ) DBPORT = "3306"; + connection = new DBServiceImpl( "com.mysql.jdbc.Driver", "jdbc:mysql", DBPORT ); + } else { + logger.error( "Unsupported JDBC driver: {}", DBMS ); + usage(); + System.exit(-1); } - - connection.init(); - connection.connect( DBHOST, DBPORT, DBUSER, DBPASS, DBBASE ); + try { + logger.debug("Connecting to database"); + connection.init(); + connection.connect( DBHOST, DBPORT, DBUSER, DBPASS, DBBASE ); + } catch ( Exception ex ) { + logger.error( ex.getMessage() ); + System.exit(-1); + } + logger.debug("Database connected"); // Create a AServProtocolManager manager = new AServProtocolManager( directories ); - manager.init( connection, params ); + manager.init( connection, parameters ); logger.debug("Manager created"); // Launch services for ( AlignmentServiceProfile serv : services.values() ) { try { - serv.init( params, manager ); + serv.init( parameters, manager ); } catch ( AServException ex ) { // This should rather be the job of the caller - logger.warn( "Cannot start {} server on {}:{}", serv, params.getProperty( "host" ), params.getProperty( "http" ) ); + logger.warn( "Cannot start {} server on {}:{}", serv, parameters.getProperty( "host" ), parameters.getProperty( "http" ) ); } } + logger.debug("Services launched"); + // Register to directories for ( Directory dir : directories.values() ) { try { - dir.open( params ); + dir.open( parameters ); logger.debug("{} connected.", dir); } catch ( AServException ex ) { logger.warn( "Cannot connect to {} directory", dir ); @@ -153,8 +194,10 @@ public class AlignmentService { //directories.remove( name, dir ); } } + logger.debug("Directories registered"); // Wait loop + logger.info("Alignment server running"); while ( true ) { // do not exhaust CPU Thread.sleep(1000); @@ -181,9 +224,11 @@ public class AlignmentService { } // Shut down database connection - manager.close(); + logger.debug("Stopping manager"); + if ( manager != null ) manager.close(); + logger.debug("Closing database connection"); connection.close(); - logger.debug("Database connection closed"); + logger.info("Alignment server stopped"); System.err.close(); } @@ -192,246 +237,95 @@ public class AlignmentService { finally { super.finalize(); } } - protected Object loadInstance( String className) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { + protected Object loadInstance( String className ) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { Class<?> cl = Class.forName(className); java.lang.reflect.Constructor constructor = cl.getConstructor( (Class[])null ); return constructor.newInstance( (Object[])null ); } + public void readParameters( String[] args ) { + try { + CommandLine line = parseCommandLine( args ); + if ( line == null ) System.exit(1); // -help - public Properties readParameters( String[] args ) { - Properties params = new Properties(); - // Default values - params.setProperty( "host", HOST ); - - // Read parameters + // Default values + parameters.setProperty( "host", HOST ); - LongOpt[] longopts = new LongOpt[20]; - // General parameters - longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); - longopts[1] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'); - longopts[2] = new LongOpt("debug", LongOpt.OPTIONAL_ARGUMENT, null, 'd'); - longopts[3] = new LongOpt("impl", LongOpt.REQUIRED_ARGUMENT, null, 'l'); - // Is there a way for that in LongOpt ??? - longopts[4] = new LongOpt("D", LongOpt.REQUIRED_ARGUMENT, null, 'D'); - // Service parameters - longopts[5] = new LongOpt("html", LongOpt.OPTIONAL_ARGUMENT, null, 'H'); - longopts[6] = new LongOpt("jade", LongOpt.OPTIONAL_ARGUMENT, null, 'A'); - longopts[7] = new LongOpt("wsdl", LongOpt.OPTIONAL_ARGUMENT, null, 'W'); - longopts[8] = new LongOpt("jxta", LongOpt.OPTIONAL_ARGUMENT, null, 'P'); - longopts[9] = new LongOpt("oyster", LongOpt.OPTIONAL_ARGUMENT, null, 'O'); - longopts[10] = new LongOpt("uddi", LongOpt.OPTIONAL_ARGUMENT, null, 'U'); - // DBMS Server parameters - longopts[11] = new LongOpt("dbmshost", LongOpt.REQUIRED_ARGUMENT, null, 'm'); - longopts[12] = new LongOpt("dbmsport", LongOpt.REQUIRED_ARGUMENT, null, 's'); - longopts[13] = new LongOpt("dbmsuser", LongOpt.REQUIRED_ARGUMENT, null, 'u'); - longopts[14] = new LongOpt("dbmspass", LongOpt.REQUIRED_ARGUMENT, null, 'p'); - longopts[15] = new LongOpt("dbmsbase", LongOpt.REQUIRED_ARGUMENT, null, 'b'); - longopts[16] = new LongOpt("dbms", LongOpt.REQUIRED_ARGUMENT, null, 'B'); - longopts[17] = new LongOpt("host", LongOpt.REQUIRED_ARGUMENT, null, 'S'); - longopts[18] = new LongOpt("serv", LongOpt.REQUIRED_ARGUMENT, null, 'i'); - longopts[19] = new LongOpt("uriprefix", LongOpt.REQUIRED_ARGUMENT, null, 'f'); - - Getopt g = new Getopt("", args, "ho:S:l:f:d::D:H::A::W::P::O::U::m:s:u:p:b:B:i:", longopts); - int c; - String arg; - - while ((c = g.getopt()) != -1) { - switch (c) { - case 'h' : - usage(); - System.exit(0); - break; - case 'o' : - /* Use filename instead of stdout */ - outfile = g.getOptarg(); - break; - case 'l' : - /* Use the given file as a database image to load */ - filename = g.getOptarg(); - break; - case 'd' : - /* DEPRECATED: Debug level */ - arg = g.getOptarg(); - System.err.println( "WARNING: debug argument is deprecated, use logging" ); - System.err.println( "See http://alignapi.gforge.inria.fr/logging.html" ); - break; - case 'i' : - /* external service */ - arg = g.getOptarg(); + // Here deal with command specific arguments + + /* Use the given file as a database image to load */ + //if ( line.hasOption( 'l' ) ) filename = line.getOptionValue( 'l' ); + if ( line.hasOption( 'i' ) ) { /* external service */ + String arg = line.getOptionValue( 'i' ); try { services.put( arg, (AlignmentServiceProfile)loadInstance( arg ) ); } catch (Exception ex) { logger.warn( "Cannot create service for {}", arg ); - logger.trace( "IGNORED Exception", ex ); - } - break; - case 'f' : - /* Parameter definition */ - params.setProperty( "prefix", g.getOptarg() ); - break; - case 'H' : - /* HTTP Server + port */ - arg = g.getOptarg(); - if ( arg != null ) { - params.setProperty( "http", arg ); - } else { - params.setProperty( "http", HTML ); + logger.debug( "IGNORED Exception", ex ); } + } + if ( line.hasOption( 'u' ) ) parameters.setProperty( "prefix", line.getOptionValue( 'u' ) ); + if ( line.hasOption( 'H' ) ) { + parameters.setProperty( "http", line.getOptionValue( 'H', HTML ) ); // This shows that it does not work try { services.put( "fr.inrialpes.exmo.align.service.HTMLAServProfile", (AlignmentServiceProfile)loadInstance( "fr.inrialpes.exmo.align.service.HTMLAServProfile" ) ); } catch (Exception ex) { logger.warn( "Cannot create service for HTMLAServProfile", ex ); } - break; - case 'A' : - /* JADE Server + port */ - arg = g.getOptarg(); - if ( arg != null ) { - params.setProperty( "jade", arg ); - } else { - params.setProperty( "jade", JADE ); - } + } + if ( line.hasOption( 'A' ) ) { + parameters.setProperty( "jade", line.getOptionValue( 'A', JADE ) ); try { services.put( "fr.inrialpes.exmo.align.service.jade.JadeFIPAAServProfile", (AlignmentServiceProfile)loadInstance( "fr.inrialpes.exmo.align.service.jade.JadeFIPAAServProfile" ) ); - } catch (Exception ex) { + } catch ( Exception ex ) { logger.warn("Cannot create service for JadeFIPAAServProfile", ex); } - break; - case 'W' : - /* Web service + port */ - arg = g.getOptarg(); - if ( arg != null ) { - params.setProperty( "wsdl", arg ); - } else { - params.setProperty( "wsdl", WSDL ); - }; + } + if ( line.hasOption( 'W' ) ) { + parameters.setProperty( "wsdl", line.getOptionValue( 'W', WSDL ) ); // The WSDL extension requires HTTP server (and the same one). // Put the default port, may be overriden - if ( params.getProperty( "http" ) == null ) - params.setProperty( "http", HTML ); + if ( parameters.getProperty( "http" ) == null ) + parameters.setProperty( "http", HTML ); try { services.put( "fr.inrialpes.exmo.align.service.HTMLAServProfile", (AlignmentServiceProfile)loadInstance( "fr.inrialpes.exmo.align.service.HTMLAServProfile" ) ); - } catch (Exception ex) { - logger.warn("Cannot create service for Web services", ex); - } - break; - case 'P' : - /* JXTA Server + port */ - arg = g.getOptarg(); - if ( arg != null ) { - params.setProperty( "jxta", arg ); - } else { - params.setProperty( "jxta", JXTA ); - } - break; - case 'S' : - /* Server */ - params.setProperty( "host", g.getOptarg() ); - break; - case 'O' : - /* [JE: Currently not working]: Oyster directory + port */ - arg = g.getOptarg(); - if ( arg != null ) { - params.setProperty( "oyster", arg ); - } else { - params.setProperty( "oyster", JADE ); + } catch ( Exception ex ) { + logger.warn( "Cannot create service for Web services", ex ); } + } + if ( line.hasOption( 'X' ) ) { parameters.setProperty( "jxta", line.getOptionValue( 'P', JXTA ) ); } + if ( line.hasOption( 'S' ) ) { parameters.setProperty( "host", line.getOptionValue( 'S' ) ); } + if ( line.hasOption( 'O' ) ) { try { directories.put( "fr.inrialpes.exmo.align.service.OysterDirectory", (Directory)loadInstance( "fr.inrialpes.exmo.align.service.OysterDirectory" ) ); } catch (Exception ex) { - logger.warn("Cannot create directory for Oyster", ex); + logger.warn( "Cannot create directory for Oyster", ex ); } - break; - case 'U' : - /* [JE: Currently not working]: UDDI directory + port */ - arg = g.getOptarg(); - if ( arg != null ) { - params.setProperty( "uddi", arg ); - } else { - params.setProperty( "uddi", JADE ); - } + } + /*if ( line.hasOption( 'U' ) ) { try { directories.put( "fr.inrialpes.exmo.align.service.UDDIDirectory", (Directory)loadInstance( "fr.inrialpes.exmo.align.service.UDDIDirectory" ) ); } catch (Exception ex) { logger.warn("Cannot create directory for UDDI", ex); } - break; - case 'm' : - DBHOST = g.getOptarg(); - break; - case 's' : - DBPORT = g.getOptarg(); - break; - case 'u' : - DBUSER = g.getOptarg(); - break; - case 'p' : - DBPASS = g.getOptarg(); - break; - case 'b' : - DBBASE = g.getOptarg(); - break; - case 'B' : - arg = g.getOptarg(); - if ( arg != null ) { - params.setProperty( "DBMS", arg ); - DBMS = arg; - } else { - params.setProperty( "DBMS", "mysql" ); - DBMS = "mysql"; - } - break; - case 'D' : - /* Parameter definition */ - arg = g.getOptarg(); - int index = arg.indexOf('='); - if ( index != -1 ) { - params.setProperty( arg.substring( 0, index), - arg.substring(index+1)); - } else { - logger.warn("Bad parameter syntax: "+g); - usage(); - System.exit(0); - - } - break; - } + }*/ + if ( line.hasOption( 'm' ) ) { DBHOST = line.getOptionValue( 'm' ); } + if ( line.hasOption( 's' ) ) { DBPORT = line.getOptionValue( 's' ); } + if ( line.hasOption( 'l' ) ) { DBUSER = line.getOptionValue( 'l' ); } + if ( line.hasOption( 'p' ) ) { DBPASS = line.getOptionValue( 'p' ); } + if ( line.hasOption( 'b' ) ) { DBBASE = line.getOptionValue( 'b' ); } + if ( line.hasOption( 'B' ) ) { DBMS = line.getOptionValue( 'B' ); } + parameters.setProperty( "DBMS", DBMS ); + } catch( ParseException exp ) { + logger.error( exp.getMessage() ); + usage(); + System.exit(-1); } - - return params; } - // Really missing: - // OUTPUT(o): what for, there is no output (maybe LOGS) - // LOAD(l): good idea, load from file, but what kind? sql? - // PARAMS(p is taken, P is taken): yes good as well to read parameters from file public void usage() { - System.err.println("usage: AlignmentService [options]"); - System.err.println("options are:"); - //System.err.println("\t--load=filename -l filename\t\tInitialize the Service with the content of this "); - System.err.println("\t--html[=port] -H[port]\t\t\tLaunch HTTP service"); - System.err.println("\t--jade[=port] -A[port]\t\t\tLaunch Agent service"); - System.err.println("\t--wsdl[=port] -W[port]\t\t\tLaunch Web service"); - System.err.println("\t--jxta[=port] -P[port]\t\t\tLaunch P2P service"); - System.err.println("\t--oyster -O\t\t\tRegister to Oyster directory"); - //System.err.println("\t--uddi -U\t\t\tRegister to Oyster directory"); - System.err.println("\t--serv=class -i class\t\t\tLaunch service corresponding to fully qualified classname"); - //System.err.println("\t--params=filename -p filename\tReads parameters from filename"); - System.err.println("\t--output=filename -o filename\tRedirect output to filename"); - System.err.println("\t--dbmshost=host -m host\t\t\tUse DBMS host"); - System.err.println("\t--dbmsport=port -s port\t\t\tUse DBMS port"); - System.err.println("\t--dbmsuser=name -u name\t\t\tUse DBMS user name"); - System.err.println("\t--dbmspass=pwd -p pwd\t\t\tUse DBMS password"); - System.err.println("\t--dbmsbase=name -b name\t\t\tUse Database name"); - System.err.println("\t--dbms=name -B name\t\t\tUse Database Management System"); - System.err.println("\t--uriprefix=uri -f uri\t\t\tSet alignment URIs with this prefix"); - System.err.println("\t-Dparam=value\t\t\tSet parameter"); - System.err.println("\t--help -h\t\t\tPrint this message"); - - System.err.print("\n"+AlignmentService.class.getPackage().getImplementationTitle()+" "+AlignmentService.class.getPackage().getImplementationVersion()); - System.err.println(" ($Id$)\n"); + usage( "java "+this.getClass().getName()+" [options]\nLaunch an Alignment server" ); } } diff --git a/src/fr/inrialpes/exmo/align/service/DBServiceImpl.java b/src/fr/inrialpes/exmo/align/service/DBServiceImpl.java index e411db08b1ae812f82e3fbadfef1ee76d52bc950..08920dad88c4fcb758df369cb98ec5af4968a968 100644 --- a/src/fr/inrialpes/exmo/align/service/DBServiceImpl.java +++ b/src/fr/inrialpes/exmo/align/service/DBServiceImpl.java @@ -2,7 +2,7 @@ * $Id$ * * Copyright (C) Seungkeun Lee, 2006 - * Copyright (C) INRIA, 2007-2009, 2013 + * Copyright (C) INRIA, 2007-2009, 2013-2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -81,7 +81,8 @@ public class DBServiceImpl implements DBService { public void connect(String IPAddress, String port, String user, String password, String database ) throws SQLException { dbpass = password; conn = DriverManager.getConnection(driverPrefix+"://"+IPAddress+":"+port+"/"+database, user, password); - } + } + //with "dbpass" given by "connect" public Connection reconnect() throws SQLException { conn = DriverManager.getConnection(driverPrefix+"://"+IPAddress+":"+port+"/"+database, user, dbpass); @@ -96,7 +97,7 @@ public class DBServiceImpl implements DBService { public void close() { try { - conn.close(); + if ( conn != null ) conn.close(); } catch (Exception ex) { logger.debug( "IGNORED Closing exception", ex ); } diff --git a/src/fr/inrialpes/exmo/align/service/QueryMediator.java b/src/fr/inrialpes/exmo/align/service/QueryMediator.java index c4fc23d7fe1ad1ba88e50fc6248103e73380e5ee..8fedb1c89a20ac84b12f1d19499ae3d555e03c9c 100644 --- a/src/fr/inrialpes/exmo/align/service/QueryMediator.java +++ b/src/fr/inrialpes/exmo/align/service/QueryMediator.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2009 + * Copyright (C) INRIA, 2006-2009, 2013 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -76,7 +76,7 @@ public class QueryMediator implements QueryProcessor { public QueryMediator( QueryProcessor proc, String alignmentURI ) throws SAXException,ParserConfigurationException,IOException { processor = proc; - AlignmentParser aparser = new AlignmentParser(0); + AlignmentParser aparser = new AlignmentParser(); try { alignment = aparser.parse( alignmentURI ); } catch ( Exception ex ) { throw new ParserConfigurationException("Error on parsing"); diff --git a/src/fr/inrialpes/exmo/align/service/WSAlignment.java b/src/fr/inrialpes/exmo/align/service/WSAlignment.java index 7b891101de8ff76f837471c9d6eab9f0a18e9aaf..0d3c94cad11eb7cda9fe6285cae0b143535545e5 100644 --- a/src/fr/inrialpes/exmo/align/service/WSAlignment.java +++ b/src/fr/inrialpes/exmo/align/service/WSAlignment.java @@ -177,7 +177,7 @@ public class WSAlignment extends URIAlignment implements AlignmentProcess { //} - AlignmentParser parser = new AlignmentParser( 0 ); + AlignmentParser parser = new AlignmentParser(); parser.initAlignment( this ); parser.setEmbedded( true ); parser.parse( httpConn.getInputStream() ); diff --git a/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServProfile.java b/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServProfile.java index 9432c97a8abd7d12e4b95ce63662e790d90809f2..ba25babfc9fd4a636579db1db983b8fbad96dc9e 100755 --- a/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServProfile.java +++ b/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServProfile.java @@ -2,7 +2,7 @@ * $Id$ * * Copyright (C) Orange R&D, 2006-2007 - * Copyright (C) INRIA, 2006-2007, 2009-2010 + * Copyright (C) INRIA, 2006-2007, 2009-2010, 2013 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -24,7 +24,6 @@ package fr.inrialpes.exmo.align.service.jade; import jade.core.Profile; import jade.core.ProfileImpl; import jade.core.Runtime; -import jade.util.Logger; import jade.wrapper.AgentContainer; import jade.wrapper.AgentController; import jade.wrapper.ControllerException; @@ -36,16 +35,17 @@ import fr.inrialpes.exmo.align.service.AlignmentServiceProfile; import java.io.File; import java.util.Properties; -public class JadeFIPAAServProfile implements AlignmentServiceProfile { +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +public class JadeFIPAAServProfile implements AlignmentServiceProfile { + final static Logger logger = LoggerFactory.getLogger( JadeFIPAAServProfile.class ); private AgentContainer mc; private AgentController algagentcontroller; - private Logger myLogger = Logger.getMyLogger(getClass().getName()); public void init( Properties params, AServProtocolManager manager ) throws AServException { int port = 8888; - int debug = 0; Object args[] = new Object[2]; //set up the manager as an argument to pass to the JADEFIPAAServiceAgent @@ -56,8 +56,6 @@ public class JadeFIPAAServProfile implements AlignmentServiceProfile { if ( params.getProperty( "jade" ) != null ) port = Integer.parseInt( params.getProperty( "jade" ) ); - if ( params.getProperty( "debug" ) != null ) - debug = Integer.parseInt( params.getProperty( "debug" ) ) - 1; /** Properties props = new Properties(); @@ -76,8 +74,7 @@ public class JadeFIPAAServProfile implements AlignmentServiceProfile { // create a default Profile Profile pMain = new ProfileImpl(null, port, null); - if ( debug > 0 ) - System.out.println("Launching a whole in-process platform..."+pMain); + //logger.trace( "Launching a whole in-process platform... {}", pMain ); mc = rt.createMainContainer(pMain); algagentcontroller = mc.createNewAgent("JadeFIPAAServiceAgent", JadeFIPAAServiceAgent.class.getName(), args); algagentcontroller.start(); @@ -91,15 +88,15 @@ public class JadeFIPAAServProfile implements AlignmentServiceProfile { try{ algagentcontroller.kill(); mc.kill(); - myLogger.log(Logger.INFO, "Agent Alignement close"); + logger.info( "Agent Alignement closed" ); } catch (ControllerException e) { - myLogger.log(Logger.WARNING, "Error killing the alignment agent."); } + logger.warn( "Error killing the alignment agent." ); } try { // Destroy the files please (JE) new File("APDescription.txt").delete(); new File("MTPs-Main-Container.txt").delete(); } catch (Exception e) { - e.printStackTrace(); + logger.debug( "IGNORED Exception", e ); } } diff --git a/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java b/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java index 1fc9677c006730a01b6ad3494e2a5161468ca647..3f67c5ae630c03bc87cae08fe8e3dd5b5433b834 100755 --- a/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java +++ b/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java @@ -2,7 +2,7 @@ * $Id$ * * Copyright (C) Orange R&D, 2006 - * Copyright (C) INRIA, 2006, 2008-2009, 2011-2012 + * Copyright (C) INRIA, 2006, 2008-2009, 2011-2013 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -19,12 +19,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - package fr.inrialpes.exmo.align.service.jade; import java.util.Iterator; import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import jade.content.ContentElement; import jade.content.ContentManager; import jade.content.Predicate; @@ -40,7 +42,6 @@ import jade.domain.FIPAAgentManagement.DFAgentDescription; import jade.domain.FIPAAgentManagement.ServiceDescription; import jade.lang.acl.ACLMessage; import jade.lang.acl.MessageTemplate; -import jade.util.Logger; import fr.inrialpes.exmo.align.service.AServProtocolManager; import fr.inrialpes.exmo.align.service.msg.Message; @@ -58,12 +59,12 @@ import fr.inrialpes.exmo.align.service.jade.messageontology.STORE; import fr.inrialpes.exmo.align.service.jade.messageontology.TRANSLATE; public class JadeFIPAAServiceAgent extends Agent { + final static Logger logger = LoggerFactory.getLogger( JadeFIPAAServiceAgent.class ); private static final long serialVersionUID = 330; public static final String SERVICE_NAME = "Alignment"; public static final String SERVICE_TYPE = "Alignment-service"; - private Logger myLogger = Logger.getMyLogger(getClass().getName()); private String myId; private String serverId; private AServProtocolManager manager; @@ -78,24 +79,24 @@ public class JadeFIPAAServiceAgent extends Agent { protected void setup() { - //myLogger.log(Logger.INFO, getAID().getName()+" started"); - super.setup(); - codec = new SLCodec(); - - // ontology = ContextAgentManagerOntology.getInstance(); - CTmanager = this.getContentManager(); + logger.info( "{} started", getAID().getName() ); + super.setup(); + codec = new SLCodec(); - //System.out.println("agent" + getAID() + " "+ getLocalName()+" is created"); + // ontology = ContextAgentManagerOntology.getInstance(); + CTmanager = this.getContentManager(); + + // logger.trace("agent {} {} is created", getAID(), getLocalName() ); - CTmanager.registerOntology(ontology); - CTmanager.registerLanguage(codec); + CTmanager.registerOntology(ontology); + CTmanager.registerLanguage(codec); // Read arguments Object[] args = getArguments(); if (args != null) { /**for (int i = 0; i < args.length; ++i) { - myLogger.log(Logger.INFO, "Arg-"+i+" = "+args[i]); + logger.debug( "Arg-{} = {}", i, args[i] ); }**/ manager=(AServProtocolManager) args[0]; @@ -123,7 +124,7 @@ public class JadeFIPAAServiceAgent extends Agent { ACLMessage msg = myAgent.receive(tpl); if (msg != null) { // --------------------------------------------------------- - //myLogger.log(Logger.INFO, "Received message: "+msg.toString()); + //logger.debug( "Received message: {}", msg.toString() ); try{ ContentElement ce = null; @@ -141,7 +142,9 @@ public class JadeFIPAAServiceAgent extends Agent { ((Action)ce).setResult(answer.getContent()); CTmanager.fillContent(JADEanswer, ce); myAgent.send(JADEanswer); - }else{myLogger.log(Logger.WARNING, answer.getContent());} + }else{ + logger.warn( answer.getContent() ); + } }else if (ce instanceof LOAD){ Message answer = manager.load(new Message(newId(), (Message)null,myId,serverId,"",params)); if(!(answer instanceof ErrorMsg)){ @@ -153,7 +156,9 @@ public class JadeFIPAAServiceAgent extends Agent { CTmanager.fillContent(JADEanswer, ce); //JADEanswer.setContent(answer.getContent()); myAgent.send(JADEanswer); - }else{myLogger.log(Logger.WARNING, answer.getContent());} + }else{ + logger.warn( answer.getContent() ); + } }else if (ce instanceof RETRIEVE){ Message answer = manager.render(new Message(newId(), (Message)null,myId,serverId,"",params)); if(!(answer instanceof ErrorMsg)){ @@ -165,7 +170,9 @@ public class JadeFIPAAServiceAgent extends Agent { ((Action)ce).setResult(answer.getContent()); CTmanager.fillContent(JADEanswer, ce); myAgent.send(JADEanswer); - }else{myLogger.log(Logger.WARNING, answer.getContent());} + }else{ + logger.warn( answer.getContent() ); + } }else if (ce instanceof TRANSLATE){ //TODO }else if (ce instanceof METADATA){ @@ -181,7 +188,9 @@ public class JadeFIPAAServiceAgent extends Agent { ((Action)ce).setResult(answer.getContent()); CTmanager.fillContent(JADEanswer, ce); myAgent.send(JADEanswer); - }else{myLogger.log(Logger.WARNING, answer.getContent());} + }else{ + logger.warn( answer.getContent() ); + } }else if (ce instanceof FIND){ Message answer = manager.existingAlignments(new Message(newId(), (Message)null,myId,serverId,"",params)); if(!(answer instanceof ErrorMsg)){ @@ -193,7 +202,9 @@ public class JadeFIPAAServiceAgent extends Agent { ((Action)ce).setResult(answer.getContent()); CTmanager.fillContent(JADEanswer, ce); myAgent.send(JADEanswer); - }else{myLogger.log(Logger.WARNING, answer.getContent());} + }else{ + logger.warn( answer.getContent() ); + } }else if (ce instanceof CUT){ Message answer = manager.trim(new Message(newId(), (Message)null,myId,serverId,"",params)); if(!(answer instanceof ErrorMsg)){ @@ -205,7 +216,9 @@ public class JadeFIPAAServiceAgent extends Agent { ((Action)ce).setResult(answer.getContent()); CTmanager.fillContent(JADEanswer, ce); myAgent.send(JADEanswer); - }else{myLogger.log(Logger.WARNING, answer.getContent());} + }else{ + logger.warn( answer.getContent() ); + } }else { ACLMessage JADEanswer=msg.createReply(); JADEanswer.setLanguage(codec.getName()); @@ -213,10 +226,11 @@ public class JadeFIPAAServiceAgent extends Agent { JADEanswer.setPerformative(ACLMessage.NOT_UNDERSTOOD); myAgent.send(JADEanswer); } + } catch( CodecException ce ) { + logger.debug( "IGNORED Exception", ce ); + } catch( OntologyException oe ) { + logger.debug( "IGNORED Exception", oe ); } - - catch(CodecException ce){ce.printStackTrace();} - catch(OntologyException oe){oe.printStackTrace();} }else { block(); } @@ -231,9 +245,8 @@ public class JadeFIPAAServiceAgent extends Agent { }//end of Setup protected void takeDown() { - - myLogger.log(Logger.INFO, "Agent Alignement Service close"); - this.doDelete(); + logger.info( "Agent Alignement Service closed" ); + this.doDelete(); } private void registerWithDF() { @@ -244,12 +257,12 @@ public class JadeFIPAAServiceAgent extends Agent { sd.setType(SERVICE_TYPE); dfd.addServices(sd); try { - //myLogger.log(Logger.INFO, "Registering with DF..."); - DFService.register(this, dfd); - //myLogger.log(Logger.INFO, "Registration OK."); + logger.debug( "Registering with DF..." ); + DFService.register(this, dfd); + logger.debug( "Registration OK." ); } - catch (FIPAException fe) { - myLogger.log(Logger.WARNING, "Error registering with DF.", fe); + catch ( FIPAException fex ) { + logger.warn( "Error registering with DF", fex ); } } diff --git a/src/fr/inrialpes/exmo/align/service/jade/messageontology/JADEFIPAAlignmentServerOntology.java b/src/fr/inrialpes/exmo/align/service/jade/messageontology/JADEFIPAAlignmentServerOntology.java index fd30792541dbaf7dc11b0a6edd3c5cbef416a209..fcb4c9059d284e4052f088e3675ae3f5d2115a71 100644 --- a/src/fr/inrialpes/exmo/align/service/jade/messageontology/JADEFIPAAlignmentServerOntology.java +++ b/src/fr/inrialpes/exmo/align/service/jade/messageontology/JADEFIPAAlignmentServerOntology.java @@ -1,5 +1,29 @@ -// file: JADEFIPAAlignmentServerOntologyOntology.java generated by ontology bean generator. DO NOT EDIT, UNLESS YOU ARE REALLY SURE WHAT YOU ARE DOING! +/* + * $Id$ + * + * Copyright (C) INRIA, 2007, 2013 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +// file: JADEFIPAAlignmentServerOntologyOntology.java generated by ontology bean generator. DO NOT EDIT, UNLESS YOU ARE REALLY SURE WHAT YOU ARE DOING! + package fr.inrialpes.exmo.align.service.jade.messageontology; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import jade.content.onto.*; import jade.content.schema.*; @@ -12,6 +36,7 @@ import jade.core.CaseInsensitiveString; * @version 2007/03/19, 17:12:29 */ public class JADEFIPAAlignmentServerOntology extends jade.content.onto.Ontology { + final static Logger logger = LoggerFactory.getLogger( JADEFIPAAlignmentServerOntology.class ); //NAME private static final long serialVersionUID = 330; public static final String ONTOLOGY_NAME = "JADEFIPAAlignmentServerOntology"; @@ -102,6 +127,7 @@ public class JADEFIPAAlignmentServerOntology extends jade.content.onto.Ontology - }catch (java.lang.Exception e) {e.printStackTrace();} + }catch (java.lang.Exception e) { + logger.debug( "IGNORED Exception", e );} } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/AlignmentIds.java b/src/fr/inrialpes/exmo/align/service/msg/AlignmentIds.java index 147d0b77380e77c6c54868809d6b751e71844c31..cdde5684b0282a0af19109cb64810215866f3df7 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/AlignmentIds.java +++ b/src/fr/inrialpes/exmo/align/service/msg/AlignmentIds.java @@ -22,11 +22,15 @@ package fr.inrialpes.exmo.align.service.msg; import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Contains the messages that should be sent according to the protocol */ public class AlignmentIds extends Success { + final static Logger logger = LoggerFactory.getLogger( AlignmentIds.class ); String pretty = null; @@ -45,8 +49,8 @@ public class AlignmentIds extends Success { if ( id.length >= 1 ) { result = "Alignment Ids: <ul>"; for ( int i = id.length-1; i >= 0; i-- ){ - //System.err.println("id["+i+"]"+id[i]); - //result += "<li><a href=\"../html/retrieve?method=fr.inrialpes.exmo.align.impl.renderer.HTMLRendererVisitor&id="+id[i]+"\">"; + // logger.trace("id[{}]{}", i, id[i] ); + // result += "<li><a href=\"../html/retrieve?method=fr.inrialpes.exmo.align.impl.renderer.HTMLRendererVisitor&id="+id[i]+"\">"; result += "<li><a href=\""+id[i]+"\">"; result += id[i]; String pp = null; @@ -56,7 +60,7 @@ public class AlignmentIds extends Success { if (pp != null && !pp.equals("") && !pp.equals("null")) { result += " ("+pp+")"; } - //System.err.println("pid["+i+"]="+pp); + // logger.trace( "pid[{}]={}", i, pp ); } catch(Exception ex) { } } diff --git a/src/fr/inrialpes/exmo/ontowrap/OntologyCache.java b/src/fr/inrialpes/exmo/ontowrap/OntologyCache.java index 0c4c9b4dd52d3e48603881fcf300654dab135a63..6770f2148fa74ab451f36d4f03e1f2ff2a652f62 100644 --- a/src/fr/inrialpes/exmo/ontowrap/OntologyCache.java +++ b/src/fr/inrialpes/exmo/ontowrap/OntologyCache.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2007-2008, 2010 + * Copyright (C) INRIA, 2007-2008, 2010, 2013 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -21,11 +21,13 @@ package fr.inrialpes.exmo.ontowrap; -// import java classes import java.util.Hashtable; import java.util.Enumeration; import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * This caches the loaded ontologies so that it is possible * to share them between alignments @@ -38,7 +40,8 @@ import java.net.URI; */ public class OntologyCache <O extends LoadedOntology> { - + final static Logger logger = LoggerFactory.getLogger( OntologyCache.class ); + /** The list of currently loaded ontologies as a function: * URI --> Ontology * This is the ontology URI, NOT its filename @@ -73,15 +76,15 @@ public class OntologyCache <O extends LoadedOntology> { /* debugging utility */ public void displayCache(){ - System.err.println("CACHE: "+ontologies.size()+"/"+ontologyUris.size()+" elements cached"); + logger.trace( "CACHE: {}/{} elements cached", ontologies.size(), ontologyUris.size() ); // No way to make this iterable?? //for ( URI u : ontologies.keys() ){ for( Enumeration<URI> e = ontologies.keys(); e.hasMoreElements(); ){ - URI u = e.nextElement(); + URI u = e.nextElement(); LoadedOntology o = ontologies.get( u ); - System.err.println( " "+u ); - System.err.println( " "+o.getURI() ); - System.err.println( " --> "+o+" ("+o.getOntology()+")" ); + logger.trace( " {}", u ); + logger.trace( " {}", o.getURI() ); + logger.trace( " --> {} ({})", o, o.getOntology() ); } }; diff --git a/src/fr/inrialpes/exmo/ontowrap/OntologyFactory.java b/src/fr/inrialpes/exmo/ontowrap/OntologyFactory.java index 4c39e881d378658376955231ed7929d89d5c7220..e7a60e78c87c646382a6e32cdb772ed2505a4e2d 100644 --- a/src/fr/inrialpes/exmo/ontowrap/OntologyFactory.java +++ b/src/fr/inrialpes/exmo/ontowrap/OntologyFactory.java @@ -168,11 +168,11 @@ public abstract class OntologyFactory { */ public LoadedOntology loadOntology( Ontology onto ) throws OntowrapException { // logger.trace( "loading Ontology: {}", onto ); - try { // Try with URI - return loadOntology( onto.getURI() ); + try { // Try with file + return loadOntology( onto.getFile() ); } catch ( Exception ex ) { - try { // Try with file - return loadOntology( onto.getFile() ); + try { // Try with URI + return loadOntology( onto.getURI() ); } catch ( Exception ex2 ) { throw new OntowrapException( "Cannot load ontology "+onto ); } diff --git a/src/fr/inrialpes/exmo/ontowrap/jena25/JENAOntology.java b/src/fr/inrialpes/exmo/ontowrap/jena25/JENAOntology.java index f7bec973b11e4f3cd54b5f17bb0d71efa2240c87..7595929cabedaaf7da3bc0b0f38f9acdf8f6d18c 100644 --- a/src/fr/inrialpes/exmo/ontowrap/jena25/JENAOntology.java +++ b/src/fr/inrialpes/exmo/ontowrap/jena25/JENAOntology.java @@ -55,11 +55,11 @@ import fr.inrialpes.exmo.ontowrap.util.EntityFilter; public class JENAOntology extends BasicOntology<OntModel> implements HeavyLoadedOntology<OntModel>{ - private boolean onlyLocalEntities=true; + private boolean onlyLocalEntities = true; // JE: this is not very Java 1.5... // This is because of the version of Jena we use apparently - + public JENAOntology() {} // default is true public JENAOntology(boolean onlyLocalEntities) { this.onlyLocalEntities=onlyLocalEntities; diff --git a/src/fr/inrialpes/exmo/ontowrap/jena25/JENAOntologyFactory.java b/src/fr/inrialpes/exmo/ontowrap/jena25/JENAOntologyFactory.java index 08e4286a88bca2bc00b3356b78bd83bb4efc759a..de57fd590d64da8bf7557e0abc9ea0bccf2263f3 100644 --- a/src/fr/inrialpes/exmo/ontowrap/jena25/JENAOntologyFactory.java +++ b/src/fr/inrialpes/exmo/ontowrap/jena25/JENAOntologyFactory.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2003-2008, 2010 + * Copyright (C) INRIA, 2003-2008, 2010, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -24,6 +24,9 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.NoSuchElementException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntModelSpec; import com.hp.hpl.jena.ontology.Ontology; @@ -35,6 +38,7 @@ import fr.inrialpes.exmo.ontowrap.OntologyCache; import fr.inrialpes.exmo.ontowrap.OntowrapException; public class JENAOntologyFactory extends OntologyFactory { + final static Logger logger = LoggerFactory.getLogger( JENAOntologyFactory.class ); private static URI formalismUri = null; private static String formalismId = "OWL1.0"; @@ -45,7 +49,9 @@ public class JENAOntologyFactory extends OntologyFactory { cache = new OntologyCache<JENAOntology>(); try { formalismUri = new URI("http://www.w3.org/2002/07/owl#"); - } catch (URISyntaxException ex) { ex.printStackTrace(); } // should not happen + } catch (URISyntaxException ex) { + logger.debug( "IGNORED (should never happen)", ex ); + } // should not happen } public JENAOntology newOntology( Object ontology , boolean onlyLocalEntities ) throws OntowrapException { diff --git a/src/fr/inrialpes/exmo/ontowrap/owlapi10/OWLAPIAnnotIt.java b/src/fr/inrialpes/exmo/ontowrap/owlapi10/OWLAPIAnnotIt.java index dcc760a454c62df1d9fd7147e2ef618fee7cd783..177cfab7f1c4fd434194039edbcc43596c0ae006 100644 --- a/src/fr/inrialpes/exmo/ontowrap/owlapi10/OWLAPIAnnotIt.java +++ b/src/fr/inrialpes/exmo/ontowrap/owlapi10/OWLAPIAnnotIt.java @@ -1,7 +1,7 @@ /* * $Id: OWLAPIAnnotIt.java 896 2008-11-25 14:45:46Z jdavid $ * - * Copyright (C) INRIA, 2007-2008, 2010 + * Copyright (C) INRIA, 2007-2008, 2010, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -23,6 +23,9 @@ package fr.inrialpes.exmo.ontowrap.owlapi10; import java.util.Iterator; import java.util.NoSuchElementException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.model.OWLAnnotationInstance; import org.semanticweb.owl.model.OWLDataValue; import org.semanticweb.owl.model.OWLEntity; @@ -36,6 +39,7 @@ import org.semanticweb.owl.model.OWLOntology; * */ public class OWLAPIAnnotIt implements Iterator<String> { + final static Logger logger = LoggerFactory.getLogger( OWLAPIAnnotIt.class ); /*private OWLOntology o; private OWLEntity e;*/ @@ -80,7 +84,7 @@ public class OWLAPIAnnotIt implements Iterator<String> { } } } catch (OWLException e) { - e.printStackTrace(); + logger.debug( "IGNORED Exception", e ); currentElem=null; } } diff --git a/src/fr/inrialpes/exmo/ontowrap/owlapi10/OWLAPIOntology.java b/src/fr/inrialpes/exmo/ontowrap/owlapi10/OWLAPIOntology.java index fb132c809d73d422af87c9cbef01b646dab41311..69bc1921c21882ab69e9b79be70d18fcfcbfa503 100644 --- a/src/fr/inrialpes/exmo/ontowrap/owlapi10/OWLAPIOntology.java +++ b/src/fr/inrialpes/exmo/ontowrap/owlapi10/OWLAPIOntology.java @@ -1,7 +1,7 @@ /* * $Id: OWLAPIOntology.java 896 2008-11-25 14:45:46Z jdavid $ * - * Copyright (C) INRIA, 2007-2008, 2010 + * Copyright (C) INRIA, 2007-2008, 2010, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -40,6 +40,9 @@ import java.util.Map; import java.util.Set; import java.util.HashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import fr.inrialpes.exmo.ontowrap.Annotation; import fr.inrialpes.exmo.ontowrap.OntologyFactory; import fr.inrialpes.exmo.ontowrap.HeavyLoadedOntology; @@ -69,6 +72,7 @@ import org.semanticweb.owl.model.helper.OWLEntityCollector; */ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyLoadedOntology<OWLOntology> { + final static Logger logger = LoggerFactory.getLogger( OWLAPIOntology.class ); /* For caching sizes */ private int nbentities = -1; @@ -82,7 +86,9 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL setFormalism( "OWL1.0" ); try { setFormURI( new URI("http://www.w3.org/2002/07/owl#") ); - } catch (Exception e) {}; // does not happen + } catch (Exception e) { + logger.debug( "IGNORED (should never happen)", e ); + }; }; // ----------------------------------------------------------------- @@ -179,7 +185,7 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL try { return new OWLAPIAnnotIt(o,e,lang,typeAnnot); } catch (OWLException e) { - e.printStackTrace(); + logger.debug( "IGNORED", e ); return null; } } @@ -357,7 +363,9 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL public void unload() { try { onto.getOWLConnection().notifyOntologyDeleted( onto ); - } catch (OWLException ex) { System.err.println(ex); }; + } catch (OWLException ex) { + logger.debug( "IGNORED Exception", ex); + }; } // ----------------------------------------------------------------- @@ -412,7 +420,9 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL if ( ent instanceof OWLRestriction ) prop.add( ((OWLRestriction)ent).getProperty() ); } - } catch (OWLException e) { e.printStackTrace(); } + } catch (OWLException e) { + logger.debug( "IGNORED", e ); + } } else { prop = getInheritedProperties( (OWLClass)cl ); } diff --git a/src/fr/inrialpes/exmo/ontowrap/owlapi10/OWLAPIOntologyFactory.java b/src/fr/inrialpes/exmo/ontowrap/owlapi10/OWLAPIOntologyFactory.java index 3039bd37c6832156e9fea1a5ae26135e7c6f5db0..2bc3cb0dad481a973a65c82575a2f183a176664c 100644 --- a/src/fr/inrialpes/exmo/ontowrap/owlapi10/OWLAPIOntologyFactory.java +++ b/src/fr/inrialpes/exmo/ontowrap/owlapi10/OWLAPIOntologyFactory.java @@ -28,6 +28,9 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owl.model.OWLException; import org.semanticweb.owl.model.OWLOntology; import org.semanticweb.owl.util.OWLConnection; @@ -40,6 +43,7 @@ import fr.inrialpes.exmo.ontowrap.LoadedOntology; import fr.inrialpes.exmo.ontowrap.OntowrapException; public class OWLAPIOntologyFactory extends OntologyFactory { + final static Logger logger = LoggerFactory.getLogger( OWLAPIOntologyFactory.class ); private static URI formalismUri = null; private static String formalismId = "OWL1.0"; @@ -49,7 +53,9 @@ public class OWLAPIOntologyFactory extends OntologyFactory { cache = new OntologyCache<OWLAPIOntology>(); try { formalismUri = new URI("http://www.w3.org/2002/07/owl#"); - } catch (URISyntaxException ex) { ex.printStackTrace(); } // should not happen + } catch (URISyntaxException ex) { + logger.debug( "IGNORED should never happen", ex ); + } }; public void clearCache() throws OntowrapException { @@ -67,7 +73,7 @@ public class OWLAPIOntologyFactory extends OntologyFactory { onto.setURI( ((OWLOntology)ontology).getLogicalURI() ); } catch (OWLException e) { // Better put in the OntowrapException of loaded - e.printStackTrace(); + logger.debug( "IGNORED (ontology without URI)", e ); } //cache.recordOntology( uri, onto ); return onto; @@ -99,7 +105,7 @@ public class OWLAPIOntologyFactory extends OntologyFactory { onto.setURI( ontology.getLogicalURI() ); } catch (OWLException e) { // Better put in the OntowrapException of loaded - e.printStackTrace(); + logger.debug( "IGNORED Exception", e ); } cache.recordOntology( uri, onto ); return onto; diff --git a/src/fr/inrialpes/exmo/ontowrap/owlapi30/OWLAPI3Ontology.java b/src/fr/inrialpes/exmo/ontowrap/owlapi30/OWLAPI3Ontology.java index 82e368651f08d4021d47c44cb43930a0c8c54c84..3c3fea5d1845ce55b886233de28f928bd1fe1313 100644 --- a/src/fr/inrialpes/exmo/ontowrap/owlapi30/OWLAPI3Ontology.java +++ b/src/fr/inrialpes/exmo/ontowrap/owlapi30/OWLAPI3Ontology.java @@ -93,9 +93,6 @@ public class OWLAPI3Ontology extends BasicOntology<OWLOntology> implements Heavy //return onto.getDataPropertiesInSignature(); } - - - public Set<? extends Object> getEntities() { //return onto.getSignature(); return new EntityFilter<OWLEntity>(onto.getSignature(),this) { diff --git a/src/fr/inrialpes/exmo/ontowrap/owlapi30/OWLAPI3OntologyFactory.java b/src/fr/inrialpes/exmo/ontowrap/owlapi30/OWLAPI3OntologyFactory.java index 788996dc837a03beefd6738b0cccfd5383dd29dd..d08caf42d376bdf1c0e0da3da804bdd708073cc5 100644 --- a/src/fr/inrialpes/exmo/ontowrap/owlapi30/OWLAPI3OntologyFactory.java +++ b/src/fr/inrialpes/exmo/ontowrap/owlapi30/OWLAPI3OntologyFactory.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2008-2011 + * Copyright (C) INRIA, 2008-2011, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -23,6 +23,9 @@ package fr.inrialpes.exmo.ontowrap.owlapi30; import java.net.URI; import java.net.URISyntaxException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.owlapi.apibinding.OWLManager; import org.semanticweb.owlapi.model.OWLOntology; @@ -38,6 +41,7 @@ import fr.inrialpes.exmo.ontowrap.OntologyFactory; import fr.inrialpes.exmo.ontowrap.HeavyLoadedOntology; public class OWLAPI3OntologyFactory extends OntologyFactory { + final static Logger logger = LoggerFactory.getLogger( OWLAPI3OntologyFactory.class ); private URI formalismUri = null; @@ -52,13 +56,13 @@ public class OWLAPI3OntologyFactory extends OntologyFactory { try { formalismUri = new URI("http://www.w3.org/2002/07/owl#"); manager = OWLManager.createOWLOntologyManager(); - } catch (URISyntaxException ex) { // should not happen - ex.printStackTrace(); + } catch (URISyntaxException ex) { + logger.debug( "IGNORED should never happen", ex ); } } @Override - public OWLAPI3Ontology newOntology( Object ontology , boolean onlyLocalEntities) throws OntowrapException { + public OWLAPI3Ontology newOntology( Object ontology, boolean onlyLocalEntities) throws OntowrapException { if ( ontology instanceof OWLOntology ) { OWLAPI3Ontology onto = new OWLAPI3Ontology(onlyLocalEntities); onto.setFormalism( formalismId ); @@ -74,27 +78,26 @@ public class OWLAPI3OntologyFactory extends OntologyFactory { } @Override - public HeavyLoadedOntology loadOntology( URI uri , boolean onlyLocalEntities) throws OntowrapException { + public HeavyLoadedOntology loadOntology( URI uri, boolean onlyLocalEntities ) throws OntowrapException { OWLAPI3Ontology onto = null; - //System.err.println( " Loading ontology "+uri ); + // logger.trace( " Loading ontology {}", uri ); // Cache seems to be implemented in API 3.0 anyway // and it seems to not work well with this one onto = cache.getOntologyFromURI( uri ); - //System.err.println( " cache1: "+onto ); + // logger.trace( "cache1: {}", onto ); if ( onto != null ) return onto; onto = cache.getOntology( uri ); - //System.err.println( " cache2: "+onto ); + // logger.trace( "cache2: {}", onto ); if ( onto != null ) return onto; // OWLAPI's own cache IRI ontoIRI = IRI.create( uri ); OWLOntology ontology = manager.getOntology( ontoIRI ); - //System.err.println( " cache3: "+ontology ); - + // logger.trace( "cache3: {}", ontology ); try { // This below does not seem to work! //ontology = manager.loadOntologyFromOntologyDocument( IRI.create( uri ) ); if ( ontology == null ) ontology = manager.loadOntology( ontoIRI ); - //System.err.println( " loaded: "+ontology ); + // logger.trace( "loaded: {}", ontology ); // I must retrieve it from cache and return it! } catch ( OWLOntologyDocumentAlreadyExistsException oodaeex ) { // should never happen // This is a cache failure @@ -105,10 +108,9 @@ public class OWLAPI3OntologyFactory extends OntologyFactory { if ( ontology == null ) throw new OntowrapException("Already loaded [owl cache failure] " + uri, ooaeex ); } catch ( OWLOntologyCreationException oocex ) { - oocex.printStackTrace(); - throw new OntowrapException("Cannot load " + uri, oocex ); + throw new OntowrapException( "Cannot load " + uri, oocex ); } - onto = new OWLAPI3Ontology(onlyLocalEntities); + onto = new OWLAPI3Ontology( onlyLocalEntities ); onto.setFormalism( formalismId ); onto.setFormURI( formalismUri ); onto.setOntology( ontology ); @@ -119,10 +121,10 @@ public class OWLAPI3OntologyFactory extends OntologyFactory { // Better put in the OntowrapException of loaded // The ontology has no URI. In principle, it is not valid // It may be possible to put the uri instead (now it is void) - e.printStackTrace(); + logger.debug( "IGNORED Exception (ontology without URI)", e ); } cache.recordOntology( uri, onto ); - //System.err.println( " after-cache: "+cache.getOntology( uri ) ); + // logger.trace( "after-cache: {}", cache.getOntology( uri ) ); return onto; } diff --git a/src/fr/inrialpes/exmo/ontowrap/skosapi/SKOSOntologyFactory.java b/src/fr/inrialpes/exmo/ontowrap/skosapi/SKOSOntologyFactory.java index fa9fdf95abb2ee9bb3af2d43b5c1e7c99f5cf67e..312c5d8865084cb685fdb6680606679c624209e5 100644 --- a/src/fr/inrialpes/exmo/ontowrap/skosapi/SKOSOntologyFactory.java +++ b/src/fr/inrialpes/exmo/ontowrap/skosapi/SKOSOntologyFactory.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2009-2010 + * Copyright (C) INRIA, 2009-2010, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -24,6 +24,9 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.NoSuchElementException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.skosapibinding.SKOSManager; import org.semanticweb.skos.SKOSCreationException; import org.semanticweb.skos.SKOSDataset; @@ -35,6 +38,7 @@ import fr.inrialpes.exmo.ontowrap.OntologyCache; import fr.inrialpes.exmo.ontowrap.OntowrapException; public class SKOSOntologyFactory extends OntologyFactory { + final static Logger logger = LoggerFactory.getLogger( SKOSOntologyFactory.class ); private static URI formalismUri = null; private static String formalismId = "SKOS1.0"; @@ -47,7 +51,7 @@ public class SKOSOntologyFactory extends OntologyFactory { cache = new OntologyCache<SKOSThesaurus>(); try { formalismUri = new URI("http://www.w3.org/2004/02/skos/core#"); - } catch (URISyntaxException ex) { ex.printStackTrace(); } // should not happen + } catch (URISyntaxException ex) { logger.debug( "IGNORED should not happen", ex ); } try { manager = new SKOSManager(); } catch (SKOSCreationException sce) { @@ -77,7 +81,7 @@ public class SKOSOntologyFactory extends OntologyFactory { @Override public SKOSThesaurus loadOntology( URI uri , boolean onlyLocalEntities) throws OntowrapException { - //System.err.println(" Loading "+uri ); + //logger.trace( "Loading {}", uri ); SKOSThesaurus onto = null; onto = cache.getOntologyFromURI( uri ); if ( onto != null ) return onto; diff --git a/src/fr/inrialpes/exmo/ontowrap/skosapi/SKOSThesaurus.java b/src/fr/inrialpes/exmo/ontowrap/skosapi/SKOSThesaurus.java index d0fbea57fdda2742bf8a342eef77be828e2d66ea..8f8ab92103ec64df6aab96e1682054b2de3a3bb3 100644 --- a/src/fr/inrialpes/exmo/ontowrap/skosapi/SKOSThesaurus.java +++ b/src/fr/inrialpes/exmo/ontowrap/skosapi/SKOSThesaurus.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2009-2010, 2012 + * Copyright (C) INRIA, 2009-2010, 2012-2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -27,6 +27,9 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.semanticweb.skos.SKOSDataFactory; import org.semanticweb.skos.SKOSDataset; import org.semanticweb.skos.SKOSAnnotation; @@ -45,6 +48,7 @@ import fr.inrialpes.exmo.ontowrap.HeavyLoadedOntology; import fr.inrialpes.exmo.ontowrap.OntowrapException; public class SKOSThesaurus extends BasicOntology<SKOSDataset> implements HeavyLoadedOntology<SKOSDataset>{ + final static Logger logger = LoggerFactory.getLogger( SKOSThesaurus.class ); SKOSDataFactory factory; @@ -88,7 +92,7 @@ onto.getSKOSDataRelationAssertions(concept) assertion.getSKOSObject(); if (literal.isTyped()) { SKOSTypedLiteral typedLiteral = literal.getAsSKOSTypedLiteral(); -System.out.println("\t\t" + assertion.getSKOSProperty().getURI().getFragment() + " " + literal.getLiteral() + " Type:" + typedLiteral.getDataType().getURI() ); +//logger.trace("\t\t {} {} Type: {}", assertion.getSKOSProperty().getURI().getFragment(), literal.getLiteral(), typedLiteral.getDataType().getURI() ); } else { SKOSUntypedLiteral untypedLiteral = literal.getAsSKOSUntypedLiteral(); if (untypedLiteral.hasLang()) { diff --git a/src/fr/inrialpes/exmo/ontowrap/skoslite/SKOSLiteOntologyFactory.java b/src/fr/inrialpes/exmo/ontowrap/skoslite/SKOSLiteOntologyFactory.java index aefc35948b87ec34c97724a64039cde994516460..8c412061821ce067daddfe72b4025548ec378b0d 100644 --- a/src/fr/inrialpes/exmo/ontowrap/skoslite/SKOSLiteOntologyFactory.java +++ b/src/fr/inrialpes/exmo/ontowrap/skoslite/SKOSLiteOntologyFactory.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2008-2010 + * Copyright (C) INRIA, 2008-2010, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -23,6 +23,9 @@ package fr.inrialpes.exmo.ontowrap.skoslite; import java.net.URI; import java.net.URISyntaxException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.hp.hpl.jena.rdf.model.Model; import fr.inrialpes.exmo.ontowrap.OntologyCache; @@ -30,6 +33,7 @@ import fr.inrialpes.exmo.ontowrap.OntologyFactory; import fr.inrialpes.exmo.ontowrap.OntowrapException; public class SKOSLiteOntologyFactory extends OntologyFactory { + final static Logger logger = LoggerFactory.getLogger( SKOSLiteOntologyFactory.class ); private URI formalismUri; private final static String formalismId = "SKOS1.0"; @@ -39,8 +43,7 @@ public class SKOSLiteOntologyFactory extends OntologyFactory { try { formalismUri = new URI("http://www.w3.org/2004/02/skos/core#"); } catch (URISyntaxException e) { - - e.printStackTrace(); + logger.trace( "IGNORED: should never been raised", e ); } } diff --git a/src/fr/inrialpes/exmo/ontowrap/skoslite/SKOSLiteThesaurus.java b/src/fr/inrialpes/exmo/ontowrap/skoslite/SKOSLiteThesaurus.java index 51291e00c8df5d17369beda4e64f355069f2398b..497726ac442aa332614e5f3f00f1c6d869050d95 100644 --- a/src/fr/inrialpes/exmo/ontowrap/skoslite/SKOSLiteThesaurus.java +++ b/src/fr/inrialpes/exmo/ontowrap/skoslite/SKOSLiteThesaurus.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2008-2010, 2012 + * Copyright (C) INRIA, 2008-2010, 2012-2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -27,6 +27,9 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.hp.hpl.jena.graph.Node; import com.hp.hpl.jena.rdf.model.InfModel; import com.hp.hpl.jena.rdf.model.Model; @@ -45,6 +48,7 @@ import fr.inrialpes.exmo.ontowrap.HeavyLoadedOntology; import fr.inrialpes.exmo.ontowrap.OntowrapException; public class SKOSLiteThesaurus implements HeavyLoadedOntology<Model> { + final static Logger logger = LoggerFactory.getLogger( SKOSLiteThesaurus.class ); protected final static String SKOS_ONTO = SKOSLiteThesaurus.class.getClassLoader().getResource("fr/inrialpes/exmo/ontowrap/skoslite/skos.rdf").toString(); @@ -150,7 +154,7 @@ public class SKOSLiteThesaurus implements HeavyLoadedOntology<Model> { */ public Set<? extends Object> getSubClasses(Object c, int local, int asserted, int named) { HashSet<Object> sub = new HashSet<Object>(); - //System.out.println(c); + //logger.trace( "getSubClasses({})", c); StmtIterator it =ontoInf.listStatements(null,ontoInf.getProperty(SKOS_BROADERTRANSITIVE),(Resource) c); while ( it.hasNext() ) { Statement st = it.next(); @@ -203,7 +207,8 @@ public class SKOSLiteThesaurus implements HeavyLoadedOntology<Model> { try { Object o = ontoInf.getRawModel().getResource(u.toString()); if (! ontoInf.contains((Resource) o, RDF.type, ontoInf.getResource(SKOS_CONCEPT))) { - return null;//System.out.println(u+" : "+o); + //logger.trace( "getEntity({}) = {}", u, o); + return null; } return o; @@ -224,7 +229,7 @@ public class SKOSLiteThesaurus implements HeavyLoadedOntology<Model> { while (it.hasNext()) { Node n = it.next().asNode(); if (n.isLiteral() && (lang==null || lang.equals(n.getLiteralLanguage()))) { - //System.out.println(n.getLiteralLexicalForm()); + //logger.trace( "getEntityAnnotation = {}", n.getLiteralLexicalForm() ); annots.add(n.getLiteralLexicalForm()); } } @@ -243,7 +248,7 @@ public class SKOSLiteThesaurus implements HeavyLoadedOntology<Model> { while (it.hasNext()) { Node n = it.next().asNode(); if (n.isLiteral()) { - //System.out.println(n.getLiteralLexicalForm()); + //logger.trace( "getEntityAnnotationsL = {}", n.getLiteralLexicalForm() ); annots.add(new Annotation(n.getLiteralLexicalForm(),n.getLiteralLanguage())); } } diff --git a/src/fr/inrialpes/exmo/ontowrap/util/EntityFilter.java b/src/fr/inrialpes/exmo/ontowrap/util/EntityFilter.java index d99f89826b90b5bb23ee47e7286dcc804cb661c3..2504b5037f049b9e7ccf298e7e8d6007717ef85e 100644 --- a/src/fr/inrialpes/exmo/ontowrap/util/EntityFilter.java +++ b/src/fr/inrialpes/exmo/ontowrap/util/EntityFilter.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2010 + * Copyright (C) INRIA, 2010, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -23,10 +23,14 @@ package fr.inrialpes.exmo.ontowrap.util; import java.net.URI; import java.util.Set; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import fr.inrialpes.exmo.ontowrap.LoadedOntology; import fr.inrialpes.exmo.ontowrap.OntowrapException; public class EntityFilter<T> extends FilteredSet<T> { + final static Logger logger = LoggerFactory.getLogger( EntityFilter.class ); private String ontoURI=null; private LoadedOntology<?> onto=null; @@ -43,11 +47,11 @@ public class EntityFilter<T> extends FilteredSet<T> { protected boolean isFiltered(T obj) { try { URI entURI=onto.getEntityURI(obj); - //System.out.println(entURI +" - "+ontoURI); + //logger.trace( "{} - {}", entURI, ontoURI); return (entURI.getAuthority()!=null) && (entURI==null || ontoURI.equals(entURI.toString()) || !entURI.toString().startsWith(ontoURI)); } catch (OntowrapException e) { - // e.printStackTrace(); + logger.debug( "IGNORED: Entity is filtered", e ); } return true; } diff --git a/src/org/semanticweb/owl/align/AlignmentException.java b/src/org/semanticweb/owl/align/AlignmentException.java index a09da48c91962025e771cdb40181ce4e6f3769f8..f55cac7dd956b1fe337a9a87b01d466a690a3b6f 100644 --- a/src/org/semanticweb/owl/align/AlignmentException.java +++ b/src/org/semanticweb/owl/align/AlignmentException.java @@ -30,19 +30,16 @@ import java.lang.Exception; * @version $Id$ */ -public class AlignmentException extends Exception -{ +public class AlignmentException extends Exception { private static final long serialVersionUID = 330; - public AlignmentException( String message ) - { + public AlignmentException( String message ) { super( message ); } - public AlignmentException( String message, Exception e ) - { - super( message, e ); + public AlignmentException( String message, Exception ex ) { + super( message, ex ); } } diff --git a/test/clitest.sh b/test/clitest.sh new file mode 100644 index 0000000000000000000000000000000000000000..00a4bd3876064e5b91ec9a48df3641aaee6e71af --- /dev/null +++ b/test/clitest.sh @@ -0,0 +1,1143 @@ +#!/bin/sh +# +# This long script runs commands from the +# +# It is highly dependent on logback and my own logback.xml +# + +CWD=`pwd` +CP=$CWD/lib/procalign.jar:$CWD/lib/slf4j/logback-core-1.0.9.jar:$CWD/lib/slf4j/logback-classic-1.0.9.jar:$CWD +RESDIR='/tmp/clitest' + +######################################################################## +# ProcAlign +######################################################################## + +/bin/rm -rf $RESDIR +mkdir -p $RESDIR + +# GOTO +if false; then +echo this is for avoiding some parts +#GOTO +fi + +echo "\t\tTHE -z OPTIONS RELY ON LOGBACK BEING PROPERLY DEFINED" +echo "\t\t *** Testing Procalign ***" + +#------------------- +echo "\t-z, -zzz" +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.Procalign -z &> $RESDIR/zerr.txt +grep "Unrecognized option: -z" $RESDIR/zerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with PROC-ERR1; fi +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.Procalign --zzz &> $RESDIR/zzzerr.txt +grep "Unrecognized option: --zzz" $RESDIR/zzzerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with PROC-ERR2; fi + +#------------------- +echo "\t-h,--help" +java -cp $CP fr.inrialpes.exmo.align.cli.Procalign -h &> $RESDIR/proc-h.txt +java -cp $CP fr.inrialpes.exmo.align.cli.Procalign --help &> $RESDIR/proc-help.txt +if [ -s $RESDIR/proc-h.txt ]; then diff $RESDIR/proc-h.txt $RESDIR/proc-help.txt > $RESDIR/proc-diff-h.txt; else echo error with PROC-HELP1; fi +if [ -s $RESDIR/proc-diff-h.txt ]; then echo error with PROC-HELP2; fi + +#------------------- +echo "\t-o,--output <FILE>" +java -cp $CP fr.inrialpes.exmo.align.cli.Procalign file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl -o $RESDIR/proc-o1.rdf +java -cp $CP fr.inrialpes.exmo.align.cli.Procalign file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl --output $RESDIR/proc-output1.rdf +sed "s:<time>[^<]*</time>::" $RESDIR/proc-o1.rdf > $RESDIR/proc-o.rdf +sed "s:<time>[^<]*</time>::" $RESDIR/proc-output1.rdf > $RESDIR/proc-output.rdf +if [ -s $RESDIR/proc-o.rdf ]; then diff $RESDIR/proc-o.rdf $RESDIR/proc-output.rdf; else echo error with PROC-OUTPUT1; fi + +#------------------- +echo "\t-a,--alignment <FILE>" +java -cp $CP fr.inrialpes.exmo.align.cli.Procalign file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl -a examples/rdf/sample.rdf | sed "s:<time>[^<]*</time>::" > $RESDIR/proc-a.rdf +java -cp $CP fr.inrialpes.exmo.align.cli.Procalign file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl --alignment examples/rdf/sample.rdf | sed "s:<time>[^<]*</time>::" > $RESDIR/proc-align.rdf +if [ -s $RESDIR/proc-a.rdf ]; then diff $RESDIR/proc-a.rdf $RESDIR/proc-align.rdf; else echo error with PROC-ALIGN1; fi + +#------------------- +echo "\t-i <C>, --impl <C>" +#JE: A random distance available (could try with others) +java -cp $CP fr.inrialpes.exmo.align.cli.Procalign file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl -i fr.inrialpes.exmo.align.impl.method.StrucSubsDistAlignment | sed "s:<time>[^<]*</time>::" > $RESDIR/proc-i.rdf +java -cp $CP fr.inrialpes.exmo.align.cli.Procalign file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl --impl fr.inrialpes.exmo.align.impl.method.StrucSubsDistAlignment | sed "s:<time>[^<]*</time>::" > $RESDIR/proc-impl.rdf +if [ -s $RESDIR/proc-i.rdf ]; then diff $RESDIR/proc-i.rdf $RESDIR/proc-impl.rdf; else echo error with PROC-IMPL1; fi + +#------------------- +echo "\t-Dn=v" +java -cp $CP fr.inrialpes.exmo.align.cli.Procalign file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl -i fr.inrialpes.exmo.align.impl.method.StringDistAlignment -DstringFunction=levenshteinDistance | sed "s:<time>[^<]*</time>::" > $RESDIR/proc-id.rdf +if [ -s $RESDIR/proc-id.rdf ]; then diff $RESDIR/proc-i.rdf $RESDIR/proc-id.rdf | sed "s:<time>[^<]*</time>::" > $RESDIR/diff-proc.txt; else echo error with PROC-PARAM1; fi +if [ ! -s $RESDIR/diff-proc.txt ]; then echo error with PROC-PARAM2; fi + +#------------------- +echo "\t-t,--threshold <DOUBLE>" +java -cp $CP fr.inrialpes.exmo.align.cli.Procalign file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl -i fr.inrialpes.exmo.align.impl.method.StringDistAlignment -DstringFunction=levenshteinDistance -t 0.4 | sed "s:<time>[^<]*</time>::" > $RESDIR/proc-t.rdf +java -cp $CP fr.inrialpes.exmo.align.cli.Procalign file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl fr.inrialpes.exmo.align.impl.method.StringDistAlignment -DstringFunction=levenshteinDistance --threshold 0.4 | sed "s:<time>[^<]*</time>::" > $RESDIR/proc-threshold.rdf +if [ -s $RESDIR/proc-t.rdf ]; then diff $RESDIR/proc-t.rdf $RESDIR/proc-threshold.rdf; else echo error with PROC-THRES1; fi +# test diff from previous +diff $RESDIR/proc-t.rdf $RESDIR/proc-id.rdf > $RESDIR/diff-proc.txt +if [ ! -s $RESDIR/diff-proc.txt ]; then echo error with PROC-THRES2; fi + +#------------------- +echo "\t-T,--cutmethod <METHOD>" +java -cp $CP fr.inrialpes.exmo.align.cli.Procalign file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl -i fr.inrialpes.exmo.align.impl.method.StringDistAlignment -DstringFunction=levenshteinDistance -t 0.4 -T perc | sed "s:<time>[^<]*</time>::" > $RESDIR/proc-C.rdf +java -cp $CP fr.inrialpes.exmo.align.cli.Procalign file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl --impl fr.inrialpes.exmo.align.impl.method.StringDistAlignment -DstringFunction=levenshteinDistance -t 0.4 --cutmethod perc | sed "s:<time>[^<]*</time>::" > $RESDIR/proc-cutmethod.rdf +if [ -s $RESDIR/proc-C.rdf ]; then diff $RESDIR/proc-C.rdf $RESDIR/proc-cutmethod.rdf; else echo error with PROC-CUT1; fi +# test diff from previous +diff $RESDIR/proc-C.rdf $RESDIR/proc-t.rdf > $RESDIR/diff-proc.txt +if [ ! -s $RESDIR/diff-proc.txt ]; then echo error with PROC-CUT2; fi + +#------------------- +echo "\t-r,--renderer <CLASS>" +java -cp $CP fr.inrialpes.exmo.align.cli.Procalign file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl -r fr.inrialpes.exmo.align.impl.renderer.OWLAxiomsRendererVisitor | sed "s/time: [0-9]*/time: 0/" > $RESDIR/proc-r.rdf +java -cp $CP fr.inrialpes.exmo.align.cli.Procalign file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl --renderer fr.inrialpes.exmo.align.impl.renderer.OWLAxiomsRendererVisitor | sed "s/time: [0-9]*/time: 0/" > $RESDIR/proc-render.rdf +if [ -s $RESDIR/proc-r.rdf ]; then diff $RESDIR/proc-r.rdf $RESDIR/proc-render.rdf; else echo error with PROC-RENDER1; fi + +#------------------- +echo "\t-P,--params <FILE>" +echo "<?xml version='1.0' encoding='utf-8' standalone='no'?> +<\x21DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\"> +<properties> +<entry key=\"impl\">fr.inrialpes.exmo.align.impl.method.StringDistAlignment</entry> +<entry key=\"stringFunction\">levenshteinDistance</entry> +</properties>" > $RESDIR/params.xml +java -cp $CP fr.inrialpes.exmo.align.cli.Procalign file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl -P $RESDIR/params.xml | sed "s:<time>[^<]*</time>::" > $RESDIR/proc-p.rdf +#Will not work because we use loadFromXML +#echo "impl=fr.inrialpes.exmo.align.impl.method.StringDistAlignment +#stringFunction=levenshteinDistance" > $RESDIR/params.prop +java -cp $CP fr.inrialpes.exmo.align.cli.Procalign file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl --params $RESDIR/params.xml | sed "s:<time>[^<]*</time>::" > $RESDIR/proc-params.rdf +if [ -s $RESDIR/proc-p.rdf ]; then diff $RESDIR/proc-p.rdf $RESDIR/proc-params.rdf; else echo error with PROC-PARAMS1; fi +diff $RESDIR/proc-p.rdf $RESDIR/proc-id.rdf + +######################################################################## +# ParserPrinter +######################################################################## + +echo "\t\t *** Testing ParserPrinter ***" + +#------------------- +echo "\t-z, -zzz" + +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter -z &> $RESDIR/zerr.txt +grep "Unrecognized option: -z" $RESDIR/zerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with PARS-ERR1; fi +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter --zzz &> $RESDIR/zzzerr.txt +grep "Unrecognized option: --zzz" $RESDIR/zzzerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with PARS-ERR2; fi + +#------------------- +echo "\t-h, --help" +java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter -h &> $RESDIR/pars-h.txt +java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter --help &> $RESDIR/pars-help.txt +if [ -s $RESDIR/pars-h.txt ]; then diff $RESDIR/pars-h.txt $RESDIR/pars-help.txt; else echo error with $RESDIR/pars-h.txt; fi + +#------------------- +echo "\tno-op" +java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter file://$CWD/examples/rdf/newsample.rdf &> $RESDIR/pars-noop.rdf + +#------------------- +echo "\t-e,--embedded" +java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter file://$CWD/examples/rdf/newsample.rdf -e -o $RESDIR/pars-e.rdf +java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter file://$CWD/examples/rdf/newsample.rdf --embedded -o $RESDIR/pars-emb.rdf +if [ -s $RESDIR/pars-e.rdf ]; then diff $RESDIR/pars-e.rdf $RESDIR/pars-emb.rdf; else echo error with PARS-EMB; fi +diff $RESDIR/pars-e.rdf $RESDIR/pars-noop.rdf + +#------------------- +# JE: there is no alternative parser (RDF/XML Parser are not AlignmentParsers) +echo "\t-p,--parser <CLASS>" +java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter -p fr.inrialpes.exmo.align.parser.AlignmentParser file://$CWD/examples/rdf/newsample.rdf -o $RESDIR/pars-p1.rdf +java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter --parser fr.inrialpes.exmo.align.parser.AlignmentParser file://$CWD/examples/rdf/newsample.rdf -o $RESDIR/pars-p2.rdf +if [ -s $RESDIR/pars-p1.rdf ]; then diff $RESDIR/pars-p1.rdf $RESDIR/pars-p2.rdf; else echo error with PARS-PARS1; fi + +#------------------- +echo "\t-o <F>, --output <F>" +java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter file://$CWD/examples/rdf/newsample.rdf -o $RESDIR/pars-o1.rdf +if [ -s $RESDIR/pars-o1.rdf ]; then diff $RESDIR/pars-o1.rdf $RESDIR/pars-noop.rdf; else echo error with PARS-OUTPUT0; fi +java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter file://$CWD/examples/rdf/newsample.rdf --output $RESDIR/pars-output1.rdf +diff $RESDIR/pars-o1.rdf $RESDIR/pars-output1.rdf + +#------------------- +# This is for SPARQL OUTPUT +echo "\t-c,--outputDir <DIR>" +#java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter file://$CWD/examples/rdf/newsample.rdf -w $RESDIR -o pars-o2.rdf +#java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter file://$CWD/examples/rdf/newsample.rdf --output pars-output2.rdf --outputDir $RESDIR +#if [ -s $RESDIR/pars-o2.rdf ]; then diff $RESDIR/pars-o2.rdf $RESDIR/pars-output2.rdf; else echo error with PARS-OUTPUT2; fi + +#------------------- +echo "\t-i,--inverse" +java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter file://$CWD/examples/rdf/newsample.rdf -i -o $RESDIR/pars-i.rdf +if [ -s $RESDIR/pars-i.rdf ]; then diff $RESDIR/pars-i.rdf $RESDIR/pars-noop.rdf > $RESDIR/diff-pars.txt; else echo error with PARS-INV1; fi +if [ ! -s $RESDIR/diff-pars.txt ]; then echo error with PARS-INV2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter file://$CWD/examples/rdf/newsample.rdf --inverse --output $RESDIR/pars-inverse.rdf +diff $RESDIR/pars-i.rdf $RESDIR/pars-inverse.rdf + +#------------------- +echo "\t-t,--threshold <DOUBLE>" +java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter file://$CWD/examples/rdf/newsample.rdf -t .6 -o $RESDIR/pars-t1.rdf +if [ -s $RESDIR/pars-t1.rdf ]; then diff $RESDIR/pars-t1.rdf $RESDIR/pars-noop.rdf > $RESDIR/diff-thres.txt; else echo error with PARS-THRES1; fi +if [ ! -s $RESDIR/diff-thres.txt ]; then echo error with PARS-THRES2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter file://$CWD/examples/rdf/newsample.rdf --threshold .6 --output $RESDIR/pars-thres1.rdf +diff $RESDIR/pars-t1.rdf $RESDIR/pars-thres1.rdf + +#------------------- +echo "\t-T,--cutmethod <METHOD>" +java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter file://$CWD/examples/rdf/newsample.rdf -T best -t .6 -o $RESDIR/pars-g1.rdf +if [ -s $RESDIR/pars-g1.rdf ]; then diff $RESDIR/pars-g1.rdf $RESDIR/pars-t1.rdf > $RESDIR/diff-gap.txt; else echo error with PARS-GAP1; fi +if [ ! -s $RESDIR/diff-gap.txt ]; then echo error with PARS-GAP2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter file://$CWD/examples/rdf/newsample.rdf --cutmethod best --threshold .6 --output $RESDIR/pars-gap1.rdf +diff $RESDIR/pars-g1.rdf $RESDIR/pars-gap1.rdf + +#------------------- +echo "\t-r,--renderer <CLASS>" +java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter file://$CWD/examples/rdf/newsample.rdf -r fr.inrialpes.exmo.align.impl.renderer.OWLAxiomsRendererVisitor -o $RESDIR/pars-r1.rdf +if [ -s $RESDIR/pars-r1.rdf ]; then diff $RESDIR/pars-r1.rdf $RESDIR/pars-o1.rdf > $RESDIR/diff-rend.txt; else echo error with PARS-RENDER1; fi +if [ ! -s $RESDIR/diff-rend.txt ]; then echo error with PARS-RENDER2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.ParserPrinter file://$CWD/examples/rdf/newsample.rdf --renderer fr.inrialpes.exmo.align.impl.renderer.OWLAxiomsRendererVisitor -o $RESDIR/pars-render1.rdf +diff $RESDIR/pars-r1.rdf $RESDIR/pars-render1.rdf + +#------------------- +echo "\t-Dn=v" +echo "\t(same as Procalign)" + +#------------------- +echo "\t-P,--params <FILE>" +echo "\t(same as Procalign)" + +######################################################################## +# EvalAlign +######################################################################## + +echo "\t\t *** Testing EvalAlign ***" + +#------------------- +echo "\t-d(<L>), --debug (<L>) DEPRECATED" + +#------------------- +echo "\t-z, -zzz" + +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.EvalAlign -z &> $RESDIR/zerr.txt +grep "Unrecognized option: -z" $RESDIR/zerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with EVAL-ERR1; fi +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.EvalAlign --zzz &> $RESDIR/zzzerr.txt +grep "Unrecognized option: --zzz" $RESDIR/zzzerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with EVAL-ERR2; fi + +#------------------- +echo "\t-h, --help" +java -cp $CP fr.inrialpes.exmo.align.cli.EvalAlign -h &> $RESDIR/eval-h.txt +java -cp $CP fr.inrialpes.exmo.align.cli.EvalAlign --help &> $RESDIR/eval-help.txt +# This should be put everywhere! +if [ -s $RESDIR/eval-h.txt ]; then diff $RESDIR/eval-h.txt $RESDIR/eval-help.txt; else echo error with EVAL-HELP1; fi + +#java -cp $CP fr.inrialpes.exmo.align.cli.EvalAlign -i fr.inrialpes.exmo.align.impl.eval.PRecEvaluator html/tutorial/refalign.rdf html/tutorial/refalign.rdf -o $RESDIR/eval-i.txt +#java -cp $CP fr.inrialpes.exmo.align.cli.EvalAlign --impl fr.inrialpes.exmo.align.impl.eval.PRecEvaluator html/tutorial/refalign.rdf html/tutorial/refalign.rdf --output $RESDIR/eval-impl.txt +#if [ -s $RESDIR/eval-i.txt ]; then diff $RESDIR/eval-i.txt $RESDIR/eval-impl.txt; else echo error with EVAL_HELP2; fi + +#------------------- +echo "\tno-op" +java -cp $CP fr.inrialpes.exmo.align.cli.EvalAlign file://$CWD/examples/rdf/newsample.rdf file://$RESDIR/proc-o1.rdf &> $RESDIR/eval-noop.xml +if [ ! -s $RESDIR/eval-noop.xml ]; then echo error with EVAL-NOOP; fi + +#------------------- +echo "\t-o <F>, --output <F>" +java -cp $CP fr.inrialpes.exmo.align.cli.EvalAlign file://$CWD/examples/rdf/newsample.rdf file://$RESDIR/proc-o1.rdf -o $RESDIR/eval-o1.xml +if [ -s $RESDIR/eval-o1.xml ]; then diff $RESDIR/eval-o1.xml $RESDIR/eval-noop.xml; else echo error with EVAL-OUT1; fi +java -cp $CP fr.inrialpes.exmo.align.cli.EvalAlign file://$CWD/examples/rdf/newsample.rdf file://$RESDIR/proc-o1.rdf --output $RESDIR/eval-out1.xml +diff $RESDIR/eval-out1.xml $RESDIR/eval-o1.xml + +#------------------- +echo "\t-i <C>, --impl <C>" +java -cp $CP fr.inrialpes.exmo.align.cli.EvalAlign -i fr.inrialpes.exmo.align.impl.eval.WeightedPREvaluator file://$CWD/examples/rdf/newsample.rdf file://$RESDIR/proc-o1.rdf -o $RESDIR/eval-i1.xml +if [ -s $RESDIR/eval-i1.xml ]; then diff $RESDIR/eval-o1.xml $RESDIR/eval-noop.xml > $RESDIR/diff-evimpl.txt ; else echo error with EVAL-IMPL1; fi +if [ ! -s $RESDIR/diff-rend.txt ]; then echo error with EVAL-IMPL2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.EvalAlign --impl fr.inrialpes.exmo.align.impl.eval.WeightedPREvaluator file://$CWD/examples/rdf/newsample.rdf file://$RESDIR/proc-o1.rdf -o $RESDIR/eval-impl1.xml +diff $RESDIR/eval-impl1.xml $RESDIR/eval-i1.xml + +#------------------- +echo "\t-Dn=v" +echo "\t(same as Procalign)" + +#------------------- +echo "\t-P,--params <FILE>" +echo "\t(same as Procalign)" + +######################################################################## +# TestGen +######################################################################## + +echo "\t\t *** Testing TestGen ***" + +#java -Xmx1200m -cp $CP fr.inrialpes.exmo.align.cli.TestGen -u http://www.example.org/mynewtest -w $RESDIR/outtestdir -DremoveClasses=.25 examples/rdf/edu.umbc.ebiquity.publication.owl +# --> This one +#java -Xmx1200m -cp $CP fr.inrialpes.exmo.align.cli.TestGen -t fr.inrialpes.exmo.align.gen.BenchmarkGenerator -u http://www.example.org/mynewtest -w $RESDIR/outtestdir examples/rdf/edu.umbc.ebiquity.publication.owl +#$JAVA -Xmx1200m -cp $CP fr.inrialpes.exmo.align.cli.TestGen -t fr.inrialpes.exmo.align.gen.BenchmarkGenerator -u $URI/$run/ -w $DIR/r$run $seedonto + +#------------------- +echo "\t-z, -zzz" + +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.TestGen -z &> $RESDIR/zerr.txt +grep "Unrecognized option: -z" $RESDIR/zerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with GEN-ERR1; fi +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.TestGen --zzz &> $RESDIR/zzzerr.txt +grep "Unrecognized option: --zzz" $RESDIR/zzzerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with GEN-ERR2; fi + +#------------------- +echo "\t-h, --help" +java -cp $CP fr.inrialpes.exmo.align.cli.TestGen -h &> $RESDIR/test-h.txt +java -cp $CP fr.inrialpes.exmo.align.cli.TestGen --help &> $RESDIR/test-help.txt +if [ -s $RESDIR/test-h.txt ]; then diff $RESDIR/test-h.txt $RESDIR/test-help.txt; else echo error with TEST-HELP; fi + +#------------------- +echo "\t-u,--urlprefix <URI> --uriprefix" +mkdir $RESDIR/smalltest +mkdir $RESDIR/smalltest/gentestempty1 +cd $RESDIR/smalltest/gentestempty1 +java -Xmx1200m -cp $CP fr.inrialpes.exmo.align.cli.TestGen -u http://www.example.org/mynewtest $CWD/examples/rdf/edu.umbc.ebiquity.publication.owl +if [ ! -s refalign.rdf ]; then echo error with GEN-EMP1; fi +if [ ! -s onto.rdf ]; then echo error with GEN-EMP2; fi +mkdir $RESDIR/smalltest/gentestempty2 +cd $RESDIR/smalltest/gentestempty2 +java -Xmx1200m -cp $CP fr.inrialpes.exmo.align.cli.TestGen --uriprefix http://www.example.org/mynewtest2 $CWD/examples/rdf/edu.umbc.ebiquity.publication.owl +if [ -s refalign.rdf ]; then diff refalign.rdf $RESDIR/smalltest/gentestempty1/refalign.rdf > gendiff.txt; else echo error with GEN-EMP3; fi +if [ ! -s gendiff.txt ]; then echo error with GEN-EMP4; fi +if [ -s onto.rdf ]; then diff onto.rdf $RESDIR/smalltest/gentestempty1/onto.rdf > gendiff.txt; else echo error with GEN-EMP5; fi +if [ ! -s gendiff.txt ]; then echo error with GEN-EMP6; fi +cd $CWD + +#------------------- +echo "\t-w,--outdir <DIR>" +java -Xmx1200m -cp $CP fr.inrialpes.exmo.align.cli.TestGen -u http://www.example.org/mynewtest -w $RESDIR/smalltest/outtestdir1 examples/rdf/edu.umbc.ebiquity.publication.owl +java -Xmx1200m -cp $CP fr.inrialpes.exmo.align.cli.TestGen -u http://www.example.org/mynewtest --outdir $RESDIR/smalltest/outtestdir2 examples/rdf/edu.umbc.ebiquity.publication.owl +#if [ -s $RESDIR/smalltest/outtestdir1/onto.rdf ]; then diff $RESDIR/smalltest/outtestdir1/onto.rdf $RESDIR/smalltest/outtestdir2/onto.rdf; else echo error with GEN-OUT1; fi +if [ -s $RESDIR/smalltest/outtestdir1/refalign.rdf ]; then diff $RESDIR/smalltest/outtestdir1/refalign.rdf $RESDIR/smalltest/outtestdir2/refalign.rdf; else echo error with GEN-OUT2; fi + +#------------------- +echo "\t-Dn=v" +java -Xmx1200m -cp $CP fr.inrialpes.exmo.align.cli.TestGen -u http://www.example.org/mynewtest -DremoveClasses=.25 -w $RESDIR/smalltest/outtestdir3 examples/rdf/edu.umbc.ebiquity.publication.owl +# Here we can do with many parameters +if [ -s $RESDIR/smalltest/outtestdir3/onto.rdf ]; then diff $RESDIR/smalltest/outtestdir1/refalign.rdf $RESDIR/smalltest/outtestdir3/refalign.rdf > $RESDIR/smalltest/outtestdir2/gendiff.txt ; else echo error with GEN-OUT3; fi +if [ ! -s $RESDIR/smalltest/outtestdir2/gendiff.txt ]; then echo error with GEN-VAR1; fi + +#------------------- +echo "\t-a,--alignname <FILE> " +echo "\t-o,--output <FILE>" +java -Xmx1200m -cp $CP fr.inrialpes.exmo.align.cli.TestGen -u http://www.example.org/mynewtest -a myalign.rdf -o biblio.owl -w $RESDIR/outtestdir4 examples/rdf/edu.umbc.ebiquity.publication.owl +java -Xmx1200m -cp $CP fr.inrialpes.exmo.align.cli.TestGen -u http://www.example.org/mynewtest --alignname myalign.rdf --output biblio.owl -w $RESDIR/outtestdir5 examples/rdf/edu.umbc.ebiquity.publication.owl +if [ -s $RESDIR/outtestdir4/biblio.owl ]; then diff $RESDIR/outtestdir5/biblio.owl $RESDIR/outtestdir4/biblio.owl; else echo error with GEN-OUT1; fi +if [ -s $RESDIR/outtestdir4/myalign.rdf ]; then diff $RESDIR/outtestdir5/myalign.rdf $RESDIR/outtestdir4/myalign.rdf; else echo error with GEN-AL1; fi +diff $RESDIR/outtestdir5/myalign.rdf $RESDIR/smalltest/outtestdir1/refalign.rdf > $RESDIR/outtestdir5/gendiff.txt +if [ ! -s $RESDIR/outtestdir5/gendiff.txt ]; then echo error with GEN-AL2; fi + +#------------------- +echo "\t-t,--testset <CLASS>" +mkdir $RESDIR/outtestdir +java -Xmx1200m -cp $CP fr.inrialpes.exmo.align.cli.TestGen -t fr.inrialpes.exmo.align.gen.BenchmarkGenerator -u http://www.example.org/mynewtest -w $RESDIR/outtestdir examples/rdf/edu.umbc.ebiquity.publication.owl +mkdir $RESDIR/outtestdir9 +java -Xmx1200m -cp $CP fr.inrialpes.exmo.align.cli.TestGen --testset fr.inrialpes.exmo.align.gen.BenchmarkGenerator --uriprefix http://www.example.org/mynewtest --outdir $RESDIR/outtestdir9 examples/rdf/edu.umbc.ebiquity.publication.owl +if [ -s $RESDIR/outtestdir9/266/onto.rdf ]; then diff $RESDIR/outtestdir/266/onto.rdf $RESDIR/outtestdir9/266/onto.rdf > $RESDIR/outtestdir9/gendiff.txt; else echo error with GEN-TSET1; fi +if [ ! -s $RESDIR/outtestdir9/gendiff.txt ]; then echo error with GEN-TSET2; fi + +#------------------- +echo "\t-P,--params <FILE>" +echo "\t(same as Procalign)" + +######################################################################## +# GroupAlign +######################################################################## + +# ADJUSTED Because otherwise --alignment below does not work + +for i in `cd $RESDIR/smalltest/; ls -d */` +do +sed -i '' "s;<location>http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#</location>;<location>file://$RESDIR/smalltest/gentestempty1/onto1.rdf</location>;" $RESDIR/smalltest/${i}refalign.rdf +sed -i '' "s;<location>http://www.example.org/mynewtest/onto.rdf#</location>;<location>file://$RESDIR/smalltest/${i}onto.rdf</location>;" $RESDIR/smalltest/${i}refalign.rdf +sed -i '' "s;http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#;http://www.example.org/mynewtest/101/onto.rdf#;" $RESDIR/smalltest/${i}refalign.rdf +done + +echo "\t\t *** Testing GroupAlign ***" + +cp $RESDIR/outtestdir/101/onto.rdf $RESDIR/smalltest/gentestempty1/onto1.rdf +cp $RESDIR/outtestdir/101/onto.rdf $RESDIR/smalltest/gentestempty2/onto1.rdf +cp $RESDIR/outtestdir/101/onto.rdf $RESDIR/smalltest/outtestdir1/onto1.rdf +cp $RESDIR/outtestdir/101/onto.rdf $RESDIR/smalltest/outtestdir2/onto1.rdf +cp $RESDIR/outtestdir/101/onto.rdf $RESDIR/smalltest/outtestdir3/onto1.rdf + +#------------------- +echo "\tEMPTY" +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign + +#------------------- +echo "\t-z, -zzz" + +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign -z &> $RESDIR/zerr.txt +grep "Unrecognized option: -z" $RESDIR/zerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with GRAL-ERR1; fi +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign --zzz &> $RESDIR/zzzerr.txt +grep "Unrecognized option: --zzz" $RESDIR/zzzerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with GRAL-ERR2; fi + +#------------------- +echo "\t-h, --help" +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign -h &> $RESDIR/gral-h.txt +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign --help &> $RESDIR/gral-help.txt +if [ -s $RESDIR/gral-h.txt ]; then diff $RESDIR/gral-h.txt $RESDIR/gral-help.txt; else echo error with GRAL-HELP; fi + +#------------------- +echo "\t-w,--directory <DIR>" +echo "\t-o <F>, --output <F>" +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign -w $RESDIR/smalltest -o streq1.rdf +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign --directory $RESDIR/smalltest --output streq2.rdf +sed -i '' "s;<time>[^<]*</time>;;g" $RESDIR/smalltest/gentestempty1/streq1.rdf +sed -i '' "s;<time>[^<]*</time>;;g" $RESDIR/smalltest/gentestempty1/streq2.rdf +if [ -s $RESDIR/smalltest/gentestempty1/streq1.rdf ]; then diff $RESDIR/smalltest/gentestempty1/streq1.rdf $RESDIR/smalltest/gentestempty1/streq2.rdf > $RESDIR/smalltest/diffstreq.txt ; else echo error with GRAL-DIR1; fi +if [ -s $RESDIR/smalltest/diffstreq.txt ]; then echo error with GRAL-DIR2; fi + +#------------------- +echo "\t-i <C>, --impl <C>" +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign -i fr.inrialpes.exmo.align.impl.method.EditDistNameAlignment -w $RESDIR/smalltest -o edna1.rdf +sed -i '' "s;<time>[^<]*</time>;;g" $RESDIR/smalltest/gentestempty1/edna1.rdf +if [ -s $RESDIR/smalltest/gentestempty1/edna1.rdf ]; then diff $RESDIR/smalltest/gentestempty1/edna1.rdf $RESDIR/smalltest/gentestempty1/streq2.rdf > $RESDIR/smalltest/diffstredna.txt ; else echo error with GRAL-IMPL1; fi +if [ ! -s $RESDIR/smalltest/diffstredna.txt ]; then echo error with GRAL-IMPL2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign --impl fr.inrialpes.exmo.align.impl.method.EditDistNameAlignment -w $RESDIR/smalltest -o edna2.rdf +sed -i '' "s;<time>[^<]*</time>;;g" $RESDIR/smalltest/gentestempty1/edna2.rdf +if [ -s $RESDIR/smalltest/gentestempty1/edna2.rdf ]; then diff $RESDIR/smalltest/gentestempty1/edna1.rdf $RESDIR/smalltest/gentestempty1/edna2.rdf > $RESDIR/smalltest/diffedna.txt ; else echo error with GRAL-IMPL3; fi +if [ -s $RESDIR/smalltest/diffedna.txt ]; then echo error with GRAL-IMPL4; fi + +#------------------- +# This test in fact does not work because there are too many 1. values. +# I have checked that it works independently (add a bad distance name!) +echo "\t-Dn=v" + +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign -i fr.inrialpes.exmo.align.impl.method.StringDistAlignment -DstringFunction=levenshteinDistance -w $RESDIR/smalltest -o lev1.rdf +sed -i '' "s;<time>[^<]*</time>;;g" $RESDIR/smalltest/gentestempty1/lev1.rdf +if [ -s $RESDIR/smalltest/gentestempty1/lev1.rdf ]; then diff $RESDIR/smalltest/gentestempty1/edna1.rdf $RESDIR/smalltest/gentestempty1/lev1.rdf > $RESDIR/smalltest/diffstredna.txt ; else echo error with GRAL-DV1; fi +if [ ! -s $RESDIR/smalltest/diffstredna.txt ]; then echo error with GRAL-DV2; fi + +#------------------- + +echo "\t-a,--alignment <FILE> " +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign -a refalign.rdf -w $RESDIR/smalltest -o streq1a.rdf +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign --alignment refalign.rdf --directory $RESDIR/smalltest --output streq2a.rdf +sed -i '' "s;<time>[^<]*</time>;;g" $RESDIR/smalltest/gentestempty1/streq1a.rdf +sed -i '' "s;<time>[^<]*</time>;;g" $RESDIR/smalltest/gentestempty1/streq2a.rdf +if [ -s $RESDIR/smalltest/gentestempty1/streq1a.rdf ]; then diff $RESDIR/smalltest/gentestempty1/streq1a.rdf $RESDIR/smalltest/gentestempty1/streq2a.rdf > $RESDIR/smalltest/diffstreqa.txt ; else echo error with GRAL-AL1; fi +if [ -s $RESDIR/smalltest/diffstreqa.txt ]; then echo error with GRAL-AL2; fi + +#------------------- +echo "\t-n,--name <URI>" +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign -n file://$RESDIR/outtestdir/101/onto.rdf -w $RESDIR/smalltest -o streq1n.rdf +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign --name file://$RESDIR/outtestdir/101/onto.rdf --directory $RESDIR/smalltest --output streq2n.rdf +sed -i '' "s;<time>[^<]*</time>;;g" $RESDIR/smalltest/gentestempty1/streq1n.rdf +sed -i '' "s;<time>[^<]*</time>;;g" $RESDIR/smalltest/gentestempty1/streq2n.rdf +if [ -s $RESDIR/smalltest/gentestempty1/streq1n.rdf ]; then diff $RESDIR/smalltest/gentestempty1/streq1n.rdf $RESDIR/smalltest/gentestempty1/streq2n.rdf > $RESDIR/smalltest/diffstreqn.txt ; else echo error with GRAL-NAME1; fi +if [ -s $RESDIR/smalltest/diffstreqn.txt ]; then echo error with GRAL-NAME2; fi + +#------------------- +echo "\t-r,--renderer <CLASS>" +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign -r fr.inrialpes.exmo.align.impl.renderer.HTMLRendererVisitor -w $RESDIR/smalltest -o streq1.html +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign --renderer fr.inrialpes.exmo.align.impl.renderer.HTMLRendererVisitor --directory $RESDIR/smalltest --output streq2.html +sed -i '' "s;time</td><td property=\"align:time\">[^<]*;;g" $RESDIR/smalltest/gentestempty1/streq1.html +sed -i '' "s;time</td><td property=\"align:time\">[^<]*;;g" $RESDIR/smalltest/gentestempty1/streq2.html +if [ -s $RESDIR/smalltest/gentestempty1/streq1.html ]; then diff $RESDIR/smalltest/gentestempty1/streq1.html $RESDIR/smalltest/gentestempty1/streq2.html ; else echo error with GRAL-RENDER1; fi + +#------------------- +echo "\t-s,--source <FILE>" +echo "\t-t,--target <FILE>" +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign -s onto.rdf -t onto1.rdf -w $RESDIR/smalltest -o streq1x.rdf +sed -i '' "s;<time>[^<]*</time>;;g" $RESDIR/smalltest/gentestempty1/streq1x.rdf +if [ -s $RESDIR/smalltest/gentestempty1/streq1x.rdf ]; then diff $RESDIR/smalltest/gentestempty1/streq1x.rdf $RESDIR/smalltest/gentestempty1/streq2n.rdf > $RESDIR/smalltest/diffstreqxn.txt ; else echo error with GRAL-ST1; fi +if [ ! -s $RESDIR/smalltest/diffstreqxn.txt ]; then echo error with GRAL-ST2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign --source onto.rdf --target onto1.rdf --directory $RESDIR/smalltest --output streq2x.rdf +sed -i '' "s;<time>[^<]*</time>;;g" $RESDIR/smalltest/gentestempty1/streq2x.rdf +if [ -s $RESDIR/smalltest/gentestempty1/streq1x.rdf ]; then diff $RESDIR/smalltest/gentestempty1/streq1x.rdf $RESDIR/smalltest/gentestempty1/streq2x.rdf ; else echo error with GRAL-ST3; fi + +#------------------- +echo "\t-u,--uriprefix <URI>" + +ln -s /tmp/clitest/smalltest /tmp/clitest/preftest + +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign -w $RESDIR/smalltest -u file:///tmp/clitest/preftest -o strpr1.rdf +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign --directory $RESDIR/smalltest --uriprefix file:///tmp/clitest/preftest --output strpr2.rdf +sed -i '' "s;<time>[^<]*</time>;;g" $RESDIR/smalltest/gentestempty1/strpr1.rdf +sed -i '' "s;<time>[^<]*</time>;;g" $RESDIR/smalltest/gentestempty1/strpr2.rdf +if [ -s $RESDIR/smalltest/gentestempty1/strpr1.rdf ]; then diff $RESDIR/smalltest/gentestempty1/strpr1.rdf $RESDIR/smalltest/gentestempty1/strpr2.rdf > $RESDIR/smalltest/diffpref.txt ; else echo error with GRAL-PR1; fi +if [ -s $RESDIR/smalltest/diffpref.txt ]; then echo error with GRAL-PR2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupAlign -w $RESDIR/smalltest -u file:///tmp/clitest/dummy -o strpr3.rdf +if [ -s $RESDIR/smalltest/gentestempty1/strpr3.rdf ]; then echo error with GRAL-PR3; fi + +#------------------- +echo "\t-P,--params <FILE>" +echo "\t(same as Procalign)" + +######################################################################## +# GroupEval +######################################################################## + +echo "\t\t *** Testing GroupEval ***" + +#------------------- +echo "\t-z, -zzz" + +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.GroupEval -z &> $RESDIR/zerr.txt +grep "Unrecognized option: -z" $RESDIR/zerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with GREV-ERR1; fi +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.GroupEval --zzz &> $RESDIR/zzzerr.txt +grep "Unrecognized option: --zzz" $RESDIR/zzzerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with GREV-ERR2; fi + +#------------------- +echo "\t-h, --help" + +java -cp $CP fr.inrialpes.exmo.align.cli.GroupEval -h &> $RESDIR/groupeval-h.txt +java -cp $CP fr.inrialpes.exmo.align.cli.GroupEval --help &> $RESDIR/groupeval-help.txt +if [ -s $RESDIR/groupeval-h.txt ]; then diff $RESDIR/groupeval-h.txt $RESDIR/groupeval-help.txt; else echo error with GREVAL-HELP; fi + +#------------------- +echo "\t-l,--list <FILE>" + +cd $RESDIR/smalltest +java -cp $CP fr.inrialpes.exmo.align.cli.GroupEval -l "refalign,lev1,streq1" > groupeval-l1.html +if [ ! -s groupeval-l1.html ]; then echo error with GREV-LIST1; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupEval --list "refalign,lev1,streq1" > groupeval-l2.html +if [ -s groupeval-l2.html ]; then diff groupeval-l1.html groupeval-l2.html ; else echo error with GREV-LIST2; fi +cd $CWD + +#------------------- +echo "\t-w,--directory <DIR>" + +java -cp $CP fr.inrialpes.exmo.align.cli.GroupEval -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest > $RESDIR/groupeval-w1.html +if [ -s $RESDIR/groupeval-w1.html ]; then diff $RESDIR/groupeval-w1.html $RESDIR/smalltest/groupeval-l1.html > $RESDIR/smalltest/diffgrev-w1.txt ; else echo error with GREV-DIR1; fi +if [ ! -s $RESDIR/smalltest/diffgrev-w1.txt ]; then echo error with GREV-DIR2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupEval -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" --directory $RESDIR/smalltest > $RESDIR/groupeval-w2.html +if [ -s $RESDIR/groupeval-w2.html ]; then diff $RESDIR/groupeval-w1.html $RESDIR/groupeval-w2.html ; else echo error with GREV-DIR3; fi + +#------------------- +echo "\t-o <F>, --output <F>" + +java -cp $CP fr.inrialpes.exmo.align.cli.GroupEval -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest -o $RESDIR/groupeval-o1.html +if [ -s $RESDIR/groupeval-o1.html ]; then diff $RESDIR/groupeval-o1.html $RESDIR/groupeval-w1.html ; else echo error with GREV-OUT1; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupEval -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest --output $RESDIR/groupeval-o2.html +if [ -s $RESDIR/groupeval-o2.html ]; then diff $RESDIR/groupeval-o1.html $RESDIR/groupeval-o2.html ; else echo error with GREV-OUT3; fi + +#------------------- +echo "\t-f,--format <MEAS>" + +java -cp $CP fr.inrialpes.exmo.align.cli.GroupEval -f f -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest > $RESDIR/groupeval-f1.html +if [ -s $RESDIR/groupeval-f1.html ]; then diff $RESDIR/groupeval-w1.html $RESDIR/groupeval-f1.html > $RESDIR/smalltest/diffgrev-f1.txt ; else echo error with GREV-FORM1; fi +if [ ! -s $RESDIR/smalltest/diffgrev-f1.txt ]; then echo error with GREV-FORM2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupEval --format f -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest > $RESDIR/groupeval-f2.html +if [ -s $RESDIR/groupeval-f2.html ]; then diff $RESDIR/groupeval-f1.html $RESDIR/groupeval-f2.html ; else echo error with GREV-FORM3; fi + +#------------------- +echo "\t-c,--color (<COLOR>)" + +java -cp $CP fr.inrialpes.exmo.align.cli.GroupEval -c -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest > $RESDIR/groupeval-c1.html +if [ -s $RESDIR/groupeval-c1.html ]; then diff $RESDIR/groupeval-w1.html $RESDIR/groupeval-c1.html > $RESDIR/smalltest/diffgrev-c1.txt ; else echo error with GREV-COL1; fi +if [ ! -s $RESDIR/smalltest/diffgrev-c1.txt ]; then echo error with GREV-COL2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupEval --color -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest > $RESDIR/groupeval-c2.html +if [ -s $RESDIR/groupeval-c2.html ]; then diff $RESDIR/groupeval-c1.html $RESDIR/groupeval-c2.html ; else echo error with GREV-COL3; fi + +#------------------- +echo "\t-r,--reference <FILE>" +java -cp $CP fr.inrialpes.exmo.align.cli.GroupEval -r lev1.rdf -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest -o $RESDIR/groupeval-r1.html +if [ -s $RESDIR/groupeval-r1.html ]; then diff $RESDIR/groupeval-w1.html $RESDIR/groupeval-r1.html > $RESDIR/smalltest/diffgrev-r1.txt ; else echo error with GREV-REF1; fi +if [ ! -s $RESDIR/smalltest/diffgrev-r1.txt ]; then echo error with GREV-REF2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupEval --reference lev1.rdf -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest -o $RESDIR/groupeval-r2.html +if [ -s $RESDIR/groupeval-r2.html ]; then diff $RESDIR/groupeval-r1.html $RESDIR/groupeval-r2.html ; else echo error with GREV-REF3; fi + +#------------------- +echo "\t-t,--type <TYPE> Output TYPE (html|xml|tex|ascii|triangle" +java -cp $CP fr.inrialpes.exmo.align.cli.GroupEval -t triangle -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest -o $RESDIR/groupeval-ttr1.tex +if [ -s $RESDIR/groupeval-ttr1.tex ]; then diff $RESDIR/groupeval-w1.html $RESDIR/groupeval-ttr1.tex > $RESDIR/smalltest/diffgrev-t1.txt ; else echo error with GREV-TYP1; fi +if [ ! -s $RESDIR/smalltest/diffgrev-t1.txt ]; then echo error with GREV-TYP2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupEval --type triangle -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest -o $RESDIR/groupeval-ttr2.tex +if [ -s $RESDIR/groupeval-ttr2.tex ]; then diff $RESDIR/groupeval-ttr1.tex $RESDIR/groupeval-ttr2.tex ; else echo error with GREV-TYP3; fi + +#------------------- +echo "\t-Dn=v" +echo "\t(same as Procalign; useless: no parameters involved so far)" + +#------------------- +echo "\t-P,--params <FILE>" +echo "\t(same as Procalign; useless: no parameters involved so far)" + +######################################################################## +# WGroupEval +######################################################################## + +echo "\t\t *** Testing WGroupEval ***" + +#------------------- +echo "\t-z, -zzz" + +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval -z &> $RESDIR/zerr.txt +grep "Unrecognized option: -z" $RESDIR/zerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with WGREV-ERR1; fi +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval --zzz &> $RESDIR/zzzerr.txt +grep "Unrecognized option: --zzz" $RESDIR/zzzerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with WGREV-ERR2; fi + +#------------------- +echo "\t-h, --help" + +java -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval -h &> $RESDIR/wgrev-h.txt +java -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval --help &> $RESDIR/wgrev-help.txt +if [ -s $RESDIR/wgrev-h.txt ]; then diff $RESDIR/wgrev-h.txt $RESDIR/wgrev-help.txt; else echo error with WGREV-HELP; fi + +#------------------- +echo "\t-l,--list <FILE>" + +cd $RESDIR/smalltest +java -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval -l "refalign,lev1,streq1" > wgrev-l1.html +if [ ! -s wgrev-l1.html ]; then echo error with WGREV-LIST1; fi +java -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval --list "refalign,lev1,streq1" > wgrev-l2.html +if [ -s wgrev-l2.html ]; then diff wgrev-l1.html wgrev-l2.html ; else echo error with WGREV-LIST2; fi +cd $CWD + +#------------------- +echo "\t-w,--directory <DIR>" + +java -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest > $RESDIR/wgrev-w1.html +if [ -s $RESDIR/wgrev-w1.html ]; then diff $RESDIR/wgrev-w1.html $RESDIR/smalltest/wgrev-l1.html > $RESDIR/smalltest/diffgrev-w1.txt ; else echo error with WGREV-DIR1; fi +if [ ! -s $RESDIR/smalltest/diffgrev-w1.txt ]; then echo error with WGREV-DIR2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" --directory $RESDIR/smalltest > $RESDIR/wgrev-w2.html +if [ -s $RESDIR/wgrev-w2.html ]; then diff $RESDIR/wgrev-w1.html $RESDIR/wgrev-w2.html ; else echo error with WGREV-DIR3; fi + +#------------------- +echo "\t-o <F>, --output <F>" + +java -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest -o $RESDIR/wgrev-o1.html +if [ -s $RESDIR/wgrev-o1.html ]; then diff $RESDIR/wgrev-o1.html $RESDIR/wgrev-w1.html ; else echo error with WGREV-OUT1; fi +java -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest --output $RESDIR/wgrev-o2.html +if [ -s $RESDIR/wgrev-o2.html ]; then diff $RESDIR/wgrev-o1.html $RESDIR/wgrev-o2.html ; else echo error with WGREV-OUT3; fi + +#------------------- +echo "\t-f,--format <MEAS>" + +java -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval -f f -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest > $RESDIR/wgrev-f1.html +if [ -s $RESDIR/wgrev-f1.html ]; then diff $RESDIR/wgrev-w1.html $RESDIR/wgrev-f1.html > $RESDIR/smalltest/diffgrev-f1.txt ; else echo error with WGREV-FORM1; fi +if [ ! -s $RESDIR/smalltest/diffgrev-f1.txt ]; then echo error with WGREV-FORM2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval --format f -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest > $RESDIR/wgrev-f2.html +if [ -s $RESDIR/wgrev-f2.html ]; then diff $RESDIR/wgrev-f1.html $RESDIR/wgrev-f2.html ; else echo error with WGREV-FORM3; fi + +#------------------- +echo "\t-c,--color (<COLOR>)" + +java -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval -c -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest > $RESDIR/wgrev-c1.html +if [ -s $RESDIR/wgrev-c1.html ]; then diff $RESDIR/wgrev-w1.html $RESDIR/wgrev-c1.html > $RESDIR/smalltest/diffgrev-c1.txt ; else echo error with WGREV-COL1; fi +if [ ! -s $RESDIR/smalltest/diffgrev-c1.txt ]; then echo error with WGREV-COL2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval --color -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest > $RESDIR/wgrev-c2.html +if [ -s $RESDIR/wgrev-c2.html ]; then diff $RESDIR/wgrev-c1.html $RESDIR/wgrev-c2.html ; else echo error with WGREV-COL3; fi + +#------------------- +echo "\t-r,--reference <FILE>" +java -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval -r lev1.rdf -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest -o $RESDIR/wgrev-r1.html +if [ -s $RESDIR/wgrev-r1.html ]; then diff $RESDIR/wgrev-w1.html $RESDIR/wgrev-r1.html > $RESDIR/smalltest/diffgrev-r1.txt ; else echo error with WGREV-REF1; fi +if [ ! -s $RESDIR/smalltest/diffgrev-r1.txt ]; then echo error with WGREV-REF2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval --reference lev1.rdf -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest -o $RESDIR/wgrev-r2.html +if [ -s $RESDIR/wgrev-r2.html ]; then diff $RESDIR/wgrev-r1.html $RESDIR/wgrev-r2.html ; else echo error with WGREV-REF3; fi + +#------------------- +echo "\t-t,--type <TYPE> Output TYPE (html|xml|tex|ascii|triangle)" +java -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval -t triangle -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest -o $RESDIR/wgrev-ttr1.tex +if [ -s $RESDIR/wgrev-ttr1.tex ]; then diff $RESDIR/wgrev-w1.html $RESDIR/wgrev-ttr1.tex > $RESDIR/smalltest/diffgrev-t1.txt ; else echo error with WGREV-TYP1; fi +if [ ! -s $RESDIR/smalltest/diffgrev-t1.txt ]; then echo error with WGREV-TYP2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.WGroupEval --type triangle -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest -o $RESDIR/wgrev-ttr2.tex +if [ -s $RESDIR/wgrev-ttr2.tex ]; then diff $RESDIR/wgrev-ttr1.tex $RESDIR/wgrev-ttr2.tex ; else echo error with WGREV-TYP3; fi + +#------------------- +echo "\t-Dn=v" +echo "\t(same as Procalign; useless: no parameters involved so far)" + +#------------------- +echo "\t-P,--params <FILE>" +echo "\t(same as Procalign; useless: no parameters involved so far)" + +######################################################################## +# ExtGroupEval +######################################################################## + +echo "\t\t *** Testing ExtGroupEval ***" + +#------------------- +echo "\t-z, -zzz" + +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval -z &> $RESDIR/zerr.txt +grep "Unrecognized option: -z" $RESDIR/zerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with EXTGRPEV-ERR1; fi +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval --zzz &> $RESDIR/zzzerr.txt +grep "Unrecognized option: --zzz" $RESDIR/zzzerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with EXTGRPEV-ERR2; fi + +#------------------- +echo "\t-h, --help" + +java -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval -h &> $RESDIR/extgrpev-h.txt +java -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval --help &> $RESDIR/extgrpev-help.txt +if [ -s $RESDIR/extgrpev-h.txt ]; then diff $RESDIR/extgrpev-h.txt $RESDIR/extgrpev-help.txt; else echo error with EXTGRPEV-HELP; fi + +#------------------- +echo "\t-l,--list <FILE>" + +cd $RESDIR/smalltest +java -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval -l "refalign,lev1,streq1" > extgrpev-l1.html +if [ ! -s extgrpev-l1.html ]; then echo error with EXTGRPEV-LIST1; fi +java -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval --list "refalign,lev1,streq1" > extgrpev-l2.html +if [ -s extgrpev-l2.html ]; then diff extgrpev-l1.html extgrpev-l2.html ; else echo error with EXTGRPEV-LIST2; fi +cd $CWD + +#------------------- +echo "\t-w,--directory <DIR>" + +java -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest > $RESDIR/extgrpev-w1.html +if [ -s $RESDIR/extgrpev-w1.html ]; then diff $RESDIR/extgrpev-w1.html $RESDIR/smalltest/extgrpev-l1.html > $RESDIR/smalltest/diffgrev-w1.txt ; else echo error with EXTGRPEV-DIR1; fi +if [ ! -s $RESDIR/smalltest/diffgrev-w1.txt ]; then echo error with EXTGRPEV-DIR2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" --directory $RESDIR/smalltest > $RESDIR/extgrpev-w2.html +if [ -s $RESDIR/extgrpev-w2.html ]; then diff $RESDIR/extgrpev-w1.html $RESDIR/extgrpev-w2.html ; else echo error with EXTGRPEV-DIR3; fi + +#------------------- +echo "\t-o <F>, --output <F>" + +java -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest -o $RESDIR/extgrpev-o1.html +if [ -s $RESDIR/extgrpev-o1.html ]; then diff $RESDIR/extgrpev-o1.html $RESDIR/extgrpev-w1.html ; else echo error with EXTGRPEV-OUT1; fi +java -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest --output $RESDIR/extgrpev-o2.html +if [ -s $RESDIR/extgrpev-o2.html ]; then diff $RESDIR/extgrpev-o1.html $RESDIR/extgrpev-o2.html ; else echo error with EXTGRPEV-OUT3; fi + +#------------------- +echo "\t-f,--format <MEAS>" + +java -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval -f f -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest > $RESDIR/extgrpev-f1.html +if [ -s $RESDIR/extgrpev-f1.html ]; then diff $RESDIR/extgrpev-w1.html $RESDIR/extgrpev-f1.html > $RESDIR/smalltest/diffgrev-f1.txt ; else echo error with EXTGRPEV-FORM1; fi +if [ ! -s $RESDIR/smalltest/diffgrev-f1.txt ]; then echo error with EXTGRPEV-FORM2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval --format f -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest > $RESDIR/extgrpev-f2.html +if [ -s $RESDIR/extgrpev-f2.html ]; then diff $RESDIR/extgrpev-f1.html $RESDIR/extgrpev-f2.html ; else echo error with EXTGRPEV-FORM3; fi + +#------------------- +echo "\t-c,--color (<COLOR>)" + +java -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval -c -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest > $RESDIR/extgrpev-c1.html +if [ -s $RESDIR/extgrpev-c1.html ]; then diff $RESDIR/extgrpev-w1.html $RESDIR/extgrpev-c1.html > $RESDIR/smalltest/diffgrev-c1.txt ; else echo error with EXTGRPEV-COL1; fi +if [ ! -s $RESDIR/smalltest/diffgrev-c1.txt ]; then echo error with EXTGRPEV-COL2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval --color -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest > $RESDIR/extgrpev-c2.html +if [ -s $RESDIR/extgrpev-c2.html ]; then diff $RESDIR/extgrpev-c1.html $RESDIR/extgrpev-c2.html ; else echo error with EXTGRPEV-COL3; fi + +#------------------- +echo "\t-r,--reference <FILE>" +java -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval -r lev1.rdf -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest -o $RESDIR/extgrpev-r1.html +if [ -s $RESDIR/extgrpev-r1.html ]; then diff $RESDIR/extgrpev-o1.html $RESDIR/extgrpev-r1.html > $RESDIR/smalltest/diffgrev-r1.txt ; else echo error with EXTGRPEV-REF1; fi +if [ ! -s $RESDIR/smalltest/diffgrev-r1.txt ]; then echo error with EXTGRPEV-REF2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval --reference lev1.rdf -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest -o $RESDIR/extgrpev-r2.html +if [ -s $RESDIR/extgrpev-r2.html ]; then diff $RESDIR/extgrpev-r1.html $RESDIR/extgrpev-r2.html ; else echo error with EXTGRPEV-REF3; fi + +#------------------- +echo "\t-t,--type <TYPE> Output TYPE (html|xml|tex|ascii|triangle)" +java -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval -t triangle -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest -o $RESDIR/extgrpev-ttr1.tex +if [ -s $RESDIR/extgrpev-ttr1.tex ]; then diff $RESDIR/extgrpev-o1.html $RESDIR/extgrpev-ttr1.tex > $RESDIR/smalltest/diffgrev-t1.txt ; else echo error with EXTGRPEV-TYP1; fi +# Useless: only html is available at the moment, so the diff is empty +#if [ ! -s $RESDIR/smalltest/diffgrev-t1.txt ]; then echo error with EXTGRPEV-TYP2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.ExtGroupEval --type triangle -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" -w $RESDIR/smalltest -o $RESDIR/extgrpev-ttr2.tex +if [ -s $RESDIR/extgrpev-ttr2.tex ]; then diff $RESDIR/extgrpev-ttr1.tex $RESDIR/extgrpev-ttr2.tex ; else echo error with EXTGRPEV-TYP3; fi + +#------------------- +echo "\t-Dn=v" +echo "\t(same as Procalign; useless: no parameters involved so far)" + +#------------------- +echo "\t-P,--params <FILE>" +echo "\t(same as Procalign; useless: no parameters involved so far)" + +######################################################################## +# GroupOutput +######################################################################## + +echo "\t\t *** Testing GroupOutput ***" + +#------------------- +echo "\t-z, -zzz" + +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput -z &> $RESDIR/zerr.txt +grep "Unrecognized option: -z" $RESDIR/zerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with GROUT-ERR1; fi +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput --zzz &> $RESDIR/zzzerr.txt +grep "Unrecognized option: --zzz" $RESDIR/zzzerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with GROUT-ERR2; fi + +#------------------- +echo "\t-h, --help" +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput -h &> $RESDIR/grout-h.txt +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput --help &> $RESDIR/grout-help.txt +if [ -s $RESDIR/grout-h.txt ]; then diff $RESDIR/grout-h.txt $RESDIR/grout-help.txt; else echo error with $RESDIR/grout-h.txt; fi +diff $RESDIR/grout-h.txt $RESDIR/grout-help.txt + +#------------------- +echo "\t-l,--list <FILE>" + +cd $RESDIR/smalltest +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" > grout-l1.tex +if [ ! -s grout-l1.tex ]; then echo error with GROUT-LIST1; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput --list "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" > grout-l2.tex +if [ -s grout-l2.tex ]; then diff grout-l1.tex grout-l2.tex ; else echo error with GROUT-LIST2; fi +cd $CWD + +#------------------- +echo "\t-o <F>, --output <F>" + +cd $RESDIR/smalltest +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput -l "refalign,edna1,streq1,lev1" -o $RESDIR/grout-o1.tex +if [ ! -s $RESDIR/grout-o1.tex ]; then echo error with GROUT-OUT1; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput -l "refalign,edna1,streq1,lev1" --output $RESDIR/grout-o2.tex +if [ -s $RESDIR/grout-o2.tex ]; then diff $RESDIR/grout-o1.tex $RESDIR/grout-o2.tex ; else echo error with GROUT-OUT3; fi +cd $CWD + +#------------------- +echo "\t-w,--directory <DIR>" + +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput -l "refalign,edna1,streq1,lev1" -w $RESDIR/smalltest -o $RESDIR/grout-w1.tex +if [ -s $RESDIR/grout-w1.tex ]; then diff $RESDIR/grout-o1.tex $RESDIR/grout-w1.tex ; else echo error with GROUT-DIR1; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput -l "refalign,edna1,streq1,lev1" --directory $RESDIR/smalltest --output $RESDIR/grout-w2.tex +if [ -s $RESDIR/grout-w2.tex ]; then diff $RESDIR/grout-o1.tex $RESDIR/grout-o2.tex ; else echo error with GROUT-DIR3; fi + +#------------------- +echo "\t-v,--value" + +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput -l "refalign,edna1,streq1,lev1" -v -w $RESDIR/smalltest -o $RESDIR/grout-v1.tex +if [ -s $RESDIR/grout-v1.tex ]; then diff $RESDIR/grout-o1.tex $RESDIR/grout-v1.tex > $RESDIR/smalltest/diffgrout-v1.txt; else echo error with GROUT-VAL1; fi +if [ ! -s $RESDIR/smalltest/diffgrout-v1.txt ]; then echo error with GROUT-VAL2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput -l "refalign,edna1,streq1,lev1" --values --directory $RESDIR/smalltest --output $RESDIR/grout-v2.tex +if [ -s $RESDIR/grout-v2.tex ]; then diff $RESDIR/grout-v1.tex $RESDIR/grout-v2.tex ; else echo error with GROUT-VAL3; fi + +#------------------- +echo "\t-e,--labels" + +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput -l "refalign,edna1,streq1,lev1" -e -w $RESDIR/smalltest -o $RESDIR/grout-e1.tex +if [ -s $RESDIR/grout-e1.tex ]; then diff $RESDIR/grout-o1.tex $RESDIR/grout-e1.tex > $RESDIR/smalltest/diffgrout-e1.txt; else echo error with GROUT-LAB1; fi +if [ ! -s $RESDIR/smalltest/diffgrout-e1.txt ]; then echo error with GROUT-LAB2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput -l "refalign,edna1,streq1,lev1" --labels --directory $RESDIR/smalltest --output $RESDIR/grout-e2.tex +if [ -s $RESDIR/grout-e2.tex ]; then diff $RESDIR/grout-e1.tex $RESDIR/grout-e2.tex ; else echo error with GROUT-LAB3; fi + +#------------------- +echo "\t-c,--color (<COLOR>)" + +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput -c pink -l "refalign,edna1,streq1,lev1" -w $RESDIR/smalltest > $RESDIR/grout-c1.tex +if [ -s $RESDIR/grout-c1.tex ]; then diff $RESDIR/grout-o1.tex $RESDIR/grout-c1.tex > $RESDIR/smalltest/diffgrev-c1.txt ; else echo error with GROUT-COL1; fi +if [ ! -s $RESDIR/smalltest/diffgrev-c1.txt ]; then echo error with GROUT-COL2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput --color pink -l "refalign,edna1,streq1,lev1" -w $RESDIR/smalltest > $RESDIR/grout-c2.tex +if [ -s $RESDIR/grout-c2.tex ]; then diff $RESDIR/grout-c1.tex $RESDIR/grout-c2.tex ; else echo error with GROUT-COL3; fi + +#------------------- +echo "\t-f,--format <MEAS>" + +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput -f r -l "refalign,edna1,streq1,lev1" -w $RESDIR/smalltest > $RESDIR/grout-f1.tex +if [ -s $RESDIR/grout-f1.tex ]; then diff $RESDIR/grout-w1.tex $RESDIR/grout-f1.tex > $RESDIR/smalltest/diffgrev-f1.txt ; else echo error with GROUT-FORM1; fi +# These are always the same values, so no change with these parameters... +#if [ ! -s $RESDIR/smalltest/diffgrev-f1.txt ]; then echo error with GROUT-FORM2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput --format r -l "refalign,edna1,streq1,lev1" -w $RESDIR/smalltest > $RESDIR/grout-f2.tex +if [ -s $RESDIR/grout-f2.tex ]; then diff $RESDIR/grout-f1.tex $RESDIR/grout-f2.tex ; else echo error with GROUT-FORM3; fi + +#------------------- +echo "\t-t,--type <TYPE> Output TYPE (tex|html) / only tex available in fact" + +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput -t html -l "refalign,edna1,streq1,lev1" -w $RESDIR/smalltest -o $RESDIR/grout-t1.tex +# The results are necessary empty with html +#if [ -s $RESDIR/grout-t1.tex ]; then diff $RESDIR/grout-o1.tex $RESDIR/grout-t1.tex > $RESDIR/smalltest/diffgrev-t1.txt ; else echo error with GROUT-TYP1; fi +#if [ ! -s $RESDIR/smalltest/diffgrev-t1.txt ]; then echo error with GROUT-TYP2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GroupOutput --type html -l "refalign,edna1,streq1,lev1" -w $RESDIR/smalltest -o $RESDIR/grout-t2.tex +#if [ -s $RESDIR/grout-t2.tex ]; then diff $RESDIR/grout-t1.tex $RESDIR/grout-t2.tex ; else echo error with GROUT-TYP3; fi + +#------------------- +echo "\t-Dn=v" +echo "\t(same as Procalign; useless: no parameters involved so far)" + +#------------------- +echo "\t-P,--params <FILE>" +echo "\t(same as Procalign; useless: no parameters involved so far)" + +######################################################################## +# GenPlot +######################################################################## + +echo "\t\t *** Testing GenPlot ***" + +#------------------- +echo "\t-h, --help" +java -cp $CP fr.inrialpes.exmo.align.cli.GenPlot -h &> $RESDIR/genplot-h.txt +java -cp $CP fr.inrialpes.exmo.align.cli.GenPlot --help &> $RESDIR/genplot-help.txt +if [ -s $RESDIR/genplot-h.txt ]; then diff $RESDIR/genplot-h.txt $RESDIR/genplot-help.txt; else echo error with $RESDIR/genplot-h.txt; fi + +#------------------- +echo "\t-z,--zzz" + +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.GenPlot -z &> $RESDIR/zerr.txt +grep "Unrecognized option: -z" $RESDIR/zerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with GENPLOT-ERR1; fi +java -Dlog.level=INFO -cp $CP fr.inrialpes.exmo.align.cli.GenPlot --zzz &> $RESDIR/zzzerr.txt +grep "Unrecognized option: --zzz" $RESDIR/zzzerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with GENPLOT-ERR2; fi + +#------------------- +echo "\t-l,--list <FILE>" + +cd $RESDIR/smalltest +java -cp $CP fr.inrialpes.exmo.align.cli.GenPlot -l "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" > genplot-l1.tex +if [ ! -s genplot-l1.tex ]; then echo error with GENPLOT-LIST1; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GenPlot --list "refalign,edna1,streq1,streq1n,streq1x,streq2,streq2n,streq2x,lev1" > genplot-l2.tex +if [ -s genplot-l2.tex ]; then diff genplot-l1.tex genplot-l2.tex ; else echo error with GENPLOT-LIST2; fi +cd $CWD + +#------------------- +echo "\t-o <F>, --output <F>" + +cd $RESDIR/smalltest +java -cp $CP fr.inrialpes.exmo.align.cli.GenPlot -l "refalign,edna1,streq1,lev1" -o $RESDIR/genplot-o1.tex +if [ ! -s $RESDIR/genplot-o1.tex ]; then echo error with GENPLOT-OUT1; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GenPlot -l "refalign,edna1,streq1,lev1" --output $RESDIR/genplot-o2.tex +if [ -s $RESDIR/genplot-o2.tex ]; then diff $RESDIR/genplot-o1.tex $RESDIR/genplot-o2.tex ; else echo error with GENPLOT-OUT3; fi +cd $CWD + +#------------------- +echo "\t-w,--directory <DIR>" + +java -cp $CP fr.inrialpes.exmo.align.cli.GenPlot -l "refalign,edna1,streq1,lev1" -w $RESDIR/smalltest -o $RESDIR/genplot-w1.tex +if [ -s $RESDIR/genplot-w1.tex ]; then diff $RESDIR/genplot-o1.tex $RESDIR/genplot-w1.tex ; else echo error with GENPLOT-DIR1; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GenPlot -l "refalign,edna1,streq1,lev1" --directory $RESDIR/smalltest --output $RESDIR/genplot-w2.tex +if [ -s $RESDIR/genplot-w2.tex ]; then diff $RESDIR/genplot-o1.tex $RESDIR/genplot-o2.tex ; else echo error with GENPLOT-DIR3; fi + +#------------------- +echo "\t-e,--evaluator <CLASS>" + +mv lev1.table $RESDIR/lev1-init.table +java -cp $CP fr.inrialpes.exmo.align.cli.GenPlot -e fr.inrialpes.exmo.align.impl.eval.WeightedPRecEvaluator -l "refalign,edna1,streq1,lev1" -w $RESDIR/smalltest -o $RESDIR/genplot-e1.tex +if [ -s lev1.table ]; then diff $RESDIR/lev1-init.table lev1.table > $RESDIR/smalltest/diffgrev-e1.txt; else echo error with GENPLOT-EVA1; fi +echo "--> These are the same values for both evaluators, so the error" +if [ ! -s $RESDIR/smalltest/diffgrev-e1.txt ]; then echo error with GENPLOT-EVA2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GenPlot --evaluator fr.inrialpes.exmo.align.impl.eval.WeightedPRecEvaluator -l "refalign,edna1,streq1,lev1" -w $RESDIR/smalltest -o $RESDIR/genplot-e2.tex +if [ -s $RESDIR/genplot-e2.tex ]; then diff $RESDIR/genplot-e1.tex $RESDIR/genplot-e2.tex ; else echo error with GENPLOT-EVA3; fi + +#------------------- +echo "\t-g,--grapher <CLASS> " + +java -cp $CP fr.inrialpes.exmo.align.cli.GenPlot -g fr.inrialpes.exmo.align.impl.eval.ROCCurveEvaluator -l "refalign,edna1,streq1,lev1" -w $RESDIR/smalltest -o $RESDIR/genplot-g1.tex +if [ -s $RESDIR/genplot-g1.tex ]; then diff $RESDIR/genplot-o1.tex $RESDIR/genplot-g1.tex > $RESDIR/smalltest/diffgrev-g1.txt ; else echo error with GENPLOT-GRA1; fi +if [ ! -s $RESDIR/smalltest/diffgrev-g1.txt ]; then echo error with GENPLOT-GRA2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GenPlot --grapher fr.inrialpes.exmo.align.impl.eval.ROCCurveEvaluator -l "refalign,edna1,streq1,lev1" -w $RESDIR/smalltest -o $RESDIR/genplot-g2.tex +if [ -s $RESDIR/genplot-g2.tex ]; then diff $RESDIR/genplot-g1.tex $RESDIR/genplot-g2.tex ; else echo error with GENPLOT-GRA3; fi + +#------------------- +echo "\t-t,--type <TYPE> Output TYPE (tsv|tex|html(|xml))" + +java -cp $CP fr.inrialpes.exmo.align.cli.GenPlot -t html -l "refalign,edna1,streq1,lev1" -w $RESDIR/smalltest -o $RESDIR/genplot-t1.html +if [ -s $RESDIR/genplot-t1.html ]; then diff $RESDIR/genplot-o1.tex $RESDIR/genplot-t1.html > $RESDIR/smalltest/diffgrev-t1.txt ; else echo error with GENPLOT-TYP1; fi +if [ ! -s $RESDIR/smalltest/diffgrev-t1.txt ]; then echo error with GENPLOT-TYP2; fi +java -cp $CP fr.inrialpes.exmo.align.cli.GenPlot --type html -l "refalign,edna1,streq1,lev1" -w $RESDIR/smalltest -o $RESDIR/genplot-t2.html +if [ -s $RESDIR/genplot-t2.html ]; then diff $RESDIR/genplot-t1.html $RESDIR/genplot-t2.html ; else echo error with GENPLOT-TYP3; fi + +#------------------- +echo "\t-Dn=v" +echo "\t(same as Procalign)" + +#------------------- +echo "\t-P,--params <FILE>" +echo "\t(same as Procalign)" + + +######################################################################## +# AlignmentService +######################################################################## + +echo "\t\t *** Testing AlignmentService ***" +echo "\tTHIS WILL ONLY WORK WITH A RUNNING MYSQL SET FOR THE SERVER" +echo "\tTHIS IS ALSO VERY SENSITIVE TO TIMEOUTS" + +#------------------- +echo "\t-z, -zzz" + +java -Dlog.level=INFO -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService -z &> $RESDIR/zerr.txt +grep "Unrecognized option: -z" $RESDIR/zerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-ERR1; fi +java -Dlog.level=INFO -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService --zzz &> $RESDIR/zzzerr.txt +grep "Unrecognized option: --zzz" $RESDIR/zzzerr.txt > $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-ERR2; fi + +#------------------- +echo "\t-h, --help" +java -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService -h &> $RESDIR/aser-h.txt +java -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService --help &> $RESDIR/aser-help.txt +if [ -s $RESDIR/aser-h.txt ]; then diff $RESDIR/aser-h.txt $RESDIR/aser-help.txt; else echo error with ASERV-HELP1; fi + +#------------------- +echo "\t-o <F>, --output <F>" +java -Dlog.level=DEBUG -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService -o $RESDIR/aserv.log & +sleep 15 +if [ -s $RESDIR/aserv.log ]; then grep "Alignment server running" $RESDIR/aserv.log > $RESDIR/oerr.txt; else echo error with ASERV-OUT1; fi +if [ ! -s $RESDIR/oerr.txt ]; then echo error with ASERV-OUT2; fi +kill -TERM $! +echo > $RESDIR/aserv.log +java -Dlog.level=DEBUG -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService --output $RESDIR/aserv2.log & +sleep 15 +if [ -s $RESDIR/aserv2.log ]; then grep "Alignment server running" $RESDIR/aserv2.log > $RESDIR/oerr.txt; else echo error with ASERV-OUT3; fi +if [ ! -s $RESDIR/oerr.txt ]; then echo error with ASERV-OUT4; fi +kill -TERM $! + +#------------------- +echo "\t-i,--impl <CLASS>" +java -Dlog.level=WARN -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService -i fr.inrialpes.exmo.align.cli.GenPlot &> $Resdir/err.txt & +sleep 5; +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-IMPL1; else grep "Cannot create service for fr.inrialpes.exmo.align.cli.GenPlot" $RESDIR/err.txt > $RESDIR/ierr.txt; fi +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-IMPL2; fi +kill -TERM $! +java -Dlog.level=WARN -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService --impl fr.inrialpes.exmo.align.cli.GenPlot2 &> $Resdir/err.txt & +sleep 5; +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-IMPL3; else grep "Cannot create service for fr.inrialpes.exmo.align.cli.GenPlot2" $RESDIR/err.txt > $RESDIR/ierr.txt; fi +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-IMPL4; fi +kill -TERM $! + +#------------------- +echo "\t-A,--jade <PORT>" +java -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService -A 5555 &> $RESDIR/err.txt & +sleep 20; +if [ -s $RESDIR/err.txt ]; then grep "is ready" $RESDIR/err.txt > $RESDIR/jerr.txt; else echo error with ASERV-JADE1; fi +if [ ! -s $RESDIR/jerr.txt ]; then echo error with ASERV-JADE2; fi +kill -TERM $! +java -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService --jade 5555 &> $RESDIR/err.txt & +sleep 20; +if [ -s $RESDIR/err.txt ]; then grep "is ready" $RESDIR/err.txt > $RESDIR/jerr.txt; else echo error with ASERV-JADE3; fi +if [ ! -s $RESDIR/jerr.txt ]; then echo error with ASERV-JADE4; fi +kill -TERM $! +/bin/rm -f $RESDIR/err.txt $RESDIR/jerr.txt + +#------------------- +echo "\t-W,--wsdl <PORT>" +java -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService -W 5555 &> $RESDIR/err.txt & +sleep 5; +kill -TERM $! +if [ -s $RESDIR/err.txt ]; then echo error with ASERV-WSDL1; fi +java -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService --wsdl 5555 &> $RESDIR/err.txt & +sleep 5; +kill -TERM $! +if [ -s $RESDIR/err.txt ]; then echo error with ASERV-WSDL2; fi + +#------------------- +echo "\t-H,--http <PORT>" +java -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService -H 5555 &> $RESDIR/err.txt & +sleep 5; +kill -TERM $! +if [ -s $RESDIR/err.txt ]; then echo error with ASERV-HTTP1; fi +java -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService --http 5555 &> $Resdir/err.txt & +sleep 5; +kill -TERM $! +if [ -s $RESDIR/err.txt ]; then echo error with ASERV-HTTP2; fi + +#------------------- +echo "\t-X,--jxta <PORT>" +java -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService -X 5555 &> $RESDIR/err.txt & +sleep 5; +kill -TERM $! +if [ -s $RESDIR/err.txt ]; then echo error with ASERV-JXTA1; fi +java -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService --jxta 5555 &> $RESDIR/err.txt & +sleep 5; +kill -TERM $! +if [ -s $RESDIR/err.txt ]; then echo error with ASERV-JXTA2; fi + +#------------------- +echo "\t-O,--oyster" +echo "\t\tTO BE DEPRECATED" +#java -cp $CP:lib/oyster/oyster.jar:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService -O &> $RESDIR/err.txt & +#sleep 5; +#if [ -s $RESDIR/err.txt ]; then echo error with ASERV-OYSTER1; fi +#kill -TERM $! +#java -cp $CP:lib/oyster/oyster.jar:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService --oyster &> $RESDIR/err.txt & +#sleep 5; +#if [ -s $RESDIR/err.txt ]; then echo error with ASERV-OYSTER2; fi +#kill -TERM $! + +#------------------- +echo "\t-S,--host <HOSTNAME>" +java -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService -S aserv.inria.fr &> $RESDIR/err.txt & +sleep 5; +kill -TERM $! +if [ -s $RESDIR/err.txt ]; then echo error with ASERV-HOST1; fi +java -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService --host aserv.inria.fr &> $RESDIR/err.txt & +sleep 5; +kill -TERM $! +if [ -s $RESDIR/err.txt ]; then echo error with ASERV-HOST2; fi + +#------------------- +echo "\t-u,--uriprefix <URI>" +java -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService -u http://www.example.org &> $RESDIR/err.txt & +sleep 5; +kill -TERM $! +if [ -s $RESDIR/err.txt ]; then echo error with ASERV-URIP1; fi +java -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService --uriprefix http://www.example.org &> $RESDIR/err.txt & +sleep 5; +kill -TERM $! +if [ -s $RESDIR/err.txt ]; then echo error with ASERV-URIP2; fi + +#------------------- +echo "\t-B,--dbms <DBMS>" +java -Dlog.level=ERROR -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService -B postgres &> $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-DBMS1; else grep "Connection refused." $RESDIR/err.txt > $RESDIR/dberr.txt; fi +if [ ! -s $RESDIR/dberr.txt ]; then echo error with ASERV-DBMS2; fi +java -Dlog.level=ERROR -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService --dbms postgres &> $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-DBMS3; else grep "Connection refused." $RESDIR/err.txt > $RESDIR/dberr.txt; fi +if [ ! -s $RESDIR/dberr.txt ]; then echo error with ASERV-DBMS4; fi + +#------------------- +echo "\t-m,--dbmshost <HOST>" +java -Dlog.level=ERROR -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService -m www.gloubi.boulga &> $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-DBHOST1; else grep "Communications link failure" $RESDIR/err.txt > $RESDIR/dberr.txt; fi +if [ ! -s $RESDIR/dberr.txt ]; then echo error with ASERV-DBHOST2; fi +java -Dlog.level=ERROR -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService --dbmshost www.gloubi.boulga &> $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-DBHOST3; else grep "Communications link failure" $RESDIR/err.txt > $RESDIR/dberr.txt; fi +if [ ! -s $RESDIR/dberr.txt ]; then echo error with ASERV-DBHOST4; fi + +#------------------- +echo "\t-s,--dbmsport <PORT>" +java -Dlog.level=ERROR -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService -s 5555 &> $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-DBPORT1; else grep "Communications link failure" $RESDIR/err.txt > $RESDIR/dberr.txt; fi +if [ ! -s $RESDIR/dberr.txt ]; then echo error with ASERV-DBPORT2; fi +java -Dlog.level=ERROR -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService --dbmsport 5555 &> $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-DBPORT3; else grep "Communications link failure" $RESDIR/err.txt > $RESDIR/dberr.txt; fi +if [ ! -s $RESDIR/dberr.txt ]; then echo error with ASERV-DBPORT4; fi + +#------------------- +echo "\t-b,--dbmsbase <BASE>" +java -Dlog.level=ERROR -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService -b myAlignDB &> $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-DBDB1; else grep "Access denied for user" $RESDIR/err.txt > $RESDIR/dberr.txt; fi +if [ ! -s $RESDIR/dberr.txt ]; then echo error with ASERV-DBDB2; fi +java -Dlog.level=ERROR -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService --dbmsbase myAlignDB &> $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-DBDB3; else grep "Access denied for user" $RESDIR/err.txt > $RESDIR/dberr.txt; fi +if [ ! -s $RESDIR/dberr.txt ]; then echo error with ASERV-DBDB4; fi + +#------------------- +echo "\t-l,--dbmsuser <USER>" +java -Dlog.level=ERROR -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService -l scott &> $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-DBUSR1; else grep "Access denied for user" $RESDIR/err.txt > $RESDIR/dberr.txt; fi +if [ ! -s $RESDIR/dberr.txt ]; then echo error with ASERV-DBUSR2; fi +java -Dlog.level=ERROR -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService --dbmsuser scott &> $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-DBUSR3; else grep "Access denied for user" $RESDIR/err.txt > $RESDIR/dberr.txt; fi +if [ ! -s $RESDIR/dberr.txt ]; then echo error with ASERV-DBUSR4; fi + +#------------------- +echo "\t-p,--dbmspass <PASS>" +java -Dlog.level=ERROR -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService -p tiger &> $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-DBPAS1; else grep "Access denied for user" $RESDIR/err.txt > $RESDIR/dberr.txt; fi +if [ ! -s $RESDIR/dberr.txt ]; then echo error with ASERV-DBPAS2; fi +java -Dlog.level=ERROR -cp $CP:lib/alignsvc.jar fr.inrialpes.exmo.align.service.AlignmentService --dbmspass tiger &> $RESDIR/err.txt +if [ ! -s $RESDIR/err.txt ]; then echo error with ASERV-DBPAS3; else grep "Access denied for user" $RESDIR/err.txt > $RESDIR/dberr.txt; fi +if [ ! -s $RESDIR/dberr.txt ]; then echo error with ASERV-DBPAS4; fi + +#------------------- +echo "\t-Dn=v" +echo "\t(same as Procalign)" + +#------------------- +echo "\t-P,--params <FILE>" +echo "\t(same as Procalign)" + +######################################################################## +echo Evrything is fine + + + + + diff --git a/test/src/EDOALTest.java b/test/src/EDOALTest.java index bf9e55b85e84e585dda494bec85a16ace48fd2de..02a75c3ce81eda903c33518455a6bee0c437c164 100644 --- a/test/src/EDOALTest.java +++ b/test/src/EDOALTest.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2008-2011 + * Copyright (C) INRIA, 2008-2011, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -124,7 +124,8 @@ java -cp ../../lib/procalign.jar fr.inrialpes.exmo.align.cli.ParserPrinter wine2 //assertEquals( wine2, stream.toString() ); } - /* This is round triping wrt converting to URIALignment... */ + /* This is round triping wrt converting to URIALignment... + // Does not work anymore, because now it would try to parse an OMWG file... which goes to loop @Test(expectedExceptions = AlignmentException.class, groups = { "full", "omwg", "raw" }, dependsOnMethods = {"roundTripTest"}) public void anotherRoundTripTest() throws Exception { aparser1.initAlignment( null ); @@ -137,6 +138,6 @@ java -cp ../../lib/procalign.jar fr.inrialpes.exmo.align.cli.ParserPrinter wine2 eal = EDOALAlignment.toEDOALAlignment( al ); // does not work because the ontology cannot be loaded! assertNotNull( eal ); assertEquals( eal.nbCells(), 3 ); - } + } */ } diff --git a/test/src/RendererTest.java b/test/src/RendererTest.java index 80846e4cbd890ecf29572ccf099ab7bb29b5f951..512528b113ea6d34d7a3a46c41516b0654f79ea8 100644 --- a/test/src/RendererTest.java +++ b/test/src/RendererTest.java @@ -166,7 +166,7 @@ public class RendererTest { oalignment.render( renderer ); // test error with alignment writer.flush(); writer.close(); - assertTrue( valueSimilarTo( stream.toString().length(), 17293 ), "Rendered differently: expected "+17293+" but was "+stream.toString().length() ); + assertTrue( valueSimilarTo( stream.toString().length(), 33811 ), "Rendered differently: expected "+33811+" but was "+stream.toString().length() ); } @Test(groups = { "full", "impl", "raw" })