You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by je...@apache.org on 2010/07/16 03:31:39 UTC
svn commit: r964654 - in
/mahout/trunk/core/src/main/java/org/apache/mahout/clustering:
dirichlet/DirichletDriver.java fuzzykmeans/FuzzyKMeansDriver.java
lda/LDADriver.java meanshift/MeanShiftCanopyDriver.java
Author: jeastman
Date: Fri Jul 16 01:31:39 2010
New Revision: 964654
URL: http://svn.apache.org/viewvc?rev=964654&view=rev
Log:
MAHOUT-294: Another bit of polishing to replace inlined option building sequences with multi-parameter addOption calls. All tests run
Modified:
mahout/trunk/core/src/main/java/org/apache/mahout/clustering/dirichlet/DirichletDriver.java
mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/FuzzyKMeansDriver.java
mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDADriver.java
mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyDriver.java
Modified: mahout/trunk/core/src/main/java/org/apache/mahout/clustering/dirichlet/DirichletDriver.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/dirichlet/DirichletDriver.java?rev=964654&r1=964653&r2=964654&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/clustering/dirichlet/DirichletDriver.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/clustering/dirichlet/DirichletDriver.java Fri Jul 16 01:31:39 2010
@@ -22,8 +22,6 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
-import org.apache.commons.cli2.builder.ArgumentBuilder;
-import org.apache.commons.cli2.builder.DefaultOptionBuilder;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
@@ -101,17 +99,15 @@ public class DirichletDriver extends Abs
addOption(DefaultOptionCreator.numClustersOption().withRequired(true).create());
addOption(DefaultOptionCreator.overwriteOption().create());
addOption(DefaultOptionCreator.clusteringOption().create());
- addOption(new DefaultOptionBuilder().withLongName(ALPHA_OPTION).withRequired(false).withShortName("m")
- .withArgument(new ArgumentBuilder().withName(ALPHA_OPTION).withDefault("1.0").withMinimum(1).withMaximum(1).create())
- .withDescription("The alpha0 value for the DirichletDistribution. Defaults to 1.0").create());
- addOption(new DefaultOptionBuilder().withLongName(MODEL_DISTRIBUTION_CLASS_OPTION).withRequired(false).withShortName("md")
- .withArgument(new ArgumentBuilder().withName(MODEL_DISTRIBUTION_CLASS_OPTION).withDefault(NormalModelDistribution.class
- .getName()).withMinimum(1).withMaximum(1).create()).withDescription("The ModelDistribution class name. "
- + "Defaults to NormalModelDistribution").create());
- addOption(new DefaultOptionBuilder().withLongName(MODEL_PROTOTYPE_CLASS_OPTION).withRequired(false).withShortName("mp")
- .withArgument(new ArgumentBuilder().withName("prototypeClass").withDefault(RandomAccessSparseVector.class.getName())
- .withMinimum(1).withMaximum(1).create())
- .withDescription("The ModelDistribution prototype Vector class name. Defaults to RandomAccessSparseVector").create());
+ addOption(ALPHA_OPTION, "a0", "The alpha0 value for the DirichletDistribution. Defaults to 1.0", "1.0");
+ addOption(MODEL_DISTRIBUTION_CLASS_OPTION,
+ "md",
+ "The ModelDistribution class name. Defaults to NormalModelDistribution",
+ NormalModelDistribution.class.getName());
+ addOption(MODEL_PROTOTYPE_CLASS_OPTION,
+ "mp",
+ "The ModelDistribution prototype Vector class name. Defaults to RandomAccessSparseVector",
+ RandomAccessSparseVector.class.getName());
addOption(DefaultOptionCreator.emitMostLikelyOption().create());
addOption(DefaultOptionCreator.thresholdOption().create());
addOption(DefaultOptionCreator.numReducersOption().create());
Modified: mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/FuzzyKMeansDriver.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/FuzzyKMeansDriver.java?rev=964654&r1=964653&r2=964654&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/FuzzyKMeansDriver.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/FuzzyKMeansDriver.java Fri Jul 16 01:31:39 2010
@@ -22,8 +22,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import org.apache.commons.cli2.builder.ArgumentBuilder;
-import org.apache.commons.cli2.builder.DefaultOptionBuilder;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
@@ -132,9 +130,7 @@ public class FuzzyKMeansDriver extends A
addOption(DefaultOptionCreator.convergenceOption().create());
addOption(DefaultOptionCreator.maxIterationsOption().create());
addOption(DefaultOptionCreator.overwriteOption().create());
- addOption(new DefaultOptionBuilder().withLongName(M_OPTION).withRequired(true).withArgument(new ArgumentBuilder()
- .withName(M_OPTION).withMinimum(1).withMaximum(1).create())
- .withDescription("coefficient normalization factor, must be greater than 1").withShortName(M_OPTION).create());
+ addOption(M_OPTION, M_OPTION,"coefficient normalization factor, must be greater than 1", true);
addOption(DefaultOptionCreator.numReducersOption().create());
//TODO: addOption(DefaultOptionCreator.numMappersOption().create()); but how to set in new Job?
addOption(DefaultOptionCreator.clusteringOption().create());
Modified: mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDADriver.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDADriver.java?rev=964654&r1=964653&r2=964654&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDADriver.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDADriver.java Fri Jul 16 01:31:39 2010
@@ -21,8 +21,6 @@ import java.io.IOException;
import java.util.Map;
import java.util.Random;
-import org.apache.commons.cli2.builder.ArgumentBuilder;
-import org.apache.commons.cli2.builder.DefaultOptionBuilder;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
@@ -167,16 +165,11 @@ public final class LDADriver extends Abs
addInputOption();
addOutputOption();
addOption(DefaultOptionCreator.overwriteOption().create());
- addOption(new DefaultOptionBuilder().withLongName(NUM_TOPICS_OPTION).withRequired(true).withArgument(new ArgumentBuilder()
- .withName(NUM_TOPICS_OPTION).withMinimum(1).withMaximum(1).create())
- .withDescription("The total number of topics in the corpus").withShortName("k").create());
- addOption(new DefaultOptionBuilder().withLongName(NUM_WORDS_OPTION).withRequired(true).withArgument(new ArgumentBuilder()
- .withName(NUM_WORDS_OPTION).withMinimum(1).withMaximum(1).create())
- .withDescription("The total number of words in the corpus (can be approximate, needs to exceed the actual value)")
- .withShortName("v").create());
- addOption(new DefaultOptionBuilder().withLongName(TOPIC_SMOOTHING_OPTION).withRequired(false)
- .withArgument(new ArgumentBuilder().withName(TOPIC_SMOOTHING_OPTION).withDefault(-1.0).withMinimum(0).withMaximum(1)
- .create()).withDescription("Topic smoothing parameter. Default is 50/numTopics.").withShortName("a").create());
+ addOption(NUM_TOPICS_OPTION, "k", "The total number of topics in the corpus", true);
+ addOption(NUM_WORDS_OPTION,
+ "v",
+ "The total number of words in the corpus (can be approximate, needs to exceed the actual value)");
+ addOption(TOPIC_SMOOTHING_OPTION, "a", "Topic smoothing parameter. Default is 50/numTopics.", "-1.0");
addOption(DefaultOptionCreator.maxIterationsOption().withRequired(false).create());
addOption(DefaultOptionCreator.numReducersOption().create());
Modified: mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyDriver.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyDriver.java?rev=964654&r1=964653&r2=964654&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyDriver.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyDriver.java Fri Jul 16 01:31:39 2010
@@ -20,8 +20,6 @@ package org.apache.mahout.clustering.mea
import java.io.IOException;
import java.util.Map;
-import org.apache.commons.cli2.builder.ArgumentBuilder;
-import org.apache.commons.cli2.builder.DefaultOptionBuilder;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
@@ -113,9 +111,9 @@ public class MeanShiftCanopyDriver exten
addOption(DefaultOptionCreator.convergenceOption().create());
addOption(DefaultOptionCreator.maxIterationsOption().create());
addOption(DefaultOptionCreator.overwriteOption().create());
- addOption(new DefaultOptionBuilder().withLongName(INPUT_IS_CANOPIES_OPTION).withRequired(false).withShortName("ic")
- .withArgument(new ArgumentBuilder().withName(INPUT_IS_CANOPIES_OPTION).withMinimum(1).withMaximum(1).create())
- .withDescription("If present, the input directory already contains MeanShiftCanopies").create());
+ addOption(INPUT_IS_CANOPIES_OPTION,
+ INPUT_IS_CANOPIES_OPTION,
+ "If present, the input directory already contains MeanShiftCanopies");
addOption(DefaultOptionCreator.distanceMeasureOption().create());
addOption(DefaultOptionCreator.t1Option().create());
addOption(DefaultOptionCreator.t2Option().create());