mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r704462 - in /lucene/mahout/trunk: core/src/main/java/org/apache/mahout/cf/taste/hadoop/ core/src/main/java/org/apache/mahout/cf/taste/impl/common/ core/src/main/java/org/apache/mahout/cf/taste/impl/neighborhood/ core/src/main/java/org/apac...
Date Tue, 14 Oct 2008 11:07:48 GMT
Author: srowen
Date: Tue Oct 14 04:07:46 2008
New Revision: 704462

URL: http://svn.apache.org/viewvc?rev=704462&view=rev
Log:
Many more small polishes to use of primitives/objects, etc.

Modified:
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/ByItemIDComparator.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/RandomUtils.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/neighborhood/NearestNUserNeighborhood.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/GenericRecommendedItem.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TopItems.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommender2.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/GenericItemSimilarity.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/BayesFileFormatter.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/Classify.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/ConfusionMatrix.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesClassifier.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesModel.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesThetaNormalizerMapper.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesThetaNormalizerReducer.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/common/BayesFeatureDriver.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/common/BayesFeatureMapper.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/common/BayesTfIdfMapper.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesClassifier.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesModel.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesThetaMapper.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesThetaNormalizerMapper.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesThetaNormalizerReducer.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/FuzzyKMeansDriver.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/SoftCluster.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/Model.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/TanimotoDistanceMeasure.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/fuzzykmeans/TestFuzzyKmeansClustering.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/EvalMapperTest.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/PrepareTwentyNewsgroups.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TestClassifier.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TrainClassifier.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaDatasetCreator.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaXmlSplitter.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/DescriptionUtils.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/ToolCombiner.java
    lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMapperTest.java
    lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/tool/CDInfosToolTest.java

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/ByItemIDComparator.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/ByItemIDComparator.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/ByItemIDComparator.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/ByItemIDComparator.java Tue Oct 14 04:07:46 2008
@@ -22,9 +22,9 @@
 
 final class ByItemIDComparator implements Comparator<ItemPrefWritable>, Serializable {
 
-  private static final ByItemIDComparator instance = new ByItemIDComparator();
+  private static final Comparator instance = new ByItemIDComparator();
 
-  public static ByItemIDComparator getInstance() {
+  public static Comparator getInstance() {
     return instance;
   }
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/RandomUtils.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/RandomUtils.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/RandomUtils.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/RandomUtils.java Tue Oct 14 04:07:46 2008
@@ -46,4 +46,13 @@
     return testSeed ? new MersenneTwisterRNG(STANDARD_SEED) : new MersenneTwisterRNG();
   }
 
+  /**
+   * @return what {@link Double#hashCode()} would return for the same value
+   */
+  public static int hashDouble(double value) {
+    // Just copied from Double.hashCode
+    long bits = Double.doubleToLongBits(value);
+    return (int) (bits ^ (bits >>> 32));
+  }
+
 }

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/neighborhood/NearestNUserNeighborhood.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/neighborhood/NearestNUserNeighborhood.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/neighborhood/NearestNUserNeighborhood.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/neighborhood/NearestNUserNeighborhood.java Tue Oct 14 04:07:46 2008
@@ -21,6 +21,7 @@
 import org.apache.mahout.cf.taste.similarity.UserSimilarity;
 import org.apache.mahout.cf.taste.model.DataModel;
 import org.apache.mahout.cf.taste.model.User;
+import org.apache.mahout.cf.taste.impl.common.RandomUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -131,7 +132,7 @@
 
     @Override
     public int hashCode() {
-      return user.hashCode() ^ Double.valueOf(theCorrelation).hashCode();
+      return user.hashCode() ^ RandomUtils.hashDouble(theCorrelation);
     }
 
     @Override

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/GenericRecommendedItem.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/GenericRecommendedItem.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/GenericRecommendedItem.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/GenericRecommendedItem.java Tue Oct 14 04:07:46 2008
@@ -19,6 +19,7 @@
 
 import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.recommender.RecommendedItem;
+import org.apache.mahout.cf.taste.impl.common.RandomUtils;
 
 import java.io.Serializable;
 
@@ -61,7 +62,7 @@
 
   @Override
   public int hashCode() {
-    return item.hashCode() ^ Double.valueOf(value).hashCode();
+    return item.hashCode() ^ RandomUtils.hashDouble(value);
   }
 
   @Override

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TopItems.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TopItems.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TopItems.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TopItems.java Tue Oct 14 04:07:46 2008
@@ -19,6 +19,7 @@
 
 import org.apache.mahout.cf.taste.common.TasteException;
 import org.apache.mahout.cf.taste.impl.similarity.GenericItemSimilarity;
+import org.apache.mahout.cf.taste.impl.common.RandomUtils;
 import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.Preference;
 import org.apache.mahout.cf.taste.model.User;
@@ -116,8 +117,9 @@
   /**
    * <p>Thanks to tsmorton for suggesting this functionality and writing part of the code.</p>
    *
-   * @see org.apache.mahout.cf.taste.impl.similarity.GenericItemSimilarity#GenericItemCorrelation(Iterable, int)
-   * @see org.apache.mahout.cf.taste.impl.similarity.GenericItemSimilarity#GenericItemCorrelation(org.apache.mahout.cf.taste.similarity.ItemSimilarity , org.apache.mahout.cf.taste.model.DataModel , int)
+   * @see GenericItemSimilarity#GenericItemSimilarity(Iterable, int)
+   * @see GenericItemSimilarity#GenericItemSimilarity(org.apache.mahout.cf.taste.similarity.ItemSimilarity,
+   *  org.apache.mahout.cf.taste.model.DataModel, int)
    */
   public static List<GenericItemSimilarity.ItemItemCorrelation> getTopItemItemCorrelations(
           int howMany, Iterable<GenericItemSimilarity.ItemItemCorrelation> allCorrelations) {
@@ -189,7 +191,7 @@
 
     @Override
     public int hashCode() {
-      return user.hashCode() ^ Double.valueOf(similarity).hashCode();
+      return user.hashCode() ^ RandomUtils.hashDouble(similarity);
     }
 
     @Override

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommender2.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommender2.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommender2.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommender2.java Tue Oct 14 04:07:46 2008
@@ -23,6 +23,7 @@
 import org.apache.mahout.cf.taste.impl.common.FullRunningAverage;
 import org.apache.mahout.cf.taste.impl.common.RefreshHelper;
 import org.apache.mahout.cf.taste.impl.common.RunningAverage;
+import org.apache.mahout.cf.taste.impl.common.RandomUtils;
 import org.apache.mahout.cf.taste.model.DataModel;
 import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.Preference;
@@ -258,7 +259,7 @@
 
     @Override
     public int hashCode() {
-      return cluster1.hashCode() ^ cluster2.hashCode() ^ Double.valueOf(similarity).hashCode();
+      return cluster1.hashCode() ^ cluster2.hashCode() ^ RandomUtils.hashDouble(similarity);
     }
 
     @Override

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/GenericItemSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/GenericItemSimilarity.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/GenericItemSimilarity.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/GenericItemSimilarity.java Tue Oct 14 04:07:46 2008
@@ -34,11 +34,11 @@
 import java.util.NoSuchElementException;
 
 /**
- * <p>A "generic" {@link org.apache.mahout.cf.taste.similarity.ItemSimilarity} which takes a static list of precomputed {@link Item}
+ * <p>A "generic" {@link ItemSimilarity} which takes a static list of precomputed {@link Item}
  * correlations and bases its responses on that alone. The values may have been precomputed
  * offline by another process, stored in a file, and then read and fed into an instance of this class.</p>
  *
- * <p>This is perhaps the best {@link org.apache.mahout.cf.taste.similarity.ItemSimilarity} to use with
+ * <p>This is perhaps the best {@link ItemSimilarity} to use with
  * {@link org.apache.mahout.cf.taste.impl.recommender.GenericItemBasedRecommender}, for now, since the point of item-based
  * recommenders is that they can take advantage of the fact that item similarity is relatively static,
  * can be precomputed, and then used in computation to gain a significant performance advantage.</p>
@@ -63,7 +63,7 @@
   }
 
   /**
-   * <p>Like {@link #GenericItemCorrelation(Iterable)}, but will only keep the specified number of correlations
+   * <p>Like {@link #GenericItemSimilarity(Iterable)}, but will only keep the specified number of correlations
    * from the given {@link Iterable} of correlations. It will keep those with the highest correlation --
    * those that are therefore most important.</p>
    *
@@ -78,15 +78,15 @@
   }
 
   /**
-   * <p>Builds a list of item-item correlations given an {@link org.apache.mahout.cf.taste.similarity.ItemSimilarity} implementation and a
+   * <p>Builds a list of item-item correlations given an {@link ItemSimilarity} implementation and a
    * {@link DataModel}, rather than a list of {@link ItemItemCorrelation}s.</p>
    *
    * <p>It's valid to build a {@link GenericItemSimilarity} this way, but perhaps missing some of the point
    * of an item-based recommender. Item-based recommenders use the assumption that item-item correlations
    * are relatively fixed, and might be known already independent of user preferences. Hence it is useful
-   * to inject that information, using {@link #GenericItemCorrelation(Iterable)}.</p>
+   * to inject that information, using {@link #GenericItemSimilarity(Iterable)}.</p>
    *
-   * @param otherSimilarity other {@link org.apache.mahout.cf.taste.similarity.ItemSimilarity} to get correlations from
+   * @param otherSimilarity other {@link ItemSimilarity} to get correlations from
    * @param dataModel data model to get {@link Item}s from
    * @throws TasteException if an error occurs while accessing the {@link DataModel} items
    */
@@ -97,13 +97,13 @@
   }
 
   /**
-   * <p>Like {@link #GenericItemCorrelation(org.apache.mahout.cf.taste.similarity.ItemSimilarity , DataModel)} )}, but will only
+   * <p>Like {@link #GenericItemSimilarity(ItemSimilarity, DataModel)} )}, but will only
    * keep the specified number of correlations from the given {@link DataModel}.
    * It will keep those with the highest correlation -- those that are therefore most important.</p>
    *
    * <p>Thanks to tsmorton for suggesting this and providing part of the implementation.</p>
    *
-   * @param otherSimilarity other {@link org.apache.mahout.cf.taste.similarity.ItemSimilarity} to get correlations from
+   * @param otherSimilarity other {@link ItemSimilarity} to get correlations from
    * @param dataModel data model to get {@link Item}s from
    * @param maxToKeep maximum number of correlations to keep
    * @throws TasteException if an error occurs while accessing the {@link DataModel} items

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/BayesFileFormatter.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/BayesFileFormatter.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/BayesFileFormatter.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/BayesFileFormatter.java Tue Oct 14 04:07:46 2008
@@ -23,6 +23,7 @@
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
 import org.apache.commons.cli.PosixParser;
+import org.apache.commons.cli.Parser;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.CharArraySet;
 import org.apache.lucene.analysis.Token;
@@ -71,6 +72,7 @@
     Writer writer = new OutputStreamWriter(new FileOutputStream(outputFile),
         charset);
     inputDir.listFiles(new FileProcessor(label, analyzer, charset, writer));
+    // TODO srowen asks why call this when return value isn't used?
     writer.close();
 
   }
@@ -96,6 +98,7 @@
       writer.close();
     } else {
       input.listFiles(new FileProcessor(label, analyzer, charset, outDir));
+      // TODO srowen asks why call this when return value isn't used?
     }
   }
 
@@ -147,7 +150,7 @@
     }
 
     public boolean accept(File file) {
-      if (file.isFile() == true) {
+      if (file.isFile()) {
         try {
           Writer theWriter;
           if (writer == null) {
@@ -172,6 +175,7 @@
         }
       } else {
         file.listFiles(this);
+        // TODO srowen asks why call this when return value isn't used?
       }
       return false;
     }
@@ -276,7 +280,7 @@
     options.addOption(helpOpt);
     CommandLine cmdLine;
     try {
-      PosixParser parser = new PosixParser();
+      Parser parser = new PosixParser();
       cmdLine = parser.parse(options, args);
       if (cmdLine.hasOption(helpOpt.getOpt())) {
         log.info("Options: {}", options);
@@ -298,7 +302,7 @@
       }
       boolean collapse = cmdLine.hasOption(collapseOpt.getOpt());
 
-      if (collapse == true) {
+      if (collapse) {
         collapse(label, analyzer, input, charset, output);
       } else {
         format(label, analyzer, input, charset, output);

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/Classify.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/Classify.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/Classify.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/Classify.java Tue Oct 14 04:07:46 2008
@@ -22,6 +22,7 @@
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
 import org.apache.commons.cli.PosixParser;
+import org.apache.commons.cli.Parser;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.mapred.JobConf;
@@ -69,7 +70,7 @@
     Option typeOpt = OptionBuilder.withLongOpt("classifierType").isRequired().hasArg().withDescription("Type of classifier").create("type");
     options.addOption(typeOpt);
 
-    PosixParser parser = new PosixParser();
+    Parser parser = new PosixParser();
     CommandLine cmdLine = parser.parse(options, args);
     SequenceFileModelReader reader = new SequenceFileModelReader();
     JobConf conf = new JobConf(Classify.class);

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/ConfusionMatrix.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/ConfusionMatrix.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/ConfusionMatrix.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/ConfusionMatrix.java Tue Oct 14 04:07:46 2008
@@ -1,12 +1,5 @@
 package org.apache.mahout.classifier;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.mahout.common.Summarizable;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements. See the NOTICE file distributed with this
@@ -14,9 +7,9 @@
  * licenses this file to You under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -24,6 +17,14 @@
  * the License.
  */
 
+import org.apache.commons.lang.StringUtils;
+import org.apache.mahout.common.Summarizable;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * The ConfusionMatrix Class stores the result of Classification of a Test Dataset.
  */
@@ -44,7 +45,7 @@
   }
   
   public float getAccuracy(String label){
-    int labelId = labelMap.get(label).intValue();
+    int labelId = labelMap.get(label);
     int labelTotal = 0;
     int correct = 0;    
     for(int i = 0 ;i < labels.size() ;i++){
@@ -55,12 +56,12 @@
   }
   
   public int getCorrect(String label){
-    int labelId = labelMap.get(label).intValue();
+    int labelId = labelMap.get(label);
     return confusionMatrix[labelId][labelId];
   }
   
   public float getTotal(String label){
-    int labelId = labelMap.get(label).intValue();
+    int labelId = labelMap.get(label);
     int labelTotal = 0;
     for(int i = 0 ;i < labels.size() ;i++){
       labelTotal+= confusionMatrix[labelId][i];
@@ -90,8 +91,8 @@
         && this.getLabels().contains(classifiedLabel) == false) {
       throw new IllegalArgumentException("Label not found " +correctLabel + " " +classifiedLabel );
     }
-    int correctId = labelMap.get(correctLabel).intValue();
-    int classifiedId = labelMap.get(classifiedLabel).intValue();
+    int correctId = labelMap.get(correctLabel);
+    int classifiedId = labelMap.get(classifiedLabel);
     return confusionMatrix[correctId][classifiedId];
   }
 
@@ -100,8 +101,8 @@
         && this.getLabels().contains(classifiedLabel) == false) {
       throw new IllegalArgumentException("Label not found");
     }
-    int correctId = labelMap.get(correctLabel).intValue();
-    int classifiedId = labelMap.get(classifiedLabel).intValue();
+    int correctId = labelMap.get(correctLabel);
+    int classifiedId = labelMap.get(classifiedLabel);
     confusionMatrix[correctId][classifiedId] = count;
   }
 
@@ -139,24 +140,23 @@
         .append("-------------------------------------------------------\n");
 
     for (String correctLabel : this.labels) {
-      returnString.append(StringUtils.rightPad(getSmallLabel(labelMap.get(
-          correctLabel).intValue()), 5)).append('\t');
+      returnString.append(StringUtils.rightPad(getSmallLabel(labelMap.get(correctLabel)), 5)).append('\t');
     }
 
     returnString.append("<--Classified as\n");
 
     for (String correctLabel : this.labels) {
-      Integer labelTotal = 0;
+      int labelTotal = 0;
       for (String classifiedLabel : this.labels) {
         returnString.append(StringUtils.rightPad(Integer.toString(getCount(
             correctLabel, classifiedLabel)), 5)).append('\t');
-        labelTotal+=getCount(correctLabel, classifiedLabel);
+        labelTotal += getCount(correctLabel, classifiedLabel);
       }
-      returnString.append(" |  ").append(StringUtils.rightPad(labelTotal.toString(), 6)).append('\t')
-          .append(StringUtils.rightPad(getSmallLabel(labelMap.get(correctLabel).intValue()), 5))
+      returnString.append(" |  ").append(StringUtils.rightPad(String.valueOf(labelTotal), 6)).append('\t')
+          .append(StringUtils.rightPad(getSmallLabel(labelMap.get(correctLabel)), 5))
           .append(" = ").append(correctLabel).append('\n');
     }
-    returnString.append("\n");
+    returnString.append('\n');
     return returnString.toString();
   }
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesClassifier.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesClassifier.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesClassifier.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesClassifier.java Tue Oct 14 04:07:46 2008
@@ -104,16 +104,15 @@
     Map<String, Integer> wordList = new HashMap<String, Integer>(1000);
     for (String word : document) {
       if (wordList.containsKey(word)) {
-        Integer count = wordList.get(word);
-        count++;
-        wordList.put(word, count);
+        int count = wordList.get(word);
+        wordList.put(word, count + 1);
       } else {
         wordList.put(word, 1);
       }
     }
     for (Map.Entry<String, Integer> entry : wordList.entrySet()) {
       String word = entry.getKey();
-      Integer count = entry.getValue();
+      int count = entry.getValue();
       result += count * model.FeatureWeight(label, word);
     }
     return result;

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesModel.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesModel.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesModel.java Tue Oct 14 04:07:46 2008
@@ -57,9 +57,9 @@
     Map<Integer, Float> featureWeights = featureLabelWeights.get(feature);
 
     if (featureWeights.containsKey(label)) {
-      result = featureWeights.get(label).floatValue();
+      result = featureWeights.get(label);
     } else {
-      result = 0;
+      result = 0.0f;
     }
     return result;
   }
@@ -93,20 +93,22 @@
       float perLabelWeightSumNormalisationFactor = Float.MAX_VALUE;
 
       for (int feature = 0, maxFeatures = featureList.size(); feature < maxFeatures; feature++) {
+        Integer featureInt = feature;
         for (int label = 0, maxLabels = labelList.size(); label < maxLabels; label++) {
 
-          float D_ij = getWeightUnprocessed(label, feature);
-          float sumLabelWeight = getSumLabelWeight(label);
+          Integer labelInt = label;
+          float D_ij = getWeightUnprocessed(labelInt, featureInt);
+          float sumLabelWeight = getSumLabelWeight(labelInt);
           // TODO srowen says sigma_j is unused
-          //float sigma_j = getSumFeatureWeight(feature);
+          //float sigma_j = getSumFeatureWeight(featureInt);
 
           float numerator = D_ij + alpha_i;
           float denominator = sumLabelWeight + vocabCount;
 
-          Float weight = (float) Math.log(numerator / denominator);
+          float weight = (float) Math.log(numerator / denominator);
 
           if (D_ij != 0)
-            setWeight(label, feature, weight);
+            setWeight(labelInt, featureInt, weight);
 
           perLabelThetaNormalizer[label] += weight;
 
@@ -127,13 +129,15 @@
       }
 
       for (int feature = 0, maxFeatures = featureList.size(); feature < maxFeatures; feature++) {
+        Integer featureInt = feature;
         for (int label = 0, maxLabels = labelList.size(); label < maxLabels; label++) {
-          float W_ij = getWeightUnprocessed(label, feature);
+          Integer labelInt = label;
+          float W_ij = getWeightUnprocessed(labelInt, featureInt);
           if (W_ij == 0)
             continue;
           float Sigma_W_ij = perLabelThetaNormalizer[label];
           float normalizedWeight = -1.0f * (W_ij / Sigma_W_ij);
-          setWeight(label, feature, normalizedWeight);
+          setWeight(labelInt, featureInt, normalizedWeight);
         }
       }
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesThetaNormalizerMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesThetaNormalizerMapper.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesThetaNormalizerMapper.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesThetaNormalizerMapper.java Tue Oct 14 04:07:46 2008
@@ -41,11 +41,11 @@
 
   String labelWeightSumString = " ";
 
-  Float sigma_jSigma_k = 0f;
+  Float sigma_jSigma_k = 0.0f;
 
   String sigma_jSigma_kString = " ";
 
-  Float vocabCount = 0f;
+  Float vocabCount = 0.0f;
 
   String vocabCountString = " ";
 
@@ -63,7 +63,7 @@
       throws IOException {
 
     String labelFeaturePair = key.toString();
-    Float alpha_i = 1.0f;
+    float alpha_i = 1.0f;
 
     String label = labelFeaturePair.split(",")[0];
     float weight = (float) Math.log((value.get() + alpha_i) / (labelWeightSum.get(label) + vocabCount));

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesThetaNormalizerReducer.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesThetaNormalizerReducer.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesThetaNormalizerReducer.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/BayesThetaNormalizerReducer.java Tue Oct 14 04:07:46 2008
@@ -39,11 +39,11 @@
 
   String labelWeightSumString = " ";
 
-  Float sigma_jSigma_k = 0f;
+  Float sigma_jSigma_k = 0.0f;
 
   String sigma_jSigma_kString = " ";
 
-  Float vocabCount = 0f;
+  Float vocabCount = 0.0f;
 
   String vocabCountString = " ";
   

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/common/BayesFeatureDriver.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/common/BayesFeatureDriver.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/common/BayesFeatureDriver.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/common/BayesFeatureDriver.java Tue Oct 14 04:07:46 2008
@@ -87,7 +87,7 @@
       dfs.delete(outPath, true);
 
     DefaultStringifier<Integer> intStringifier = new DefaultStringifier<Integer>(conf, Integer.class);
-    String gramSizeString = intStringifier.toString(Integer.valueOf(gramSize));
+    String gramSizeString = intStringifier.toString(gramSize);
 
     Integer retGramSize = intStringifier.fromString(gramSizeString);
     log.info("{}", retGramSize);

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/common/BayesFeatureMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/common/BayesFeatureMapper.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/common/BayesFeatureMapper.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/common/BayesFeatureMapper.java Tue Oct 14 04:07:46 2008
@@ -89,7 +89,7 @@
     for (Map.Entry<String, Integer> entry : wordList.entrySet()) {
       // key is label,word
       String token = entry.getKey();
-      builder.append(",").append(token);
+      builder.append(',').append(token);
       labelWord.set(builder.toString());
       FloatWritable f = new FloatWritable((float) (Math
           .log(1.0 + entry.getValue()) / lengthNormalisation));
@@ -103,7 +103,7 @@
     builder = new StringBuilder(dflabel);
     for (String token : wordList.keySet()) {
       // key is label,word
-      builder.append(",").append(token);
+      builder.append(',').append(token);
       labelWord.set(builder.toString());
       output.collect(labelWord, one);
       output.collect(new Text("," + token), one);

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/common/BayesTfIdfMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/common/BayesTfIdfMapper.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/common/BayesTfIdfMapper.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/common/BayesTfIdfMapper.java Tue Oct 14 04:07:46 2008
@@ -65,8 +65,8 @@
         throw new IOException(label);
       }
       
-      Float labelDocumentCount = labelDocumentCounts.get(label);
-      float logIdf = (float)Math.log(labelDocumentCount.floatValue()  / value.get());
+      float labelDocumentCount = labelDocumentCounts.get(label);
+      float logIdf = (float) Math.log(labelDocumentCount  / value.get());
       
       output.collect(new Text(labelFeaturePair), new FloatWritable(logIdf));
     } else if (labelFeaturePair.startsWith(",")) {

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesClassifier.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesClassifier.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesClassifier.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesClassifier.java Tue Oct 14 04:07:46 2008
@@ -101,16 +101,15 @@
     Map<String, Integer> wordList = new HashMap<String, Integer>(1000);
     for (String word : document) {
       if (wordList.containsKey(word)) {
-        Integer count = wordList.get(word);
-        count++;
-        wordList.put(word, count);
+        int count = wordList.get(word);
+        wordList.put(word, count + 1);
       } else {
         wordList.put(word, 1);
       }      
     }
     for (Map.Entry<String, Integer> entry : wordList.entrySet()) {
       String word = entry.getKey();
-      Integer count = entry.getValue();
+      int count = entry.getValue();
       result += count * model.FeatureWeight(label, word);
     }
     return result;

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesModel.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesModel.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesModel.java Tue Oct 14 04:07:46 2008
@@ -33,7 +33,7 @@
     Map<Integer, Float> featureWeights = featureLabelWeights.get(feature);
 
     if (featureWeights.containsKey(label)) {
-      result = featureWeights.get(label).floatValue();
+      result = featureWeights.get(label);
     }
     float vocabCount = featureList.size();
     float sumLabelWeight = getSumLabelWeight(label);
@@ -53,9 +53,9 @@
     Map<Integer, Float> featureWeights = featureLabelWeights.get(feature);
 
     if (featureWeights.containsKey(label)) {
-      result = featureWeights.get(label).floatValue();
+      result = featureWeights.get(label);
     } else {
-      result = 0;
+      result = 0.0f;
     }
     return result;
   }
@@ -126,19 +126,21 @@
       float perLabelWeightSumNormalisationFactor = Float.MAX_VALUE;
 
       for (int feature = 0, maxFeatures = featureList.size(); feature < maxFeatures; feature++) {
+        Integer featureInt = feature;
         for (int label = 0, maxLabels = labelList.size(); label < maxLabels; label++) {
 
-          float D_ij = getWeightUnprocessed(label, feature);
-          float sumLabelWeight = getSumLabelWeight(label);
-          float sigma_j = getSumFeatureWeight(feature);
+          Integer labelInt = label;
+          float D_ij = getWeightUnprocessed(labelInt, featureInt);
+          float sumLabelWeight = getSumLabelWeight(labelInt);
+          float sigma_j = getSumFeatureWeight(featureInt);
 
           float numerator = (sigma_j - D_ij) + alpha_i;
           float denominator = (sigma_jSigma_k - sumLabelWeight) + vocabCount;
 
-          Float weight = (float) Math.log(numerator / denominator);
+          float weight = (float) Math.log(numerator / denominator);
 
           if (D_ij != 0)
-            setWeight(label, feature, weight);
+            setWeight(labelInt, featureInt, weight);
 
           perLabelThetaNormalizer[label] += weight;
 
@@ -159,13 +161,15 @@
       }
 
       for (int feature = 0, maxFeatures = featureList.size(); feature < maxFeatures; feature++) {
+        Integer featureInt = feature;
         for (int label = 0, maxLabels = labelList.size(); label < maxLabels; label++) {
-          float W_ij = getWeightUnprocessed(label, feature);
+          Integer labelInt = label;
+          float W_ij = getWeightUnprocessed(labelInt, featureInt);
           if (W_ij == 0)
             continue;
           float Sigma_W_ij = perLabelThetaNormalizer[label];
           float normalizedWeight = -1.0f * (W_ij / Sigma_W_ij);
-          setWeight(label, feature, normalizedWeight);
+          setWeight(labelInt, featureInt, normalizedWeight);
         }
       }
   }

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesThetaMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesThetaMapper.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesThetaMapper.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesThetaMapper.java Tue Oct 14 04:07:46 2008
@@ -66,13 +66,13 @@
                                             // (feature weight Sum)
       String feature = labelFeaturePair.substring(1);
       for (String label : labelWeightSum.keySet()) {
-        double inverseDenominator = 1.0d /(sigma_jSigma_k - labelWeightSum.get(label) + vocabCount);
+        double inverseDenominator = 1.0 /(sigma_jSigma_k - labelWeightSum.get(label) + vocabCount);
         FloatWritable weight = new FloatWritable((float)((value.get() + alpha_i)*inverseDenominator ));
         output.collect(new Text((label + "," + feature).trim()), weight); //output Sigma_j
       }
     } else {
       String label = labelFeaturePair.split(",")[0];
-      double inverseDenominator = 1.0d /(sigma_jSigma_k - labelWeightSum.get(label) + vocabCount);
+      double inverseDenominator = 1.0 /(sigma_jSigma_k - labelWeightSum.get(label) + vocabCount);
       FloatWritable weight = new FloatWritable((float)(-1 * value.get()  * inverseDenominator));
       output.collect(key, weight);//output -D_ij       
     }

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesThetaNormalizerMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesThetaNormalizerMapper.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesThetaNormalizerMapper.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesThetaNormalizerMapper.java Tue Oct 14 04:07:46 2008
@@ -41,11 +41,11 @@
 
   String labelWeightSumString = " ";
 
-  Float sigma_jSigma_k = 0.0f;
+  float sigma_jSigma_k = 0.0f;
 
   String sigma_jSigma_kString = " ";
 
-  Float vocabCount = 0.0f;
+  float vocabCount = 0.0f;
 
   String vocabCountString = " ";
 
@@ -64,7 +64,7 @@
       throws IOException {
 
     String labelFeaturePair = key.toString();
-    Float alpha_i = 1.0f;
+    float alpha_i = 1.0f;
     if (labelFeaturePair.startsWith(",")) { // if it is from the Sigma_j folder
            
       for (String label : labelWeightSum.keySet()) {

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesThetaNormalizerReducer.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesThetaNormalizerReducer.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesThetaNormalizerReducer.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/cbayes/CBayesThetaNormalizerReducer.java Tue Oct 14 04:07:46 2008
@@ -40,11 +40,11 @@
 
   String labelWeightSumString = " ";
 
-  Float sigma_jSigma_k = 0f;
+  Float sigma_jSigma_k = 0.0f;
 
   String sigma_jSigma_kString = " ";
 
-  Float vocabCount = 0f;
+  Float vocabCount = 0.0f;
 
   String vocabCountString = " ";
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/FuzzyKMeansDriver.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/FuzzyKMeansDriver.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/FuzzyKMeansDriver.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/FuzzyKMeansDriver.java Tue Oct 14 04:07:46 2008
@@ -21,8 +21,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileUtil;
@@ -35,10 +33,12 @@
 import org.apache.hadoop.mapred.JobClient;
 import org.apache.hadoop.mapred.JobConf;
 import org.apache.hadoop.mapred.SequenceFileOutputFormat;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class FuzzyKMeansDriver {
 
-  private static final Log log = LogFactory.getLog(FuzzyKMeansDriver.class);
+  private static final Logger log = LoggerFactory.getLogger(FuzzyKMeansDriver.class);
 
   private FuzzyKMeansDriver() {
   }

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/SoftCluster.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/SoftCluster.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/SoftCluster.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/SoftCluster.java Tue Oct 14 04:07:46 2008
@@ -191,8 +191,8 @@
     for (int i = 0; i < clusters.size(); i++) {
       double probWeight = computeProbWeight(clusterDistanceList.get(i),
           clusterDistanceList);
-      outputValue.append(clusters.get(i).clusterId).append(":").append(
-          probWeight).append(" ");
+      outputValue.append(clusters.get(i).clusterId).append(':').append(
+          probWeight).append(' ');
     }
     output.collect(new Text(outputKey.trim()), new Text(outputValue.toString()
         .trim()
@@ -209,10 +209,10 @@
   public static double computeProbWeight(double clusterDistance,
       List<Double> clusterDistanceList) {
     double denom = 0.0;
-    if (clusterDistance == 0) {
+    if (clusterDistance == 0.0) {
       clusterDistance = minimalValue;
     }
-    for (Double eachCDist : clusterDistanceList) {
+    for (double eachCDist : clusterDistanceList) {
       if (eachCDist == 0)
         eachCDist = minimalValue;
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/Model.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/Model.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/Model.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/Model.java Tue Oct 14 04:07:46 2008
@@ -64,36 +64,35 @@
   public abstract void GenerateModel();
   
   protected float getSumLabelWeight(Integer label) {
-    float result = 0.0f;
     Float numSeen = sumLabelWeight.get(label);
     if (numSeen != null) {
-      result = numSeen;
+      return numSeen;
+    } else {
+      return 0.0f;
     }
-    return result;
   }
 
   protected float getThetaNormalizer(Integer label) {
-    float result = 0.0f;
     Float numSeen = thetaNormalizer.get(label);
     if (numSeen != null) {
-      result = numSeen;
+      return numSeen;
+    } else {
+      return 0.0f;
     }
-    return result;
   }
 
   protected float getSumFeatureWeight(Integer feature) {
-    float result = 0.0f;
     Float numSeen = sumFeatureWeight.get(feature);
     if (numSeen != null) {
-      result = numSeen;
+      return numSeen;
+    } else {
+      return 0.0f;
     }
-    return result;
   }
 
   protected Integer getLabel(String label) {
     if (!labelList.containsKey(label)) {
-      
-      Integer labelId = Integer.valueOf(labelList.size());
+      Integer labelId = labelList.size();
       labelList.put(label, labelId);
     }
     return labelList.get(label);
@@ -102,7 +101,7 @@
   protected Integer getFeature(String feature) {
     if (!featureList.containsKey(feature)) {
       
-      Integer featureId = Integer.valueOf(featureList.size());
+      Integer featureId = featureList.size();
       featureList.put(feature, featureId);
     }
     return featureList.get(feature);
@@ -206,7 +205,7 @@
         gramBuilder.append(gram);
         String token = gramBuilder.toString();        
         tokens.add(token);
-        gramBuilder.append(" ");
+        gramBuilder.append(' ');
       }
     }
     returnDocument.put(labelName, tokens);

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/TanimotoDistanceMeasure.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/TanimotoDistanceMeasure.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/TanimotoDistanceMeasure.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/TanimotoDistanceMeasure.java Tue Oct 14 04:07:46 2008
@@ -16,10 +16,6 @@
  */
 
 import org.apache.mahout.matrix.Vector;
-import org.apache.mahout.matrix.Matrix;
-import org.apache.mahout.utils.DistanceMeasure;
-import org.apache.mahout.utils.WeightedDistanceMeasure;
-import org.apache.hadoop.mapred.JobConf;
 
 import java.util.HashSet;
 import java.util.Set;
@@ -52,25 +48,25 @@
     
     Set<Integer> featuresSeen = new HashSet<Integer>((int)((vector0.size() + vector1.size()) * 0.75));
 
-    double ab = 0;
-    double a2 = 0;
-    double b2 = 0;
-
-    Double a;
-    Double b;
-    Double weight;
+    double ab = 0.0;
+    double a2 = 0.0;
+    double b2 = 0.0;
 
     for (Vector.Element feature : vector0) {
       if (!featuresSeen.add(feature.index())) {
 
-        a = feature.get();
+        double a = feature.get();
 
-        b = vector1.get(feature.index());
-        if (b == null) {
-          b = 0d;
+        Double bValue = vector1.get(feature.index());
+        double b;
+        if (bValue == null) {
+          b = 0.0;
+        } else {
+          b = bValue;
         }
 
-        weight = getWeights() == null ? 1d : getWeights().get(feature.index());
+        Vector weights = getWeights();
+        double weight = weights == null ? 1.0 : weights.get(feature.index());
 
         ab += a * b * weight;
         a2 += a * a * weight;
@@ -82,14 +78,18 @@
     for (Vector.Element feature : vector1) {
       if (!featuresSeen.add(feature.index())) {
 
-        a = vector0.get(feature.index());
-        if (a == null) {
-          a = 0d;
+        Double aValue = vector0.get(feature.index());
+        double a;
+        if (aValue == null) {
+          a = 0.0;
+        } else {
+          a = aValue;
         }
 
-        b = feature.get();
+        double b = feature.get();
 
-        weight = getWeights() == null ? 1d : getWeights().get(feature.index());
+        Vector weights = getWeights();
+        double weight = weights == null ? 1.0 : weights.get(feature.index());
 
         ab += a * b * weight;
         a2 += a * a * weight;

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/fuzzykmeans/TestFuzzyKmeansClustering.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/fuzzykmeans/TestFuzzyKmeansClustering.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/fuzzykmeans/TestFuzzyKmeansClustering.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/fuzzykmeans/TestFuzzyKmeansClustering.java Tue Oct 14 04:07:46 2008
@@ -130,8 +130,8 @@
       for (int i = 0; i < clusterList.size(); i++) {
         double probWeight = SoftCluster.computeProbWeight(clusterDistanceList
             .get(i), clusterDistanceList);
-        outputValue.append(clusterList.get(i).getClusterId()).append(":")
-            .append(probWeight).append(" ");
+        outputValue.append(clusterList.get(i).getClusterId()).append(':')
+            .append(probWeight).append(' ');
       }
 
       pointClusterInfo.put(point.asFormatString().trim(), outputValue

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/EvalMapperTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/EvalMapperTest.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/EvalMapperTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/EvalMapperTest.java Tue Oct 14 04:07:46 2008
@@ -62,7 +62,7 @@
     Set<String> keys = collector.getKeys();
     assertEquals("Number of evaluations", populationSize, keys.size());
     for (String key : keys) {
-      DummyCandidate candidate = population.get(Integer.valueOf(key));
+      DummyCandidate candidate = population.get(Integer.parseInt(key));
       assertEquals("Values for key " + key, 1, collector.getValue(key).size());
       Float fitness = collector.getValue(key).get(0).get();
       assertEquals("Evaluation of the candidate " + key, DummyEvaluator

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/PrepareTwentyNewsgroups.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/PrepareTwentyNewsgroups.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/PrepareTwentyNewsgroups.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/PrepareTwentyNewsgroups.java Tue Oct 14 04:07:46 2008
@@ -22,6 +22,7 @@
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.PosixParser;
 import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.Parser;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.mahout.classifier.BayesFileFormatter;
 
@@ -52,7 +53,7 @@
     Option charsetOpt = OptionBuilder.withLongOpt("charset").hasArg().isRequired().withDescription("The name of the character encoding of the input files").create("c");
     options.addOption(charsetOpt);
 
-    PosixParser parser = new PosixParser();
+    Parser parser = new PosixParser();
     CommandLine cmdLine = parser.parse(options, args);
 
     File parentDir = new File(cmdLine.getOptionValue(parentOpt.getOpt()));

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TestClassifier.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TestClassifier.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TestClassifier.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TestClassifier.java Tue Oct 14 04:07:46 2008
@@ -23,6 +23,7 @@
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.PosixParser;
 import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.Parser;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.mapred.JobConf;
@@ -81,7 +82,7 @@
         .hasArg().withDescription("Type of classifier").create("type");
     options.addOption(typeOpt);
 
-    PosixParser parser = new PosixParser();
+    Parser parser = new PosixParser();
     CommandLine cmdLine = parser.parse(options, args);
     SequenceFileModelReader reader = new SequenceFileModelReader();
     JobConf conf = new JobConf(TestClassifier.class);

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TrainClassifier.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TrainClassifier.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TrainClassifier.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TrainClassifier.java Tue Oct 14 04:07:46 2008
@@ -22,6 +22,7 @@
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.PosixParser;
 import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.Parser;
 import org.apache.mahout.classifier.cbayes.CBayesDriver;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -74,12 +75,12 @@
     Option typeOpt = OptionBuilder.withLongOpt("classifierType").isRequired().hasArg().withDescription("Type of classifier").create("type");
     options.addOption(typeOpt);
     
-    PosixParser parser = new PosixParser();
+    Parser parser = new PosixParser();
     CommandLine cmdLine = parser.parse(options, args);
 
     boolean train = cmdLine.hasOption(trainOpt.getOpt());
     TrainClassifier tn = new TrainClassifier();
-    if (train == true){
+    if (train){
       String classifierType = cmdLine.getOptionValue(typeOpt.getOpt());
       if(classifierType.equalsIgnoreCase("bayes")){
         log.info("Training Bayes Classifier");

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaDatasetCreator.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaDatasetCreator.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaDatasetCreator.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaDatasetCreator.java Tue Oct 14 04:07:46 2008
@@ -23,6 +23,7 @@
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.PosixParser;
 import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.Parser;
 
 import java.io.IOException;
 
@@ -42,7 +43,7 @@
         .withDescription("Location of the Countries File").create("c");
     options.addOption(countriesFileOpt);
     
-    PosixParser parser = new PosixParser();
+    Parser parser = new PosixParser();
     CommandLine cmdLine = parser.parse(options, args);
 
     String dirInputPath = cmdLine.getOptionValue(dirInputPathOpt.getOpt());

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaXmlSplitter.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaXmlSplitter.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaXmlSplitter.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaXmlSplitter.java Tue Oct 14 04:07:46 2008
@@ -23,6 +23,7 @@
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.PosixParser;
 import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.Parser;
 
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
@@ -33,6 +34,7 @@
 import java.io.OutputStreamWriter;
 import java.io.IOException;
 import java.text.DecimalFormat;
+import java.text.NumberFormat;
 
 public class WikipediaXmlSplitter {
 
@@ -46,7 +48,7 @@
     Option chunkSizeOpt = OptionBuilder.withLongOpt("chunkSize").isRequired().hasArg().withDescription("the Size of chunk in Megabytes").create("c");
     options.addOption(chunkSizeOpt);
 
-    PosixParser parser = new PosixParser();
+    Parser parser = new PosixParser();
     CommandLine cmdLine = parser.parse(options, args);
 
     String dumpFilePath = cmdLine.getOptionValue(dumpFileOpt.getOpt());
@@ -58,7 +60,7 @@
 
     File dir = new File(outputDirPath);
     dir.getPath();
-
+    // TODO srowen asks if the call to getPath() is needed?
 
     String header =
           "<mediawiki xmlns=\"http://www.mediawiki.org/xml/export-0.3/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.mediawiki.org/xml/export-0.3/ http://www.mediawiki.org/xml/export-0.3.xsd\" version=\"0.3\" xml:lang=\"en\">\n"
@@ -89,23 +91,24 @@
         + "      <namespace key=\"101\">Portal talk</namespace>\n"
         + "    </namespaces>\n"
         + "  </siteinfo>\n";
+
     String thisLine;
     StringBuilder content = new StringBuilder();
     content.append(header);
     int filenumber = 0;
-    DecimalFormat decimalFormatter = new DecimalFormat("0000");
+    NumberFormat decimalFormatter = new DecimalFormat("0000");
     while ((thisLine = dumpReader.readLine()) != null)
     {
       boolean end = false;
       if(thisLine.trim().startsWith("<page>")){
-        while(thisLine.trim().startsWith("</page>")==false){
-          content.append(thisLine).append("\n");
+        while(thisLine.trim().startsWith("</page>") == false){
+          content.append(thisLine).append('\n');
           if ((thisLine = dumpReader.readLine()) == null){
             end=true;
             break;
           }
         }
-        content.append(thisLine).append("\n");
+        content.append(thisLine).append('\n');
 
         if(content.length()>chunkSize || end){
           content.append("</mediawiki>");

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/DescriptionUtils.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/DescriptionUtils.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/DescriptionUtils.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/DescriptionUtils.java Tue Oct 14 04:07:46 2008
@@ -59,7 +59,7 @@
     for (String value : values) {
       buffer.append(value);
       if (++ind < values.size())
-        buffer.append(",");
+        buffer.append(',');
     }
 
     return buffer.toString();
@@ -67,8 +67,8 @@
 
   public static Range extractNumericalRange(String description) {
     StringTokenizer tokenizer = new StringTokenizer(description, ",");
-    float min = Float.valueOf(tokenizer.nextToken());
-    float max = Float.valueOf(tokenizer.nextToken());
+    float min = Float.parseFloat(tokenizer.nextToken());
+    float max = Float.parseFloat(tokenizer.nextToken());
     
     return new Range(min, max);
   }

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/ToolCombiner.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/ToolCombiner.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/ToolCombiner.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/ToolCombiner.java Tue Oct 14 04:07:46 2008
@@ -106,7 +106,7 @@
     float max = Float.MIN_VALUE;
 
     while (values.hasNext()) {
-      float value = Float.valueOf(values.next().toString());
+      float value = Float.parseFloat(values.next().toString());
       if (value < min)
         min = value;
       else if (value > max)

Modified: lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMapperTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMapperTest.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMapperTest.java (original)
+++ lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMapperTest.java Tue Oct 14 04:07:46 2008
@@ -98,7 +98,7 @@
 
     CDFitness[] expected = { TP, FP, TN, FN };
     for (String key : keys) {
-      int index = Integer.valueOf(key);
+      int index = Integer.parseInt(key);
       assertEquals("Values for key " + key, 1, collector.getValue(key).size());
       CDFitness eval = collector.getValue(key).get(0);
 

Modified: lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/tool/CDInfosToolTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/tool/CDInfosToolTest.java?rev=704462&r1=704461&r2=704462&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/tool/CDInfosToolTest.java (original)
+++ lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/tool/CDInfosToolTest.java Tue Oct 14 04:07:46 2008
@@ -131,11 +131,11 @@
         buffer.append(descriptions[index][vindex]);
       } else {
         // ignored attribute (any value is correct)
-        buffer.append("I");
+        buffer.append('I');
       }
 
       if (index < descriptors.size() - 1) {
-        buffer.append(",");
+        buffer.append(',');
       }
     }
 



Mime
View raw message