本文整理汇总了Java中org.apache.commons.cli2.builder.DefaultOptionBuilder类的典型用法代码示例。如果您正苦于以下问题:Java DefaultOptionBuilder类的具体用法?Java DefaultOptionBuilder怎么用?Java DefaultOptionBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultOptionBuilder类属于org.apache.commons.cli2.builder包,在下文中一共展示了DefaultOptionBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildOption
import org.apache.commons.cli2.builder.DefaultOptionBuilder; //导入依赖的package包/类
protected static Option buildOption(String name,
String shortName,
String description,
boolean hasArg, int min, int max,
boolean required,
String defaultValue) {
DefaultOptionBuilder optBuilder = new DefaultOptionBuilder().withLongName(name).withDescription(description)
.withRequired(required);
if (shortName != null) {
optBuilder.withShortName(shortName);
}
if (hasArg) {
ArgumentBuilder argBuilder = new ArgumentBuilder().withName(name).withMinimum(min).withMaximum(max);
if (defaultValue != null) {
argBuilder = argBuilder.withDefault(defaultValue);
}
optBuilder.withArgument(argBuilder.create());
}
return optBuilder.create();
}
示例2: main
import org.apache.commons.cli2.builder.DefaultOptionBuilder; //导入依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
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 {
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);
}
}
示例3: inputOption
import org.apache.commons.cli2.builder.DefaultOptionBuilder; //导入依赖的package包/类
/**
* Returns a default command line option for input directory specification.
* Used by all clustering jobs plus others
*/
public static DefaultOptionBuilder inputOption() {
return new DefaultOptionBuilder()
.withLongName(INPUT_OPTION)
.withRequired(false)
.withShortName("i")
.withArgument(
new ArgumentBuilder().withName(INPUT_OPTION).withMinimum(1)
.withMaximum(1).create())
.withDescription("Path to job input directory.");
}
示例4: clustersInOption
import org.apache.commons.cli2.builder.DefaultOptionBuilder; //导入依赖的package包/类
/**
* Returns a default command line option for clusters input directory
* specification. Used by FuzzyKmeans, Kmeans
*/
public static DefaultOptionBuilder clustersInOption() {
return new DefaultOptionBuilder()
.withLongName(CLUSTERS_IN_OPTION)
.withRequired(true)
.withArgument(
new ArgumentBuilder().withName(CLUSTERS_IN_OPTION).withMinimum(1)
.withMaximum(1).create())
.withDescription(
"The path to the initial clusters directory. Must be a SequenceFile of some type of Cluster")
.withShortName("c");
}
示例5: outputOption
import org.apache.commons.cli2.builder.DefaultOptionBuilder; //导入依赖的package包/类
/**
* Returns a default command line option for output directory specification.
* Used by all clustering jobs plus others
*/
public static DefaultOptionBuilder outputOption() {
return new DefaultOptionBuilder()
.withLongName(OUTPUT_OPTION)
.withRequired(false)
.withShortName("o")
.withArgument(
new ArgumentBuilder().withName(OUTPUT_OPTION).withMinimum(1)
.withMaximum(1).create())
.withDescription("The directory pathname for output.");
}
示例6: overwriteOption
import org.apache.commons.cli2.builder.DefaultOptionBuilder; //导入依赖的package包/类
/**
* Returns a default command line option for output directory overwriting.
* Used by all clustering jobs
*/
public static DefaultOptionBuilder overwriteOption() {
return new DefaultOptionBuilder()
.withLongName(OVERWRITE_OPTION)
.withRequired(false)
.withDescription(
"If present, overwrite the output directory before running job")
.withShortName("ow");
}
示例7: distanceMeasureOption
import org.apache.commons.cli2.builder.DefaultOptionBuilder; //导入依赖的package包/类
/**
* Returns a default command line option for specification of distance measure
* class to use. Used by Canopy, FuzzyKmeans, Kmeans, MeanShift
*/
public static DefaultOptionBuilder distanceMeasureOption() {
return new DefaultOptionBuilder()
.withLongName(DISTANCE_MEASURE_OPTION)
.withRequired(false)
.withShortName("dm")
.withArgument(
new ArgumentBuilder().withName(DISTANCE_MEASURE_OPTION)
.withDefault(SquaredEuclideanDistanceMeasure.class.getName())
.withMinimum(1).withMaximum(1).create())
.withDescription(
"The classname of the DistanceMeasure. Default is SquaredEuclidean");
}
示例8: methodOption
import org.apache.commons.cli2.builder.DefaultOptionBuilder; //导入依赖的package包/类
/**
* Returns a default command line option for specification of sequential or
* parallel operation. Used by Canopy, FuzzyKmeans, Kmeans, MeanShift,
* Dirichlet
*/
public static DefaultOptionBuilder methodOption() {
return new DefaultOptionBuilder()
.withLongName(METHOD_OPTION)
.withRequired(false)
.withShortName("xm")
.withArgument(
new ArgumentBuilder().withName(METHOD_OPTION)
.withDefault(MAPREDUCE_METHOD).withMinimum(1).withMaximum(1)
.create())
.withDescription(
"The execution method to use: sequential or mapreduce. Default is mapreduce");
}
示例9: t1Option
import org.apache.commons.cli2.builder.DefaultOptionBuilder; //导入依赖的package包/类
/**
* Returns a default command line option for specification of T1. Used by
* Canopy, MeanShift
*/
public static DefaultOptionBuilder t1Option() {
return new DefaultOptionBuilder()
.withLongName(T1_OPTION)
.withRequired(true)
.withArgument(
new ArgumentBuilder().withName(T1_OPTION).withMinimum(1)
.withMaximum(1).create()).withDescription("T1 threshold value")
.withShortName(T1_OPTION);
}
示例10: t2Option
import org.apache.commons.cli2.builder.DefaultOptionBuilder; //导入依赖的package包/类
/**
* Returns a default command line option for specification of T2. Used by
* Canopy, MeanShift
*/
public static DefaultOptionBuilder t2Option() {
return new DefaultOptionBuilder()
.withLongName(T2_OPTION)
.withRequired(true)
.withArgument(
new ArgumentBuilder().withName(T2_OPTION).withMinimum(1)
.withMaximum(1).create()).withDescription("T2 threshold value")
.withShortName(T2_OPTION);
}
示例11: t3Option
import org.apache.commons.cli2.builder.DefaultOptionBuilder; //导入依赖的package包/类
/**
* Returns a default command line option for specification of T3 (Reducer T1).
* Used by Canopy
*/
public static DefaultOptionBuilder t3Option() {
return new DefaultOptionBuilder()
.withLongName(T3_OPTION)
.withRequired(false)
.withArgument(
new ArgumentBuilder().withName(T3_OPTION).withMinimum(1)
.withMaximum(1).create())
.withDescription("T3 (Reducer T1) threshold value")
.withShortName(T3_OPTION);
}
示例12: t4Option
import org.apache.commons.cli2.builder.DefaultOptionBuilder; //导入依赖的package包/类
/**
* Returns a default command line option for specification of T4 (Reducer T2).
* Used by Canopy
*/
public static DefaultOptionBuilder t4Option() {
return new DefaultOptionBuilder()
.withLongName(T4_OPTION)
.withRequired(false)
.withArgument(
new ArgumentBuilder().withName(T4_OPTION).withMinimum(1)
.withMaximum(1).create())
.withDescription("T4 (Reducer T2) threshold value")
.withShortName(T4_OPTION);
}
示例13: clusterFilterOption
import org.apache.commons.cli2.builder.DefaultOptionBuilder; //导入依赖的package包/类
/**
* @return a DefaultOptionBuilder for the clusterFilter option
*/
public static DefaultOptionBuilder clusterFilterOption() {
return new DefaultOptionBuilder()
.withLongName(CLUSTER_FILTER_OPTION)
.withShortName("cf")
.withRequired(false)
.withArgument(
new ArgumentBuilder().withName(CLUSTER_FILTER_OPTION).withMinimum(1)
.withMaximum(1).create())
.withDescription("Cluster filter suppresses small canopies from mapper")
.withShortName(CLUSTER_FILTER_OPTION);
}
示例14: maxIterationsOption
import org.apache.commons.cli2.builder.DefaultOptionBuilder; //导入依赖的package包/类
/**
* Returns a default command line option for specification of max number of
* iterations. Used by Dirichlet, FuzzyKmeans, Kmeans, LDA
*/
public static DefaultOptionBuilder maxIterationsOption() {
// default value used by LDA which overrides withRequired(false)
return new DefaultOptionBuilder()
.withLongName(MAX_ITERATIONS_OPTION)
.withRequired(true)
.withShortName("x")
.withArgument(
new ArgumentBuilder().withName(MAX_ITERATIONS_OPTION)
.withDefault("-1").withMinimum(1).withMaximum(1).create())
.withDescription("The maximum number of iterations.");
}
示例15: numClustersOption
import org.apache.commons.cli2.builder.DefaultOptionBuilder; //导入依赖的package包/类
/**
* Returns a default command line option for specification of numbers of
* clusters to create. Used by Dirichlet, FuzzyKmeans, Kmeans
*/
public static DefaultOptionBuilder numClustersOption() {
return new DefaultOptionBuilder()
.withLongName(NUM_CLUSTERS_OPTION)
.withRequired(false)
.withArgument(
new ArgumentBuilder().withName("k").withMinimum(1).withMaximum(1)
.create()).withDescription("The number of clusters to create")
.withShortName("k");
}