List of usage examples for org.apache.commons.cli HelpFormatter setWidth
public void setWidth(int width)
From source file:wikiduper.application.GetSentenceClusters.java
@SuppressWarnings("static-access") @Override/*from w w w .ja v a 2 s . co m*/ public int run(String[] args) throws Exception { Options options = new Options(); options.addOption( OptionBuilder.withArgName("path").hasArg().withDescription("bz2 input path").create(INPUT)); options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("output path").create(OUTPUT)); options.addOption(OptionBuilder.withArgName("en|sv|de|cs|es|zh|ar|tr").hasArg() .withDescription("two-letter language code").create(LANGUAGE_OPTION)); options.addOption(OptionBuilder.withArgName("num").hasArg().withDescription("number of reducers") .create(NUM_REDUCERS)); //options.addOption(OptionBuilder.withArgName("path") // .hasArg().withDescription("pair file").create(PAIRFILE)); options.addOption( OptionBuilder.withArgName("path").hasArg().withDescription("cluster map file").create(CLUSTERMAP)); //options.addOption(OptionBuilder.withArgName("path") // .hasArg().withDescription("index file").create(INDEXFILE)); //options.addOption(OptionBuilder.withArgName("path") // .hasArg().withDescription("map file").create(MAPFILE)); CommandLine cmdline; CommandLineParser parser = new GnuParser(); try { cmdline = parser.parse(options, args); } catch (ParseException exp) { System.err.println("Error parsing command line: " + exp.getMessage()); return -1; } if (!cmdline.hasOption(INPUT) || !cmdline.hasOption(OUTPUT) || !cmdline.hasOption(CLUSTERMAP)) { //|| !cmdline.hasOption(INDEXFILE) || !cmdline.hasOption(MAPFILE)) { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(120); formatter.printHelp(this.getClass().getName(), options); ToolRunner.printGenericCommandUsage(System.out); return -1; } String language = "en"; if (cmdline.hasOption(LANGUAGE_OPTION)) { language = cmdline.getOptionValue(LANGUAGE_OPTION); if (language.length() != 2) { System.err.println("Error: \"" + language + "\" unknown language!"); return -1; } } String inputPath = cmdline.getOptionValue(INPUT); String outputPath = cmdline.getOptionValue(OUTPUT); //String pairPath = cmdline.getOptionValue(PAIRFILE); String clusterPath = cmdline.getOptionValue(CLUSTERMAP); //String indexPath = cmdline.getOptionValue(INDEXFILE); //String mapPath = cmdline.getOptionValue(MAPFILE); int reduceTasks = cmdline.hasOption(NUM_REDUCERS) ? Integer.parseInt(cmdline.getOptionValue(NUM_REDUCERS)) : 1; LOG.info("Tool name: " + this.getClass().getName()); LOG.info(" - bz2 file: " + inputPath); LOG.info(" - output file: " + outputPath); LOG.info(" - language: " + language); JobConf conf = new JobConf(getConf(), GetSentenceClusters.class); //conf.set("indexfile", indexPath); //conf.set("mapfile", mapPath); /* Get Clusters from MinhashWikipediaPages pair output */ //String docmapFile = "docmap.out"; //String remoteDocmapFile = "docmap2.out"; //getClusters(pairPath,conf,docmapFile); //System.exit(-1); //FileSystem fs = FileSystem.get(conf); //fs.copyFromLocalFile(new Path(docmapFile), new Path(remoteDocmapFile)); conf.set("docmapfile", clusterPath); conf.setJobName(String.format("GetSentenceClusters[%s: %s, %s: %s, %s: %s]", INPUT, inputPath, OUTPUT, outputPath, LANGUAGE_OPTION, language)); conf.setNumMapTasks(4); conf.setNumReduceTasks(reduceTasks); FileInputFormat.setInputPaths(conf, new Path(inputPath)); FileOutputFormat.setOutputPath(conf, new Path(outputPath)); if (language != null) { conf.set("wiki.language", language); } conf.setMapperClass(ClusterMapper.class); //conf.setReducerClass(ClusterReducer.class); //conf.setInputFormat(WikipediaPageInputFormat.class); conf.setInputFormat(SequenceFileInputFormat.class); conf.setOutputFormat(SequenceFileOutputFormat.class); // Set heap space - using old API conf.set("mapred.job.map.memory.mb", "2048"); conf.set("mapred.map.child.java.opts", "-Xmx2048m"); conf.set("mapred.job.reduce.memory.mb", "4096"); conf.set("mapred.reduce.child.java.opts", "-Xmx4096m"); conf.setOutputKeyClass(LongWritable.class); conf.setOutputValueClass(PairOfStrings.class); // Delete the output directory if it exists already. Path outputDir = new Path(outputPath); FileSystem.get(conf).delete(outputDir, true); JobClient.runJob(conf); return 0; }
From source file:yaphyre.YaPhyRe.java
private static void printHelp() { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(999); formatter.printHelp("java YaPhyRe", commandLineOptions, true); }