diff --git a/src/fr/inrialpes/exmo/align/cli/CommonCLI.java b/src/fr/inrialpes/exmo/align/cli/CommonCLI.java index be9c8f1e8a8d2628233d3ccd3f950da0a04f5935..ea988f93cde9eed5a65267041286b7a0dff7f54d 100644 --- a/src/fr/inrialpes/exmo/align/cli/CommonCLI.java +++ b/src/fr/inrialpes/exmo/align/cli/CommonCLI.java @@ -35,8 +35,8 @@ 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.Option; import org.apache.commons.cli.Options; -import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.HelpFormatter; @@ -64,11 +64,52 @@ public abstract class CommonCLI { public CommonCLI() { parameters = new Properties(); options = new Options(); + options.addOption( createOption( "h", "help", "Print this page" ) ); + options.addOption( createRequiredOption( "o", "output", "Send output to FILE", "FILE" ) ); + options.addOption( createOptionalOption( "d", "debug", "debug argument is deprecated, use logging instead\nSee http://alignapi.gforge.inria.fr/logging.html", "LEVEL") ); + options.addOption( createRequiredOption( "P", "params", "Read parameters from FILE", "FILE" ) ); + // Special one + Option opt = new Option( "D", "Use value for given property" ); + opt.setArgs(2); + opt.setValueSeparator('='); + opt.setArgName( "NAME=VALUE" ); + options.addOption( opt ); + /* 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' ) ); + */ + } + + protected Option createOption( String name, String longName, String desc ) { + Option opt = new Option( name, desc ); + opt.setLongOpt( longName ); + return opt; + } + + protected Option createRequiredOption( String name, String longName, String desc, String argName ) { + Option opt = createOption( name, longName, desc ); + opt.setArgs( 1 ); + opt.setArgName( argName ); + return opt; + } + + protected Option createOptionalOption( String name, String longName, String desc, String argName ) { + Option opt = createOption( name, longName, desc ); + opt.setOptionalArg( true ); + opt.setArgName( argName ); + return opt; + } + + protected Option createListOption( String name, String longName, String desc, String argName, char sep ) { + Option opt = createOption( name, longName, desc ); + opt.setArgName( argName ); + opt.setValueSeparator( sep ); + opt.setRequired( true ); + opt.setArgs( -2 ); // Nicely undocumented! + return opt; } // This is an example of using the interface diff --git a/src/fr/inrialpes/exmo/align/cli/EvalAlign.java b/src/fr/inrialpes/exmo/align/cli/EvalAlign.java index 7d14b80f6dd5415140ac41e54688ec6db3367e17..774f03342a6244d582415a28f7ea5057e5834908 100644 --- a/src/fr/inrialpes/exmo/align/cli/EvalAlign.java +++ b/src/fr/inrialpes/exmo/align/cli/EvalAlign.java @@ -85,7 +85,8 @@ public class EvalAlign extends CommonCLI { public EvalAlign() { super(); - options.addOption( OptionBuilder.withLongOpt( "impl" ).hasArg().withType(Class.class).withDescription( "Use the given CLASS for evaluator" ).withArgName("CLASS").create( 'i' ) ); + options.addOption( createRequiredOption( "i", "impl", "Use the given CLASS for evaluator", "CLASS" ) ); + // .withType(Class.class) } public static void main(String[] args) { @@ -135,15 +136,15 @@ public class EvalAlign extends CommonCLI { ex.printStackTrace(); } - boolean totry = true; // 2013: This should not be necessary anymore + boolean totry = true; // JE2013: This should not be necessary anymore while ( totry ) { totry = false; if ( evaluatorClass != null ) { // Create evaluator object try { Class[] cparams = { Alignment.class, Alignment.class }; - Constructor evaluatorConstructor = evaluatorClass.getConstructor(cparams); - Object [] mparams = {(Object)align1, (Object)align2}; + Constructor<?> evaluatorConstructor = evaluatorClass.getConstructor(cparams); + Object [] mparams = { align1, align2}; eval = (Evaluator)evaluatorConstructor.newInstance(mparams); } catch (InstantiationException ex) { logger.debug( "IGNORED Exception", ex ); diff --git a/src/fr/inrialpes/exmo/align/cli/ExtGroupEval.java b/src/fr/inrialpes/exmo/align/cli/ExtGroupEval.java index 5547dfdffff78507a37a7e12705b07c25dcf45c2..eec29b785eb0e31e190bbb66a3b6eaa1a0453da5 100644 --- a/src/fr/inrialpes/exmo/align/cli/ExtGroupEval.java +++ b/src/fr/inrialpes/exmo/align/cli/ExtGroupEval.java @@ -56,7 +56,6 @@ 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 @@ -108,6 +107,15 @@ public class ExtGroupEval extends CommonCLI { public ExtGroupEval() { super(); + options.addOption( createListOption( "l", "list", "List of FILEs to be included in the results (required)", "FILE", ',' ) ); + options.addOption( createOptionalOption( "c", "color", "Color even lines of the output in COLOR (default: lightblue)", "COLOR" ) ); + options.addOption( createRequiredOption( "f", "format", "Extended MEASures and order (symetric/effort-based/precision-oriented/recall-oriented) (default: "+format+")", "MEAS (sepr)" ) ); + //options.addOption( createRequiredOption( "t", "type", "Output TYPE (html|xml|tex|ascii|triangle; default: "+type+")", "TYPE" ) ); + options.addOption( createRequiredOption( "t", "type", "Output TYPE (only html available so far)", "TYPE" ) ); + //options.addOption( createRequiredOption( "s", "sup", "Are dominant columns algorithms or measure (default: s)", "ALGO" ) ); + options.addOption( createRequiredOption( "r", "reference", "Name of the reference alignment FILE (default: "+reference+")", "FILE" ) ); + options.addOption( createRequiredOption( "w", "directory", "The DIRectory containing the data to evaluate", "DIR" ) ); + /* 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' ) ); @@ -119,6 +127,7 @@ public class ExtGroupEval extends CommonCLI { // .setRequired( true ) Option opt = options.getOption( "list" ); if ( opt != null ) opt.setRequired( true ); + */ } public static void main(String[] args) { @@ -151,8 +160,8 @@ public class ExtGroupEval extends CommonCLI { print( iterateDirectories() ); } - public Vector<Vector> iterateDirectories (){ - Vector<Vector> result = null; + public Vector<Vector<Object>> iterateDirectories (){ + Vector<Vector<Object>> result = null; File [] subdir = null; try { if (ontoDir == null) { @@ -166,14 +175,14 @@ public class ExtGroupEval extends CommonCLI { } int size = subdir.length; Arrays.sort(subdir); - result = new Vector<Vector>(size); + result = new Vector<Vector<Object>>(size); int i = 0; for ( int j=0 ; j < size; j++ ) { if( subdir[j].isDirectory() ) { //logger.trace("Entering directory {}", subdir[j]); // eval the alignments in a subdirectory // store the result - Vector vect = (Vector)iterateAlignments( subdir[j] ); + Vector<Object> vect = iterateAlignments( subdir[j] ); if ( vect != null ){ result.add(i, vect); i++; @@ -235,7 +244,7 @@ public class ExtGroupEval extends CommonCLI { /** * This does not only print the results but compute the average as well */ - public void print( Vector<Vector> result ) { + public void print( Vector<Vector<Object>> result ) { PrintStream writer = null; try { if ( outputfilename == null ) { @@ -252,7 +261,7 @@ public class ExtGroupEval extends CommonCLI { } } - public void printHTML( Vector<Vector> result, PrintStream writer ) { + public void printHTML( Vector<Vector<Object>> result, PrintStream writer ) { // variables for computing iterative harmonic means int expected = 0; // expected so far int foundVect[]; // found so far @@ -310,7 +319,7 @@ public class ExtGroupEval extends CommonCLI { // </tr> // For each directory <tr> boolean colored = false; - for ( Vector test : result ) { + for ( Vector<Object> test : result ) { int nexpected = -1; if ( colored == true && color != null ){ colored = false; @@ -322,7 +331,7 @@ public class ExtGroupEval extends CommonCLI { // 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(); + Enumeration<Object> f = test.elements(); f.nextElement(); for( int k = 0 ; f.hasMoreElements() ; k++) { ExtPREvaluator eval = (ExtPREvaluator)f.nextElement(); diff --git a/src/fr/inrialpes/exmo/align/cli/GenPlot.java b/src/fr/inrialpes/exmo/align/cli/GenPlot.java index ce1a0c49aa74b0d6e4f0d12d73c8488dc86288f1..184683d9f0098ae529a2880375495038f503dc17 100644 --- a/src/fr/inrialpes/exmo/align/cli/GenPlot.java +++ b/src/fr/inrialpes/exmo/align/cli/GenPlot.java @@ -56,7 +56,6 @@ 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; @@ -104,8 +103,8 @@ public class GenPlot extends CommonCLI { String[] listAlgo = null; Vector<GraphEvaluator> listEvaluators; String fileNames = ""; - Constructor evalConstructor = null; - Constructor graphConstructor = null; + Constructor<?> evalConstructor = null; + Constructor<?> graphConstructor = null; String xlabel; String ylabel; String type = "tex"; @@ -114,8 +113,15 @@ public class GenPlot extends CommonCLI { 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( createListOption( "l", "list", "List of FILEs to be included in the results (required)", "FILE", ',' ) ); + options.addOption( createRequiredOption( "t", "type", "Output TYPE (html|xml|tex|ascii|triangle; default: "+type+")", "TYPE" ) ); + options.addOption( createRequiredOption( "e", "evaluator", "Use CLASS as evaluation plotter", "CLASS" ) ); + options.addOption( createRequiredOption( "g", "grapher", "Use CLASS as graph generator", "CLASS" ) ); + //options.addOption( createRequiredOption( "s", "step", "" ) ); + options.addOption( createRequiredOption( "w", "directory", "The DIRectory containing the data to plot", "DIR" ) ); + /* + 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' ) ); @@ -123,6 +129,7 @@ public class GenPlot extends CommonCLI { // .setRequired( true ) Option opt = options.getOption( "list" ); if ( opt != null ) opt.setRequired( true ); + */ } public static void main(String[] args) { diff --git a/src/fr/inrialpes/exmo/align/cli/GroupAggreg.java b/src/fr/inrialpes/exmo/align/cli/GroupAggreg.java index 92fe4b0aefe0f283e0034a50ccd18280b51e3a38..1089e38a73457cbf5af45f40ff02c1c66859e2e4 100644 --- a/src/fr/inrialpes/exmo/align/cli/GroupAggreg.java +++ b/src/fr/inrialpes/exmo/align/cli/GroupAggreg.java @@ -61,7 +61,6 @@ 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; /** @@ -113,7 +112,14 @@ public class GroupAggreg extends CommonCLI { public GroupAggreg() { 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( createListOption( "l", "list", "List of FILEs to be included in the results (required)", "FILE", ',' ) ); + options.addOption( createRequiredOption( "m", "aggmethod", "METHOD to use for aggregating (min|max|avg|pool)", "METHOD" ) ); + options.addOption( createRequiredOption( "t", "threshold", "Trim the alignment with regard to threshold", "DOUBLE" ) ); + options.addOption( createRequiredOption( "T", "cutmethod", "METHOD to use for triming (hard|perc|prop|best|span)", "METHOD" ) ); + options.addOption( createRequiredOption( "o", "outputDir", "The DIRectory where to output results", "DIR" ) ); + options.addOption( createRequiredOption( "w", "directory", "The DIRectory containing the data to evaluate", "DIR" ) ); + /* + 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( "workDir" ).hasOptionalArg().withDescription( "The DIRectory containing the data to evaluate" ).withArgName("DIR").create( 'w' ) ); options.addOption( OptionBuilder.withLongOpt( "aggmethod" ).hasArg().withDescription( "Method to use for aggregating (min|max|avg|pool)" ).withArgName("METHOD").create( 'm' ) ); options.addOption( OptionBuilder.withLongOpt( "threshold" ).hasArg().withDescription( "Trim the alignment with regard to threshold" ).withArgName("DOUBLE").create( 't' ) ); @@ -122,6 +128,7 @@ public class GroupAggreg extends CommonCLI { // .setRequired( true ) Option opt = options.getOption( "list" ); if ( opt != null ) opt.setRequired( true ); + */ } public static void main(String[] args) { diff --git a/src/fr/inrialpes/exmo/align/cli/GroupAlign.java b/src/fr/inrialpes/exmo/align/cli/GroupAlign.java index bf80a17c36bbb7c7622bf36b98f31412eed239d1..e6e6b8c22fa8982f68fffb63186249f607008920 100644 --- a/src/fr/inrialpes/exmo/align/cli/GroupAlign.java +++ b/src/fr/inrialpes/exmo/align/cli/GroupAlign.java @@ -53,7 +53,6 @@ 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. @@ -92,6 +91,15 @@ public class GroupAlign extends CommonCLI { public GroupAlign() { super(); + options.addOption( createRequiredOption( "a", "alignment", "Use an initial alignment FILE", "FILE" ) ); + options.addOption( createRequiredOption( "r", "renderer", "Use the given CLASS for rendering", "CLASS" ) ); + options.addOption( createRequiredOption( "i", "impl", "Use the given AlignmentProcess implementation", "CLASS" ) ); + options.addOption( createRequiredOption( "n", "name", "Use the given URI as common source ontology", "URI" ) ); + options.addOption( createRequiredOption( "u", "uriprefix", "URI prefix of the target", "URI" ) ); + options.addOption( createRequiredOption( "s", "source", "Source ontology FILEname (default "+source+")", "FILE" ) ); + options.addOption( createRequiredOption( "t", "target", "Target ontology FILEname (default "+target+")", "FILE" ) ); + options.addOption( createRequiredOption( "w", "directory", "The DIRectory containing the data to match", "DIR" ) ); + /* 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' ) ); @@ -100,6 +108,7 @@ public class GroupAlign extends CommonCLI { 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) { @@ -206,7 +215,7 @@ public class GroupAlign extends CommonCLI { Object[] mparams = {}; Class[] cparams = {}; Class<?> alignmentClass = Class.forName( alignmentClassName ); - Constructor alignmentConstructor = alignmentClass.getConstructor(cparams); + Constructor<?> alignmentConstructor = alignmentClass.getConstructor(cparams); result = (AlignmentProcess)alignmentConstructor.newInstance( mparams ); result.init( uri1, uri2 ); } catch (Exception ex) { @@ -233,7 +242,7 @@ public class GroupAlign extends CommonCLI { try { Class[] cparams = { PrintWriter.class }; - Constructor rendererConstructor = + Constructor<?> rendererConstructor = Class.forName(rendererClass).getConstructor(cparams); Object[] mparams = { (Object)writer }; renderer = (AlignmentVisitor)rendererConstructor.newInstance(mparams); diff --git a/src/fr/inrialpes/exmo/align/cli/GroupEval.java b/src/fr/inrialpes/exmo/align/cli/GroupEval.java index cd85905bec33f81710ed9d671dac002a9c33efe0..79443543aad66ffe27c75f44e1cab0d1246a1f11 100644 --- a/src/fr/inrialpes/exmo/align/cli/GroupEval.java +++ b/src/fr/inrialpes/exmo/align/cli/GroupEval.java @@ -54,7 +54,6 @@ 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; @@ -117,10 +116,20 @@ public class GroupEval extends CommonCLI { String color = null; String ontoDir = null; String classname = "fr.inrialpes.exmo.align.impl.eval.PRecEvaluator"; - Constructor evalConstructor = null; + Constructor<?> evalConstructor = null; public GroupEval() { super(); + options.addOption( createListOption( "l", "list", "List of FILEs to be included in the results (required)", "FILE", ',' ) ); + options.addOption( createOptionalOption( "c", "color", "Color even lines of the output in COLOR (default: lightblue)", "COLOR" ) ); + options.addOption( createRequiredOption( "e", "evaluator", "Use CLASS as evaluation plotter", "CLASS" ) ); + options.addOption( createRequiredOption( "f", "format", "Used MEASures and order (precision/recall/f-measure/overall/time) (default: "+format+")", "MEAS (sepr)" ) ); + options.addOption( createRequiredOption( "t", "type", "Output TYPE (html|xml|tex|ascii|triangle; default: "+type+")", "TYPE" ) ); + //options.addOption( createRequiredOption( "s", "sup", "Specifies if dominant columns are algorithms or measure (default: s)", "ALGO" ) ); + options.addOption( createRequiredOption( "r", "reference", "Name of the reference alignment FILE (default: "+reference+")", "FILE" ) ); + options.addOption( createRequiredOption( "w", "directory", "The DIRectory containing the data to evaluate", "DIR" ) ); + + /* 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( "evaluator" ).hasArg().withDescription( "Use CLASS as evaluation plotter" ).withArgName("CLASS").create( 'e' ) ); @@ -132,6 +141,7 @@ public class GroupEval extends CommonCLI { // .setRequired( true ) Option opt = options.getOption( "list" ); if ( opt != null ) opt.setRequired( true ); + */ } @@ -171,8 +181,8 @@ public class GroupEval extends CommonCLI { print( iterateDirectories() ); } - public Vector<Vector> iterateDirectories (){ - Vector<Vector> result = null; + public Vector<Vector<Object>> iterateDirectories (){ + Vector<Vector<Object>> result = null; File [] subdir = null; try { if (ontoDir == null) { @@ -186,14 +196,14 @@ public class GroupEval extends CommonCLI { } int size = subdir.length; Arrays.sort(subdir); - result = new Vector<Vector>(size); + result = new Vector<Vector<Object>>(size); int i = 0; for ( int j=0 ; j < size; j++ ) { if( subdir[j].isDirectory() ) { //logger.trace( "Entering directory {}", subdir[j] ); // eval the alignments in a subdirectory // store the result - Vector vect = iterateAlignments( subdir[j] ); + Vector<Object> vect = iterateAlignments( subdir[j] ); if ( vect != null ){ result.add(i, vect); i++; @@ -256,7 +266,7 @@ public class GroupEval extends CommonCLI { /** * This does not only print the results but compute the average as well */ - public void print( Vector<Vector> result ) { + public void print( Vector<Vector<Object>> result ) { PrintStream writer = null; try { if ( outputfilename == null ) { @@ -279,7 +289,7 @@ public class GroupEval extends CommonCLI { * Added level lines provides by Christian Meilicke (U. Mannheim) * See his program in comment below */ - public void printTRIANGLE( Vector<Vector> result, PrintStream writer ) { + public void printTRIANGLE( Vector<Vector<Object>> result, PrintStream writer ) { // variables for computing iterative harmonic means int expected = 0; // expected so far int foundVect[]; // found so far @@ -293,9 +303,9 @@ public class GroupEval extends CommonCLI { correctVect[k] = 0; timeVect[k] = 0; } - for ( Vector test : result ) { + for ( Vector<Object> test : result ) { int nexpected = -1; - Enumeration f = test.elements(); + Enumeration<Object> f = test.elements(); // Too bad the first element must be skipped f.nextElement(); for( int k = 0 ; f.hasMoreElements() ; k++) { @@ -387,7 +397,7 @@ public class GroupEval extends CommonCLI { writer.println("\\end{document}"); } - public void printHTML( Vector<Vector> result, PrintStream writer ) { + public void printHTML( Vector<Vector<Object>> result, PrintStream writer ) { // variables for computing iterative harmonic means int expected = 0; // expected so far int foundVect[]; // found so far @@ -443,7 +453,7 @@ public class GroupEval extends CommonCLI { // </tr> // For each directory <tr> boolean colored = false; - for ( Vector test : result ) { + for ( Vector<Object> test : result ) { int nexpected = -1; if ( colored == true && color != null ){ colored = false; @@ -455,7 +465,7 @@ public class GroupEval extends CommonCLI { // 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(); + Enumeration<Object> f = test.elements(); f.nextElement(); for( int k = 0 ; f.hasMoreElements() ; k++) { PRecEvaluator eval = (PRecEvaluator)f.nextElement(); @@ -533,7 +543,7 @@ public class GroupEval extends CommonCLI { if ( embedded != true ) writer.println("</body></html>"); } - public void printLATEX( Vector<Vector> result, PrintStream writer ) { + public void printLATEX( Vector<Vector<Object>> result, PrintStream writer ) { // variables for computing iterative harmonic means int expected = 0; // expected so far int foundVect[]; // found so far @@ -593,12 +603,12 @@ public class GroupEval extends CommonCLI { correctVect[k] = 0; timeVect[k] = 0; } - for ( Vector test : result ) { + for ( Vector<Object> test : result ) { int nexpected = -1; // Print the directory writer.print((String)test.get(0)); // For each record print the values - Enumeration f = test.elements(); + Enumeration<Object> f = test.elements(); f.nextElement(); for( int k = 0 ; f.hasMoreElements() ; k++) { PRecEvaluator eval = (PRecEvaluator)f.nextElement(); diff --git a/src/fr/inrialpes/exmo/align/cli/GroupOutput.java b/src/fr/inrialpes/exmo/align/cli/GroupOutput.java index 56e84b54d7fe2e3b4ae15932254ab83824c92ad1..ad0bf168d94e767d955a7885ddd142fd4d32a698 100644 --- a/src/fr/inrialpes/exmo/align/cli/GroupOutput.java +++ b/src/fr/inrialpes/exmo/align/cli/GroupOutput.java @@ -53,7 +53,7 @@ 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.Option; import org.apache.commons.cli.ParseException; import fr.inrialpes.exmo.align.parser.AlignmentParser; @@ -159,6 +159,14 @@ public class GroupOutput extends CommonCLI { public GroupOutput() { super(); + options.addOption( createListOption( "l", "list", "List of FILEs to be included in the results (required)", "FILE", ',' ) ); + options.addOption( createOption( "v", "values", "Displays the values" ) ); + options.addOption( createOption( "e", "labels", "Displays graph labels" ) ); + options.addOption( createRequiredOption( "c", "color", "Use COLOR to fill cells (default: "+color+")", "COLOR" ) ); + options.addOption( createRequiredOption( "t", "type", "Output TYPE (html|tex; default: "+type+")", "TYPE" ) ); + options.addOption( createRequiredOption( "f", "format", "Display MEASure (prof; default: f)", "MEAS (prof)" ) ); + options.addOption( createRequiredOption( "w", "directory", "The DIRectory containing the data to match", "DIR" ) ); + /* 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' ) ); @@ -166,6 +174,7 @@ public class GroupOutput extends CommonCLI { 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 ); } diff --git a/src/fr/inrialpes/exmo/align/cli/ParserPrinter.java b/src/fr/inrialpes/exmo/align/cli/ParserPrinter.java index d3c607af8cad0e9c6ebc907c902c739b32f7da40..3af1b95e03582f3b5a0539491e07d19a273f4f6b 100644 --- a/src/fr/inrialpes/exmo/align/cli/ParserPrinter.java +++ b/src/fr/inrialpes/exmo/align/cli/ParserPrinter.java @@ -36,7 +36,7 @@ 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.Option; import org.apache.commons.cli.ParseException; import org.semanticweb.owl.align.Alignment; @@ -80,6 +80,15 @@ public class ParserPrinter extends CommonCLI { public ParserPrinter() { super(); + options.addOption( createOption( "i", "inverse", "Inverse first and second ontology" ) ); + options.addOption( createOption( "e", "embedded", "Read the alignment as embedded in a XML file" ) ); + options.addOption( createRequiredOption( "r", "renderer", "Use the given CLASS for rendering", "CLASS" ) ); + options.addOption( createRequiredOption( "p", "parser", "Use the given CLASS for parsing", "CLASS" ) ); + options.addOption( createRequiredOption( "t", "threshold", "Trim the alignment with regard to threshold", "DOUBLE" ) ); + options.addOption( createRequiredOption( "T", "cutmethod", "METHOD to use for triming (hard|perc|prop|best|span)", "METHOD" ) ); + options.addOption( createRequiredOption( "f", "format", "Display MEASure (prof; default: f)", "MEAS (prof)" ) ); + options.addOption( createRequiredOption( "w", "outputDir", "Split the output in a DIRectory (for SPARQL)", "DIR" ) ); + /* 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' ) ); @@ -87,6 +96,7 @@ public class ParserPrinter extends CommonCLI { 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) { @@ -142,7 +152,7 @@ public class ParserPrinter extends CommonCLI { else { try { Class[] cparams = {}; - Constructor parserConstructor = + Constructor<?> parserConstructor = Class.forName(parserClass).getConstructor(cparams); Object[] mparams = {}; aparser = (AlignmentParser) parserConstructor.newInstance(mparams); @@ -185,7 +195,7 @@ public class ParserPrinter extends CommonCLI { else { try { Class[] cparams = { PrintWriter.class }; - Constructor rendererConstructor = Class.forName(rendererClass).getConstructor( cparams ); + Constructor<?> rendererConstructor = Class.forName(rendererClass).getConstructor( cparams ); Object[] mparams = { (Object)writer }; renderer = (AlignmentVisitor) rendererConstructor.newInstance( mparams ); } catch (Exception ex) { diff --git a/src/fr/inrialpes/exmo/align/cli/Procalign.java b/src/fr/inrialpes/exmo/align/cli/Procalign.java index 00f1692c300efd4104dfc1f7c7090aa4f15776ed..2ce3dfc7ab8b415ce8f0d67d142ac5fade093d13 100644 --- a/src/fr/inrialpes/exmo/align/cli/Procalign.java +++ b/src/fr/inrialpes/exmo/align/cli/Procalign.java @@ -50,7 +50,7 @@ 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.Option; import org.apache.commons.cli.ParseException; import fr.inrialpes.exmo.align.parser.AlignmentParser; @@ -94,11 +94,18 @@ public class Procalign extends CommonCLI { public Procalign() { super(); + options.addOption( createRequiredOption( "i", "impl", "Use the given CLASS for matcher", "CLASS" ) ); + options.addOption( createRequiredOption( "r", "renderer", "Use the given CLASS for rendering", "CLASS" ) ); + options.addOption( createRequiredOption( "a", "alignment", "Use an initial alignment FILE", "FILE" ) ); + options.addOption( createRequiredOption( "t", "threshold", "Trim the alignment with regard to threshold", "DOUBLE" ) ); + options.addOption( createRequiredOption( "T", "cutmethod", "METHOD to use for triming (hard|perc|prop|best|span)", "METHOD" ) ); + /* 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 ) { @@ -165,7 +172,7 @@ public class Procalign extends CommonCLI { // Create alignment object Class<?> alignmentClass = Class.forName( alignmentClassName ); Class[] cparams = {}; - Constructor alignmentConstructor = alignmentClass.getConstructor(cparams); + Constructor<?> alignmentConstructor = alignmentClass.getConstructor(cparams); Object[] mparams = {}; result = (AlignmentProcess)alignmentConstructor.newInstance( mparams ); result.init( onto1, onto2 ); @@ -203,7 +210,7 @@ public class Procalign extends CommonCLI { // Result printing (to be reimplemented with a default value) try { Class[] cparams = { PrintWriter.class }; - Constructor rendererConstructor = Class.forName(rendererClass).getConstructor( cparams ); + Constructor<?> rendererConstructor = Class.forName(rendererClass).getConstructor( cparams ); Object[] mparams = { (Object)writer }; renderer = (AlignmentVisitor) rendererConstructor.newInstance( mparams ); } catch (Exception ex) { diff --git a/src/fr/inrialpes/exmo/align/cli/TestGen.java b/src/fr/inrialpes/exmo/align/cli/TestGen.java index 2ed9f13389b8ea8839053b3be8b39e71824d9660..c597811b2d255569a1ab03af5ab04354a5d53852 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-2013, INRIA + * Copyright (C) 2011-2014, 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,7 +30,6 @@ 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; @@ -60,6 +59,14 @@ public class TestGen extends CommonCLI { public TestGen() { super(); + options.addOption( createRequiredOption( "u", "uriprefix", "URI prefix of the target", "URI" ) ); + options.getOption( "uriprefix" ).setRequired( true ); + options.addOption( createRequiredOption( "t", "testset", "Use CLASS for generating the test set", "CLASS" ) ); + options.addOption( createRequiredOption( "w", "outdir", "Output DIRectory (default: current)", "DIR" ) ); + options.addOption( createRequiredOption( "a", "alignname", "FILEname of generated alignment (default: refalign.rdf)", "FILE" ) ); + // We redefine the message for -o + options.getOption( "output" ).setDescription( "FILEname of the generated ontology (default: "+fileName+")" ); + /* 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' ) ); @@ -70,6 +77,7 @@ public class TestGen extends CommonCLI { // 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) { @@ -126,7 +134,7 @@ public class TestGen extends CommonCLI { try { Class<?> testSetClass = Class.forName( methodName ); Class[] cparams = {}; - Constructor testSetConstructor = testSetClass.getConstructor(cparams); + Constructor<?> testSetConstructor = testSetClass.getConstructor(cparams); Object[] mparams = {}; tset = (TestSet)testSetConstructor.newInstance( mparams ); } catch (Exception ex) { diff --git a/src/fr/inrialpes/exmo/align/cli/TransformQuery.java b/src/fr/inrialpes/exmo/align/cli/TransformQuery.java index 0bb884f9a32357e4a133fb6de97539da42ca5a35..c992d446b167ff10ea6bc3ee77ee531b2263b7c8 100644 --- a/src/fr/inrialpes/exmo/align/cli/TransformQuery.java +++ b/src/fr/inrialpes/exmo/align/cli/TransformQuery.java @@ -39,7 +39,7 @@ 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.Option; import org.apache.commons.cli.ParseException; import fr.inrialpes.exmo.align.impl.BasicAlignment; @@ -60,10 +60,16 @@ public class TransformQuery extends CommonCLI { public TransformQuery() { super(); + options.addOption( createOption( "e", "echo", "Echo the input query" ) ); + //options.addOption( createRequiredOption( "p", "process", "Process the query against a particular CLASS", "CLASS" ) ); + options.addOption( createRequiredOption( "q", "query", "get the query from the corresponding FILE", "FILE" ) ); + options.addOption( createRequiredOption( "a", "alignment", "Use the alignment identified by URI", "URI" ) ); + /* options.addOption( "e", "echo", false, "Echo the input query" ); //options.addOption( OptionBuilder.withLongOpt( "process" ).hasArg().withDescription( "Process the query against a particular CLASS" ).withArgName("CLASS").create( 'p' ) ); options.addOption( OptionBuilder.withLongOpt( "query" ).hasArg().withType(File.class).withDescription( "get the query from the corresponding FILE" ).withArgName("FILE").create( 'q' ) ); - options.addOption( OptionBuilder.withLongOpt( "alignment" ).hasArg().withDescription( "use the alignment identified by URI" ).withArgName("URI").create( 'a' ) ); + options.addOption( OptionBuilder.withLongOpt( "alignment" ).hasArg().withDescription( "Use the alignment identified by URI" ).withArgName("URI").create( 'a' ) ); + */ } public static void main(String[] args) { diff --git a/src/fr/inrialpes/exmo/align/cli/WGroupEval.java b/src/fr/inrialpes/exmo/align/cli/WGroupEval.java index 4dc2580fc57cdbc5737cde70210c226027a59e8e..c5fa90872b1aa24420ff82e487a81f9390095733 100644 --- a/src/fr/inrialpes/exmo/align/cli/WGroupEval.java +++ b/src/fr/inrialpes/exmo/align/cli/WGroupEval.java @@ -51,7 +51,6 @@ 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; @@ -103,6 +102,15 @@ public class WGroupEval extends CommonCLI { public WGroupEval() { super(); + options.addOption( createListOption( "l", "list", "List of FILEs to be included in the results (required)", "FILE", ',' ) ); + options.addOption( createOptionalOption( "c", "color", "Color even lines of the output in COLOR (default: lightblue)", "COLOR" ) ); + //options.addOption( createRequiredOption( "e", "evaluator", "Use CLASS as evaluation plotter", "CLASS" ) ); + options.addOption( createRequiredOption( "f", "format", "Used (weighted) MEASures and order (precision/recall/f-measure/overall/time) (default: "+format+")", "MEAS (prfot)" ) ); + options.addOption( createRequiredOption( "t", "type", "Output TYPE (html|xml|tex|ascii|triangle; default: "+type+")", "TYPE" ) ); + //options.addOption( createRequiredOption( "s", "sup", "Specifies if dominant columns are algorithms or measure (default: s)", "ALGO" ) ); + options.addOption( createRequiredOption( "r", "reference", "Name of the reference alignment FILE (default: "+reference+")", "FILE" ) ); + options.addOption( createRequiredOption( "w", "directory", "The DIRectory containing the data to evaluate", "DIR" ) ); + /* 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' ) ); @@ -113,6 +121,7 @@ public class WGroupEval extends CommonCLI { // .setRequired( true ) Option opt = options.getOption( "list" ); if ( opt != null ) opt.setRequired( true ); + */ } @@ -147,8 +156,8 @@ public class WGroupEval extends CommonCLI { print( iterateDirectories() ); } - public Vector<Vector> iterateDirectories (){ - Vector<Vector> result = null; + public Vector<Vector<Object>> iterateDirectories (){ + Vector<Vector<Object>> result = null; File [] subdir = null; try { if (ontoDir == null) { @@ -163,14 +172,14 @@ public class WGroupEval extends CommonCLI { } int size = subdir.length; Arrays.sort(subdir); - result = new Vector<Vector>(size); + result = new Vector<Vector<Object>>(size); int i = 0; for ( int j=0 ; j < size; j++ ) { if( subdir[j].isDirectory() ) { //logger.trace("Entering directory {}", subdir[j]); // eval the alignments in a subdirectory // store the result - Vector vect = iterateAlignments( subdir[j] ); + Vector<Object> vect = iterateAlignments( subdir[j] ); if ( vect != null ){ result.add(i, vect); i++; @@ -236,7 +245,7 @@ public class WGroupEval extends CommonCLI { /** * This does not only print the results but compute the average as well */ - public void print( Vector<Vector> result ) { + public void print( Vector<Vector<Object>> result ) { PrintStream writer = null; try { if ( outputfilename == null ) { @@ -255,7 +264,7 @@ public class WGroupEval extends CommonCLI { } } - public void printTRIANGLE( Vector<Vector> result, PrintStream writer ) { + public void printTRIANGLE( Vector<Vector<Object>> result, PrintStream writer ) { // variables for computing iterative harmonic means double expected = 0.; // expected so far double foundVect[]; // found so far @@ -272,9 +281,9 @@ public class WGroupEval extends CommonCLI { correctExpVect[k] = 0.; timeVect[k] = 0; } - for ( Vector test : result ) { + for ( Vector<Object> test : result ) { double newexpected = -1.; - Enumeration f = test.elements(); + Enumeration<Object> f = test.elements(); // Too bad the first element must be skipped f.nextElement(); for( int k = 0 ; f.hasMoreElements() ; k++) { @@ -333,7 +342,7 @@ public class WGroupEval extends CommonCLI { writer.println("\\end{document}"); } - public void printLATEX( Vector result, PrintStream writer ) { + public void printLATEX( Vector<Vector<Object>> result, PrintStream writer ) { } /* A few comments on how and why computing "weighted harmonic means" @@ -382,7 +391,7 @@ and which the program does... */ - public void printHTML( Vector<Vector> result, PrintStream writer ) { + public void printHTML( Vector<Vector<Object>> result, PrintStream writer ) { // variables for computing iterative harmonic means int expected = 0; // expected so far int foundVect[]; // found so far @@ -442,7 +451,7 @@ which the program does... // </tr> // For each directory <tr> boolean colored = false; - for ( Vector test : result ) { + for ( Vector<Object> test : result ) { double newexpected = -1.; if ( colored == true && color != null ){ colored = false; @@ -454,7 +463,7 @@ which the program does... // 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(); + Enumeration<Object> f = test.elements(); f.nextElement(); for( int k = 0 ; f.hasMoreElements() ; k++) { WeightedPREvaluator eval = (WeightedPREvaluator)f.nextElement();