List of usage examples for org.apache.commons.cli2 CommandLine hasOption
boolean hasOption(final Option option);
From source file:org.apache.mahout.clustering.syntheticcontrol.canopy.InputDriver.java
public static void main(String[] args) throws IOException { DefaultOptionBuilder obuilder = new DefaultOptionBuilder(); ArgumentBuilder abuilder = new ArgumentBuilder(); GroupBuilder gbuilder = new GroupBuilder(); Option inputOpt = DefaultOptionCreator.inputOption().withRequired(false).create(); Option outputOpt = DefaultOptionCreator.outputOption().withRequired(false).create(); Option vectorOpt = obuilder.withLongName("vector").withRequired(false) .withArgument(abuilder.withName("v").withMinimum(1).withMaximum(1).create()) .withDescription("The vector implementation to use.").withShortName("v").create(); Option helpOpt = DefaultOptionCreator.helpOption(); Group group = gbuilder.withName("Options").withOption(inputOpt).withOption(outputOpt).withOption(vectorOpt) .withOption(helpOpt).create(); try {//from w w w.java2 s .c o m Parser parser = new Parser(); parser.setGroup(group); CommandLine cmdLine = parser.parse(args); if (cmdLine.hasOption(helpOpt)) { CommandLineUtil.printHelp(group); return; } Path input = new Path(cmdLine.getValue(inputOpt, "testdata").toString()); Path output = new Path(cmdLine.getValue(outputOpt, "output").toString()); String vectorClassName = cmdLine.getValue(vectorOpt, "org.apache.mahout.math.RandomAccessSparseVector") .toString(); runJob(input, output, vectorClassName); } catch (OptionException e) { InputDriver.LOG.error("Exception parsing command line: ", e); CommandLineUtil.printHelp(group); } }
From source file:org.apache.mahout.clustering.syntheticcontrol.canopy.Job.java
public static void main(String[] args) throws Exception { DefaultOptionBuilder obuilder = new DefaultOptionBuilder(); ArgumentBuilder abuilder = new ArgumentBuilder(); GroupBuilder gbuilder = new GroupBuilder(); Option inputOpt = obuilder.withLongName("input").withRequired(false) .withArgument(abuilder.withName("input").withMinimum(1).withMaximum(1).create()) .withDescription("The Path for input Vectors. Must be a SequenceFile of Writable, Vector") .withShortName("i").create(); Option outputOpt = obuilder.withLongName("output").withRequired(false) .withArgument(abuilder.withName("output").withMinimum(1).withMaximum(1).create()) .withDescription("The Path to put the output in").withShortName("o").create(); Option measureClassOpt = obuilder.withLongName("distance").withRequired(false) .withArgument(abuilder.withName("distance").withMinimum(1).withMaximum(1).create()) .withDescription("The Distance Measure to use. Default is SquaredEuclidean").withShortName("m") .create();/*from w ww . j a va 2 s . c o m*/ // Option vectorClassOpt = obuilder.withLongName("vectorClass").withRequired(false).withArgument( // abuilder.withName("vectorClass").withMinimum(1).withMaximum(1).create()). // withDescription("The Vector implementation class name. Default is RandomAccessSparseVector.class") // .withShortName("v").create(); Option t1Opt = obuilder.withLongName("t1").withRequired(false) .withArgument(abuilder.withName("t1").withMinimum(1).withMaximum(1).create()).withDescription("t1") .withShortName("t1").create(); Option t2Opt = obuilder.withLongName("t2").withRequired(false) .withArgument(abuilder.withName("t2").withMinimum(1).withMaximum(1).create()).withDescription("t2") .withShortName("t2").create(); Option helpOpt = obuilder.withLongName("help").withDescription("Print out help").withShortName("h") .create(); Group group = gbuilder.withName("Options").withOption(inputOpt).withOption(outputOpt) .withOption(measureClassOpt)// .withOption(vectorClassOpt) .withOption(t1Opt).withOption(t2Opt).withOption(helpOpt).create(); try { Parser parser = new Parser(); parser.setGroup(group); CommandLine cmdLine = parser.parse(args); if (cmdLine.hasOption(helpOpt)) { CommandLineUtil.printHelp(group); return; } Path input = new Path(cmdLine.getValue(inputOpt, "testdata").toString()); Path output = new Path(cmdLine.getValue(outputOpt, "output").toString()); String measureClass = cmdLine .getValue(measureClassOpt, "org.apache.mahout.common.distance.EuclideanDistanceMeasure") .toString(); // String className = cmdLine.getValue(vectorClassOpt, // "org.apache.mahout.math.RandomAccessSparseVector").toString(); // Class<? extends Vector> vectorClass = Class.forName(className).asSubclass(Vector.class); double t1 = Double.parseDouble(cmdLine.getValue(t1Opt, "80").toString()); double t2 = Double.parseDouble(cmdLine.getValue(t2Opt, "55").toString()); runJob(input, output, measureClass, t1, t2); } catch (OptionException e) { Job.log.error("Exception", e); CommandLineUtil.printHelp(group); } }
From source file:org.apache.mahout.clustering.syntheticcontrol.kmeans.Job.java
public static void main(String[] args) throws Exception { DefaultOptionBuilder obuilder = new DefaultOptionBuilder(); ArgumentBuilder abuilder = new ArgumentBuilder(); GroupBuilder gbuilder = new GroupBuilder(); Option inputOpt = DefaultOptionCreator.inputOption().withRequired(false).create(); Option outputOpt = DefaultOptionCreator.outputOption().withRequired(false).create(); Option convergenceDeltaOpt = DefaultOptionCreator.convergenceOption().withRequired(false).create(); Option maxIterationsOpt = DefaultOptionCreator.maxIterationsOption().withRequired(false).create(); Option measureClassOpt = obuilder.withLongName("distance").withRequired(false) .withArgument(abuilder.withName("distance").withMinimum(1).withMaximum(1).create()) .withDescription("The Distance Measure to use. Default is SquaredEuclidean").withShortName("m") .create();/*from ww w . j a va 2 s . co m*/ Option t1Opt = obuilder.withLongName("t1").withRequired(false) .withArgument(abuilder.withName("t1").withMinimum(1).withMaximum(1).create()) .withDescription("The t1 value to use.").withShortName("m").create(); Option t2Opt = obuilder.withLongName("t2").withRequired(false) .withArgument(abuilder.withName("t2").withMinimum(1).withMaximum(1).create()) .withDescription("The t2 value to use.").withShortName("m").create(); Option vectorClassOpt = obuilder.withLongName("vectorClass").withRequired(false) .withArgument(abuilder.withName("vectorClass").withMinimum(1).withMaximum(1).create()) .withDescription("The Vector implementation class name. Default is RandomAccessSparseVector.class") .withShortName("v").create(); Option helpOpt = DefaultOptionCreator.helpOption(); Group group = gbuilder.withName("Options").withOption(inputOpt).withOption(outputOpt) .withOption(measureClassOpt).withOption(convergenceDeltaOpt).withOption(maxIterationsOpt) .withOption(vectorClassOpt).withOption(t1Opt).withOption(t2Opt).withOption(helpOpt).create(); try { Parser parser = new Parser(); parser.setGroup(group); CommandLine cmdLine = parser.parse(args); if (cmdLine.hasOption(helpOpt)) { CommandLineUtil.printHelp(group); return; } Path input = new Path(cmdLine.getValue(inputOpt, "testdata").toString()); Path output = new Path(cmdLine.getValue(outputOpt, "output").toString()); String measureClass = cmdLine .getValue(measureClassOpt, "org.apache.mahout.common.distance.EuclideanDistanceMeasure") .toString(); double t1 = Double.parseDouble(cmdLine.getValue(t1Opt, "80").toString()); double t2 = Double.parseDouble(cmdLine.getValue(t2Opt, "55").toString()); double convergenceDelta = Double.parseDouble(cmdLine.getValue(convergenceDeltaOpt, "0.5").toString()); int maxIterations = Integer.parseInt(cmdLine.getValue(maxIterationsOpt, 10).toString()); runJob(input, output, measureClass, t1, t2, convergenceDelta, maxIterations); } catch (OptionException e) { log.error("Exception", e); CommandLineUtil.printHelp(group); } }
From source file:org.apache.mahout.clustering.syntheticcontrol.meanshift.InputDriver.java
public static void main(String[] args) throws IOException { GroupBuilder gbuilder = new GroupBuilder(); Option inputOpt = DefaultOptionCreator.inputOption().withRequired(false).create(); Option outputOpt = DefaultOptionCreator.outputOption().withRequired(false).create(); Option helpOpt = DefaultOptionCreator.helpOption(); Group group = gbuilder.withName("Options").withOption(inputOpt).withOption(outputOpt).withOption(helpOpt) .create();// w w w .j a v a 2 s . c o m try { Parser parser = new Parser(); parser.setGroup(group); CommandLine cmdLine = parser.parse(args); if (cmdLine.hasOption(helpOpt)) { CommandLineUtil.printHelp(group); return; } Path input = new Path(cmdLine.getValue(inputOpt, "testdata").toString()); Path output = new Path(cmdLine.getValue(outputOpt, "output").toString()); runJob(input, output); } catch (OptionException e) { InputDriver.LOG.error("Exception parsing command line: ", e); CommandLineUtil.printHelp(group); } }
From source file:org.apache.mahout.clustering.syntheticcontrol.meanshift.Job.java
public static void main(String[] args) throws Exception { DefaultOptionBuilder obuilder = new DefaultOptionBuilder(); ArgumentBuilder abuilder = new ArgumentBuilder(); GroupBuilder gbuilder = new GroupBuilder(); Option inputOpt = DefaultOptionCreator.inputOption().withRequired(false).create(); Option outputOpt = DefaultOptionCreator.outputOption().withRequired(false).create(); Option convergenceDeltaOpt = DefaultOptionCreator.convergenceOption().withRequired(false).create(); Option maxIterOpt = DefaultOptionCreator.maxIterationsOption().withRequired(false).create(); Option helpOpt = DefaultOptionCreator.helpOption(); Option modelOpt = obuilder.withLongName("distanceClass").withRequired(false).withShortName("d") .withArgument(abuilder.withName("distanceClass").withMinimum(1).withMaximum(1).create()) .withDescription("The distance measure class name.").create(); Option threshold1Opt = obuilder.withLongName("threshold_1").withRequired(false).withShortName("t1") .withArgument(abuilder.withName("threshold_1").withMinimum(1).withMaximum(1).create()) .withDescription("The T1 distance threshold.").create(); Option threshold2Opt = obuilder.withLongName("threshold_2").withRequired(false).withShortName("t2") .withArgument(abuilder.withName("threshold_2").withMinimum(1).withMaximum(1).create()) .withDescription("The T1 distance threshold.").create(); Group group = gbuilder.withName("Options").withOption(inputOpt).withOption(outputOpt).withOption(modelOpt) .withOption(helpOpt).withOption(convergenceDeltaOpt).withOption(threshold1Opt) .withOption(maxIterOpt).withOption(threshold2Opt).create(); try {/* w w w . java 2s .co m*/ Parser parser = new Parser(); parser.setGroup(group); CommandLine cmdLine = parser.parse(args); if (cmdLine.hasOption(helpOpt)) { CommandLineUtil.printHelp(group); return; } Path input = new Path(cmdLine.getValue(inputOpt, "testdata").toString()); Path output = new Path(cmdLine.getValue(outputOpt, "output").toString()); String measureClassName = cmdLine .getValue(modelOpt, "org.apache.mahout.common.distance.EuclideanDistanceMeasure").toString(); double t1 = Double.parseDouble(cmdLine.getValue(threshold1Opt, "47.6").toString()); double t2 = Double.parseDouble(cmdLine.getValue(threshold2Opt, "1").toString()); double convergenceDelta = Double.parseDouble(cmdLine.getValue(convergenceDeltaOpt, "0.5").toString()); int maxIterations = Integer.parseInt(cmdLine.getValue(maxIterOpt, "10").toString()); runJob(input, output, measureClassName, t1, t2, convergenceDelta, maxIterations); } catch (OptionException e) { log.error("Exception parsing command line: ", e); CommandLineUtil.printHelp(group); } }
From source file:org.apache.mahout.clustering.syntheticcontrol.meanshift.OutputDriver.java
public static void main(String[] args) throws IOException { GroupBuilder gbuilder = new GroupBuilder(); Option inputOpt = DefaultOptionCreator.inputOption().withRequired(false).create(); Option outputOpt = DefaultOptionCreator.outputOption().withRequired(false).create(); Option helpOpt = DefaultOptionCreator.helpOption(); Group group = gbuilder.withName("Options").withOption(inputOpt).withOption(outputOpt).withOption(helpOpt) .create();// w w w . j a v a 2 s .c o m try { Parser parser = new Parser(); parser.setGroup(group); CommandLine cmdLine = parser.parse(args); if (cmdLine.hasOption(helpOpt)) { CommandLineUtil.printHelp(group); return; } String input = cmdLine.getValue(inputOpt, "testdata").toString(); String output = cmdLine.getValue(outputOpt, "output").toString(); runJob(input, output); } catch (OptionException e) { OutputDriver.LOG.error("Exception parsing command line: ", e); CommandLineUtil.printHelp(group); } }
From source file:org.apache.mahout.df.BreimanExample.java
@Override public int run(String[] args) throws IOException { DefaultOptionBuilder obuilder = new DefaultOptionBuilder(); ArgumentBuilder abuilder = new ArgumentBuilder(); GroupBuilder gbuilder = new GroupBuilder(); Option dataOpt = obuilder.withLongName("data").withShortName("d").withRequired(true) .withArgument(abuilder.withName("path").withMinimum(1).withMaximum(1).create()) .withDescription("Data path").create(); Option datasetOpt = obuilder.withLongName("dataset").withShortName("ds").withRequired(true) .withArgument(abuilder.withName("dataset").withMinimum(1).withMaximum(1).create()) .withDescription("Dataset path").create(); Option nbtreesOpt = obuilder.withLongName("nbtrees").withShortName("t").withRequired(true) .withArgument(abuilder.withName("nbtrees").withMinimum(1).withMaximum(1).create()) .withDescription("Number of trees to grow, each iteration").create(); Option nbItersOpt = obuilder.withLongName("iterations").withShortName("i").withRequired(true) .withArgument(abuilder.withName("numIterations").withMinimum(1).withMaximum(1).create()) .withDescription("Number of times to repeat the test").create(); Option helpOpt = obuilder.withLongName("help").withDescription("Print out help").withShortName("h") .create();//from w ww . j av a 2s .co m Group group = gbuilder.withName("Options").withOption(dataOpt).withOption(datasetOpt).withOption(nbItersOpt) .withOption(nbtreesOpt).withOption(helpOpt).create(); Path dataPath; Path datasetPath; int nbTrees; int nbIterations; try { Parser parser = new Parser(); parser.setGroup(group); CommandLine cmdLine = parser.parse(args); if (cmdLine.hasOption("help")) { CommandLineUtil.printHelp(group); return -1; } String dataName = cmdLine.getValue(dataOpt).toString(); String datasetName = cmdLine.getValue(datasetOpt).toString(); nbTrees = Integer.parseInt(cmdLine.getValue(nbtreesOpt).toString()); nbIterations = Integer.parseInt(cmdLine.getValue(nbItersOpt).toString()); dataPath = new Path(dataName); datasetPath = new Path(datasetName); } catch (OptionException e) { log.error("Error while parsing options", e); CommandLineUtil.printHelp(group); return -1; } // load the data FileSystem fs = dataPath.getFileSystem(new Configuration()); Dataset dataset = Dataset.load(getConf(), datasetPath); Data data = DataLoader.loadData(dataset, fs, dataPath); // take m to be the first integer less than log2(M) + 1, where M is the // number of inputs int m = (int) Math.floor(Maths.log(2, data.getDataset().nbAttributes()) + 1); Random rng = RandomUtils.getRandom(); for (int iteration = 0; iteration < nbIterations; iteration++) { log.info("Iteration {}", iteration); runIteration(rng, data, m, nbTrees); } log.info("********************************************"); log.info("Selection error : {}", sumTestErr / nbIterations); log.info("Single Input error : {}", sumOneErr / nbIterations); log.info("One Tree error : {}", sumTreeErr / nbIterations); log.info("Mean Random Input Time : {}", DFUtils.elapsedTime(sumTimeM / nbIterations)); log.info("Mean Single Input Time : {}", DFUtils.elapsedTime(sumTimeOne / nbIterations)); log.info("Mean Random Input Num Nodes : {}", numNodesM / nbIterations); log.info("Mean Single Input Num Nodes : {}", numNodesOne / nbIterations); return 0; }
From source file:org.apache.mahout.df.mapred.BuildForest.java
@Override public int run(String[] args) throws IOException { DefaultOptionBuilder obuilder = new DefaultOptionBuilder(); ArgumentBuilder abuilder = new ArgumentBuilder(); GroupBuilder gbuilder = new GroupBuilder(); Option oobOpt = obuilder.withShortName("oob").withRequired(false) .withDescription("Optional, estimate the out-of-bag error").create(); Option dataOpt = obuilder.withLongName("data").withShortName("d").withRequired(true) .withArgument(abuilder.withName("path").withMinimum(1).withMaximum(1).create()) .withDescription("Data path").create(); Option datasetOpt = obuilder.withLongName("dataset").withShortName("ds").withRequired(true) .withArgument(abuilder.withName("dataset").withMinimum(1).withMaximum(1).create()) .withDescription("Dataset path").create(); Option selectionOpt = obuilder.withLongName("selection").withShortName("sl").withRequired(true) .withArgument(abuilder.withName("m").withMinimum(1).withMaximum(1).create()) .withDescription("Number of variables to select randomly at each tree-node").create(); Option seedOpt = obuilder.withLongName("seed").withShortName("sd").withRequired(false) .withArgument(abuilder.withName("seed").withMinimum(1).withMaximum(1).create()) .withDescription("Optional, seed value used to initialise the Random number generator").create(); Option partialOpt = obuilder.withLongName("partial").withShortName("p").withRequired(false) .withDescription("Optional, use the Partial Data implementation").create(); Option nbtreesOpt = obuilder.withLongName("nbtrees").withShortName("t").withRequired(true) .withArgument(abuilder.withName("nbtrees").withMinimum(1).withMaximum(1).create()) .withDescription("Number of trees to grow").create(); Option helpOpt = obuilder.withLongName("help").withDescription("Print out help").withShortName("h") .create();/*from w w w. ja va 2s.c om*/ Group group = gbuilder.withName("Options").withOption(oobOpt).withOption(dataOpt).withOption(datasetOpt) .withOption(selectionOpt).withOption(seedOpt).withOption(partialOpt).withOption(nbtreesOpt) .withOption(helpOpt).create(); try { Parser parser = new Parser(); parser.setGroup(group); CommandLine cmdLine = parser.parse(args); if (cmdLine.hasOption("help")) { CommandLineUtil.printHelp(group); return -1; } isPartial = cmdLine.hasOption(partialOpt); isOob = cmdLine.hasOption(oobOpt); String dataName = cmdLine.getValue(dataOpt).toString(); String datasetName = cmdLine.getValue(datasetOpt).toString(); m = Integer.parseInt(cmdLine.getValue(selectionOpt).toString()); nbTrees = Integer.parseInt(cmdLine.getValue(nbtreesOpt).toString()); if (cmdLine.hasOption(seedOpt)) { seed = Long.valueOf(cmdLine.getValue(seedOpt).toString()); } log.debug("data : {}", dataName); log.debug("dataset : {}", datasetName); log.debug("m : {}", m); log.debug("seed : {}", seed); log.debug("nbtrees : {}", nbTrees); log.debug("isPartial : {}", isPartial); log.debug("isOob : {}", isOob); dataPath = new Path(dataName); datasetPath = new Path(datasetName); } catch (OptionException e) { log.error("Error while parsing options", e); CommandLineUtil.printHelp(group); return -1; } buildForest(); return 0; }
From source file:org.apache.mahout.df.mapreduce.BuildForest.java
@Override public int run(String[] args) throws IOException, ClassNotFoundException, InterruptedException { DefaultOptionBuilder obuilder = new DefaultOptionBuilder(); ArgumentBuilder abuilder = new ArgumentBuilder(); GroupBuilder gbuilder = new GroupBuilder(); Option oobOpt = obuilder.withShortName("oob").withRequired(false) .withDescription("Optional, estimate the out-of-bag error").create(); Option dataOpt = obuilder.withLongName("data").withShortName("d").withRequired(true) .withArgument(abuilder.withName("path").withMinimum(1).withMaximum(1).create()) .withDescription("Data path").create(); Option datasetOpt = obuilder.withLongName("dataset").withShortName("ds").withRequired(true) .withArgument(abuilder.withName("dataset").withMinimum(1).withMaximum(1).create()) .withDescription("Dataset path").create(); Option selectionOpt = obuilder.withLongName("selection").withShortName("sl").withRequired(true) .withArgument(abuilder.withName("m").withMinimum(1).withMaximum(1).create()) .withDescription("Number of variables to select randomly at each tree-node").create(); Option seedOpt = obuilder.withLongName("seed").withShortName("sd").withRequired(false) .withArgument(abuilder.withName("seed").withMinimum(1).withMaximum(1).create()) .withDescription("Optional, seed value used to initialise the Random number generator").create(); Option partialOpt = obuilder.withLongName("partial").withShortName("p").withRequired(false) .withDescription("Optional, use the Partial Data implementation").create(); Option nbtreesOpt = obuilder.withLongName("nbtrees").withShortName("t").withRequired(true) .withArgument(abuilder.withName("nbtrees").withMinimum(1).withMaximum(1).create()) .withDescription("Number of trees to grow").create(); Option outputOpt = obuilder.withLongName("output").withShortName("o").withRequired(true) .withArgument(abuilder.withName("path").withMinimum(1).withMaximum(1).create()) .withDescription("Output path, will contain the Decision Forest").create(); Option helpOpt = obuilder.withLongName("help").withDescription("Print out help").withShortName("h") .create();/*www .j av a2 s .c o m*/ Group group = gbuilder.withName("Options").withOption(oobOpt).withOption(dataOpt).withOption(datasetOpt) .withOption(selectionOpt).withOption(seedOpt).withOption(partialOpt).withOption(nbtreesOpt) .withOption(outputOpt).withOption(helpOpt).create(); try { Parser parser = new Parser(); parser.setGroup(group); CommandLine cmdLine = parser.parse(args); if (cmdLine.hasOption("help")) { CommandLineUtil.printHelp(group); return -1; } isPartial = cmdLine.hasOption(partialOpt); isOob = cmdLine.hasOption(oobOpt); String dataName = cmdLine.getValue(dataOpt).toString(); String datasetName = cmdLine.getValue(datasetOpt).toString(); String outputName = cmdLine.getValue(outputOpt).toString(); m = Integer.parseInt(cmdLine.getValue(selectionOpt).toString()); nbTrees = Integer.parseInt(cmdLine.getValue(nbtreesOpt).toString()); if (cmdLine.hasOption(seedOpt)) { seed = Long.valueOf(cmdLine.getValue(seedOpt).toString()); } log.debug("data : {}", dataName); log.debug("dataset : {}", datasetName); log.debug("output : {}", outputName); log.debug("m : {}", m); log.debug("seed : {}", seed); log.debug("nbtrees : {}", nbTrees); log.debug("isPartial : {}", isPartial); log.debug("isOob : {}", isOob); dataPath = new Path(dataName); datasetPath = new Path(datasetName); outputPath = new Path(outputName); } catch (OptionException e) { log.error("Exception", e); CommandLineUtil.printHelp(group); return -1; } buildForest(); return 0; }
From source file:org.apache.mahout.df.mapreduce.TestForest.java
@Override public int run(String[] args) throws IOException, ClassNotFoundException, InterruptedException { DefaultOptionBuilder obuilder = new DefaultOptionBuilder(); ArgumentBuilder abuilder = new ArgumentBuilder(); GroupBuilder gbuilder = new GroupBuilder(); Option inputOpt = obuilder.withLongName("input").withShortName("i").withRequired(true) .withArgument(abuilder.withName("path").withMinimum(1).withMaximum(1).create()) .withDescription("Test data path").create(); Option datasetOpt = obuilder.withLongName("dataset").withShortName("ds").withRequired(true) .withArgument(abuilder.withName("dataset").withMinimum(1).withMaximum(1).create()) .withDescription("Dataset path").create(); Option modelOpt = obuilder.withLongName("model").withShortName("m").withRequired(true) .withArgument(abuilder.withName("path").withMinimum(1).withMaximum(1).create()) .withDescription("Path to the Decision Forest").create(); Option outputOpt = obuilder.withLongName("output").withShortName("o").withRequired(false) .withArgument(abuilder.withName("output").withMinimum(1).withMaximum(1).create()) .withDescription("Path to generated predictions file").create(); Option analyzeOpt = obuilder.withLongName("analyze").withShortName("a").withRequired(false).create(); Option mrOpt = obuilder.withLongName("mapreduce").withShortName("mr").withRequired(false).create(); Option helpOpt = obuilder.withLongName("help").withDescription("Print out help").withShortName("h") .create();//w ww .ja v a 2 s .co m Group group = gbuilder.withName("Options").withOption(inputOpt).withOption(datasetOpt).withOption(modelOpt) .withOption(outputOpt).withOption(analyzeOpt).withOption(mrOpt).withOption(helpOpt).create(); try { Parser parser = new Parser(); parser.setGroup(group); CommandLine cmdLine = parser.parse(args); if (cmdLine.hasOption("help")) { CommandLineUtil.printHelp(group); return -1; } String dataName = cmdLine.getValue(inputOpt).toString(); String datasetName = cmdLine.getValue(datasetOpt).toString(); String modelName = cmdLine.getValue(modelOpt).toString(); String outputName = (cmdLine.hasOption(outputOpt)) ? cmdLine.getValue(outputOpt).toString() : null; analyze = cmdLine.hasOption(analyzeOpt); useMapreduce = cmdLine.hasOption(mrOpt); log.debug("inout : {}", dataName); log.debug("dataset : {}", datasetName); log.debug("model : {}", modelName); log.debug("output : {}", outputName); log.debug("analyze : {}", analyze); log.debug("mapreduce : {}", useMapreduce); dataPath = new Path(dataName); datasetPath = new Path(datasetName); modelPath = new Path(modelName); if (outputName != null) { outputPath = new Path(outputName); } } catch (OptionException e) { System.err.println("Exception : " + e); CommandLineUtil.printHelp(group); return -1; } testForest(); return 0; }