List of usage examples for org.apache.commons.cli2.commandline Parser parse
public CommandLine parse(final String[] arguments) throws OptionException
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 av a 2 s .c om 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 {/* ww w. ja v a 2 s . c om*/ 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();/*from ww w. j ava 2 s.co 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 ww w .j a va2 s . c o 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();//w w w. j a v a 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();/*from w w w . j a va 2 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();/*from www. j a 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; }
From source file:org.apache.mahout.df.tools.Describe.java
public static void main(String[] args) throws IOException, DescriptorException { DefaultOptionBuilder obuilder = new DefaultOptionBuilder(); ArgumentBuilder abuilder = new ArgumentBuilder(); GroupBuilder gbuilder = new GroupBuilder(); Option pathOpt = obuilder.withLongName("path").withShortName("p").withRequired(true) .withArgument(abuilder.withName("path").withMinimum(1).withMaximum(1).create()) .withDescription("Data path").create(); Option descriptorOpt = obuilder.withLongName("descriptor").withShortName("d").withRequired(true) .withArgument(abuilder.withName("descriptor").withMinimum(1).create()) .withDescription("data descriptor").create(); Option descPathOpt = obuilder.withLongName("file").withShortName("f").withRequired(true) .withArgument(abuilder.withName("file").withMinimum(1).withMaximum(1).create()) .withDescription("Path to generated descriptor file").create(); Option helpOpt = obuilder.withLongName("help").withDescription("Print out help").withShortName("h") .create();//from w w w . j ava 2 s .co m Group group = gbuilder.withName("Options").withOption(pathOpt).withOption(descPathOpt) .withOption(descriptorOpt).withOption(helpOpt).create(); try { Parser parser = new Parser(); parser.setGroup(group); CommandLine cmdLine = parser.parse(args); if (cmdLine.hasOption(helpOpt)) { CommandLineUtil.printHelp(group); return; } String dataPath = cmdLine.getValue(pathOpt).toString(); String descPath = cmdLine.getValue(descPathOpt).toString(); List<String> descriptor = convert(cmdLine.getValues(descriptorOpt)); log.debug("Data path : {}", dataPath); log.debug("Descriptor path : {}", descPath); log.debug("Descriptor : {}", descriptor); runTool(dataPath, descriptor, descPath); } catch (OptionException e) { log.warn(e.toString()); CommandLineUtil.printHelp(group); } }
From source file:org.apache.mahout.fpm.pfpgrowth.DeliciousTagsExample.java
public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException { DefaultOptionBuilder obuilder = new DefaultOptionBuilder(); ArgumentBuilder abuilder = new ArgumentBuilder(); GroupBuilder gbuilder = new GroupBuilder(); Option inputDirOpt = DefaultOptionCreator.inputOption().create(); Option outputOpt = DefaultOptionCreator.outputOption().create(); Option helpOpt = DefaultOptionCreator.helpOption(); Option recordSplitterOpt = obuilder.withLongName("splitterPattern") .withArgument(abuilder.withName("splitterPattern").withMinimum(1).withMaximum(1).create()) .withDescription("Regular Expression pattern used to split given line into fields." + " Default value splits comma or tab separated fields." + " Default Value: \"[ ,\\t]*\\t[ ,\\t]*\" ") .withShortName("regex").create(); Option encodingOpt = obuilder.withLongName("encoding") .withArgument(abuilder.withName("encoding").withMinimum(1).withMaximum(1).create()) .withDescription("(Optional) The file encoding. Default value: UTF-8").withShortName("e").create(); Group group = gbuilder.withName("Options").withOption(inputDirOpt).withOption(outputOpt).withOption(helpOpt) .withOption(recordSplitterOpt).withOption(encodingOpt).create(); try {/*from w w w.j av a2s . c o m*/ Parser parser = new Parser(); parser.setGroup(group); CommandLine cmdLine = parser.parse(args); if (cmdLine.hasOption(helpOpt)) { CommandLineUtil.printHelp(group); return; } Parameters params = new Parameters(); if (cmdLine.hasOption(recordSplitterOpt)) { params.set("splitPattern", (String) cmdLine.getValue(recordSplitterOpt)); } String encoding = "UTF-8"; if (cmdLine.hasOption(encodingOpt)) { encoding = (String) cmdLine.getValue(encodingOpt); } params.set("encoding", encoding); String inputDir = (String) cmdLine.getValue(inputDirOpt); String outputDir = (String) cmdLine.getValue(outputOpt); params.set("input", inputDir); params.set("output", outputDir); params.set("groupingFieldCount", "2"); params.set("gfield0", "1"); params.set("gfield1", "2"); params.set("selectedFieldCount", "1"); params.set("field0", "3"); params.set("maxTransactionLength", "100"); KeyBasedStringTupleGrouper.startJob(params); } catch (OptionException ex) { CommandLineUtil.printHelp(group); } }
From source file:org.apache.mahout.fpm.pfpgrowth.FPGrowthDriver.java
/** * Run TopK FPGrowth given the input file, *///from w ww. java2s . c o m public static void main(String[] args) throws Exception { DefaultOptionBuilder obuilder = new DefaultOptionBuilder(); ArgumentBuilder abuilder = new ArgumentBuilder(); GroupBuilder gbuilder = new GroupBuilder(); Option inputDirOpt = obuilder.withLongName("input").withRequired(true) .withArgument(abuilder.withName("input").withMinimum(1).withMaximum(1).create()) .withDescription("The Directory on HDFS containing the transaction files").withShortName("i") .create(); Option outputOpt = DefaultOptionCreator.outputOption().create(); Option helpOpt = DefaultOptionCreator.helpOption(); // minSupport(3), maxHeapSize(50), numGroups(1000) Option minSupportOpt = obuilder.withLongName("minSupport") .withArgument(abuilder.withName("minSupport").withMinimum(1).withMaximum(1).create()) .withDescription("(Optional) Minimum Support. Default Value: 3").withShortName("s").create(); Option maxHeapSizeOpt = obuilder.withLongName("maxHeapSize") .withArgument(abuilder.withName("maxHeapSize").withMinimum(1).withMaximum(1).create()) .withDescription( "(Optional) Maximum Heap Size k, to denote the requirement to mine top K items. Default value: 50") .withShortName("k").create(); Option numGroupsOpt = obuilder.withLongName("numGroups") .withArgument(abuilder.withName("numGroups").withMinimum(1).withMaximum(1).create()) .withDescription( "(Optional) Number of groups the features should be divided in the map-reduce version." + " Doesn't work in sequential version Default Value:1000") .withShortName("g").create(); Option recordSplitterOpt = obuilder.withLongName("splitterPattern") .withArgument(abuilder.withName("splitterPattern").withMinimum(1).withMaximum(1).create()) .withDescription("Regular Expression pattern used to split given string transaction into itemsets." + " Default value splits comma separated itemsets. Default Value:" + " \"[ ,\\t]*[,|\\t][ ,\\t]*\" ") .withShortName("regex").create(); Option treeCacheOpt = obuilder.withLongName("numTreeCacheEntries") .withArgument(abuilder.withName("numTreeCacheEntries").withMinimum(1).withMaximum(1).create()) .withDescription( "(Optional) Number of entries in the tree cache to prevent duplicate tree building. " + "(Warning) a first level conditional FP-Tree might consume a lot of memory, " + "so keep this value small, but big enough to prevent duplicate tree building. " + "Default Value:5 Recommended Values: [5-10]") .withShortName("tc").create(); Option methodOpt = obuilder.withLongName("method").withRequired(true) .withArgument(abuilder.withName("method").withMinimum(1).withMaximum(1).create()) .withDescription("Method of processing: sequential|mapreduce").withShortName("method").create(); Option encodingOpt = obuilder.withLongName("encoding") .withArgument(abuilder.withName("encoding").withMinimum(1).withMaximum(1).create()) .withDescription("(Optional) The file encoding. Default value: UTF-8").withShortName("e").create(); Group group = gbuilder.withName("Options").withOption(minSupportOpt).withOption(inputDirOpt) .withOption(outputOpt).withOption(maxHeapSizeOpt).withOption(numGroupsOpt).withOption(methodOpt) .withOption(encodingOpt).withOption(helpOpt).withOption(treeCacheOpt).withOption(recordSplitterOpt) .create(); try { Parser parser = new Parser(); parser.setGroup(group); CommandLine cmdLine = parser.parse(args); if (cmdLine.hasOption(helpOpt)) { CommandLineUtil.printHelp(group); return; } Parameters params = new Parameters(); if (cmdLine.hasOption(minSupportOpt)) { String minSupportString = (String) cmdLine.getValue(minSupportOpt); params.set("minSupport", minSupportString); } if (cmdLine.hasOption(maxHeapSizeOpt)) { String maxHeapSizeString = (String) cmdLine.getValue(maxHeapSizeOpt); params.set("maxHeapSize", maxHeapSizeString); } if (cmdLine.hasOption(numGroupsOpt)) { String numGroupsString = (String) cmdLine.getValue(numGroupsOpt); params.set("numGroups", numGroupsString); } if (cmdLine.hasOption(treeCacheOpt)) { String numTreeCacheString = (String) cmdLine.getValue(treeCacheOpt); params.set("treeCacheSize", numTreeCacheString); } if (cmdLine.hasOption(recordSplitterOpt)) { String patternString = (String) cmdLine.getValue(recordSplitterOpt); params.set("splitPattern", patternString); } String encoding = "UTF-8"; if (cmdLine.hasOption(encodingOpt)) { encoding = (String) cmdLine.getValue(encodingOpt); } params.set("encoding", encoding); Path inputDir = new Path(cmdLine.getValue(inputDirOpt).toString()); Path outputDir = new Path(cmdLine.getValue(outputOpt).toString()); params.set("input", inputDir.toString()); params.set("output", outputDir.toString()); String classificationMethod = (String) cmdLine.getValue(methodOpt); if (classificationMethod.equalsIgnoreCase("sequential")) { runFPGrowth(params); } else if (classificationMethod.equalsIgnoreCase("mapreduce")) { HadoopUtil.overwriteOutput(outputDir); PFPGrowth.runPFPGrowth(params); } } catch (OptionException e) { CommandLineUtil.printHelp(group); } }