mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r811845 - in /lucene/mahout/trunk/core/src/main/java/org/apache/mahout: cf/taste/impl/similarity/ classifier/ classifier/bayes/algorithm/ classifier/bayes/datastore/ classifier/bayes/exceptions/ classifier/bayes/interfaces/ classifier/bayes...
Date Sun, 06 Sep 2009 17:57:29 GMT
Author: srowen
Date: Sun Sep  6 17:57:28 2009
New Revision: 811845

URL: http://svn.apache.org/viewvc?rev=811845&view=rev
Log:
Small code cleanup per email to list

Modified:
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/AbstractSimilarity.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/bayes/algorithm/BayesAlgorithm.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/algorithm/CBayesAlgorithm.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/datastore/HBaseBayesDatastore.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/datastore/InMemoryBayesDatastore.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/exceptions/InvalidDatastoreException.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/interfaces/Algorithm.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/bayes/BayesClassifierDriver.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/bayes/BayesClassifierMapper.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/cbayes/CBayesThetaNormalizerReducer.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureDriver.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureMapper.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfDriver.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfMapper.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfReducer.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesWeightSummerReducer.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/FuzzyKMeansUtil.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAPrintTopics.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/Parameters.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/TimingStatistics.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/cache/HybridCache.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/cache/LFUCache.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/cache/LRUCache.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/nlp/NGrams.java

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/AbstractSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/AbstractSimilarity.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/AbstractSimilarity.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/AbstractSimilarity.java
Sun Sep  6 17:57:28 2009
@@ -22,7 +22,6 @@
 import org.apache.mahout.cf.taste.common.Weighting;
 import org.apache.mahout.cf.taste.impl.common.RefreshHelper;
 import org.apache.mahout.cf.taste.model.DataModel;
-import org.apache.mahout.cf.taste.model.Preference;
 import org.apache.mahout.cf.taste.model.PreferenceArray;
 import org.apache.mahout.cf.taste.similarity.ItemSimilarity;
 import org.apache.mahout.cf.taste.similarity.PreferenceInferrer;

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=811845&r1=811844&r2=811845&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 Sun
Sep  6 17:57:28 2009
@@ -48,7 +48,7 @@
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.nio.charset.Charset;
-import java.util.*;
+import java.util.List;
 
 public class Classify {
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/algorithm/BayesAlgorithm.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/algorithm/BayesAlgorithm.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/algorithm/BayesAlgorithm.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/algorithm/BayesAlgorithm.java
Sun Sep  6 17:57:28 2009
@@ -17,7 +17,11 @@
 
 package org.apache.mahout.classifier.bayes.algorithm;
 
-import java.util.*;
+import java.util.Collection;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.Map;
 
 import org.apache.hadoop.util.PriorityQueue;
 import org.apache.mahout.classifier.ClassifierResult;
@@ -70,7 +74,7 @@
     if (result.isEmpty()){
       result.add(new ClassifierResult(defaultCategory, 0));
     }
-    return result.toArray(new ClassifierResult[] {});  
+    return result.toArray(new ClassifierResult[result.size()]);  
   }
   
   @Override

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/algorithm/CBayesAlgorithm.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/algorithm/CBayesAlgorithm.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/algorithm/CBayesAlgorithm.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/algorithm/CBayesAlgorithm.java
Sun Sep  6 17:57:28 2009
@@ -17,7 +17,11 @@
 
 package org.apache.mahout.classifier.bayes.algorithm;
 
-import java.util.*;
+import java.util.Collection;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.Map;
 
 import org.apache.hadoop.util.PriorityQueue;
 import org.apache.mahout.classifier.ClassifierResult;
@@ -72,7 +76,7 @@
     if (result.isEmpty()) {
       result.add(new ClassifierResult(defaultCategory, 0));
     }
-    return result.toArray(new ClassifierResult[] {});
+    return result.toArray(new ClassifierResult[result.size()]);
   }
 
   @Override

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/datastore/HBaseBayesDatastore.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/datastore/HBaseBayesDatastore.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/datastore/HBaseBayesDatastore.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/datastore/HBaseBayesDatastore.java
Sun Sep  6 17:57:28 2009
@@ -18,7 +18,11 @@
 package org.apache.mahout.classifier.bayes.datastore;
 
 import java.io.IOException;
-import java.util.*;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseConfiguration;

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/datastore/InMemoryBayesDatastore.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/datastore/InMemoryBayesDatastore.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/datastore/InMemoryBayesDatastore.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/datastore/InMemoryBayesDatastore.java
Sun Sep  6 17:57:28 2009
@@ -18,7 +18,9 @@
 package org.apache.mahout.classifier.bayes.datastore;
 
 import java.io.IOException;
-import java.util.*;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/exceptions/InvalidDatastoreException.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/exceptions/InvalidDatastoreException.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/exceptions/InvalidDatastoreException.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/exceptions/InvalidDatastoreException.java
Sun Sep  6 17:57:28 2009
@@ -18,10 +18,6 @@
 package org.apache.mahout.classifier.bayes.exceptions;
 
 public final class InvalidDatastoreException extends Exception {
-  /**
-   * 
-   */
-  private static final long serialVersionUID = 5875392475968381082L;
 
   public InvalidDatastoreException() {
   }

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/interfaces/Algorithm.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/interfaces/Algorithm.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/interfaces/Algorithm.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/interfaces/Algorithm.java
Sun Sep  6 17:57:28 2009
@@ -17,7 +17,8 @@
 
 package org.apache.mahout.classifier.bayes.interfaces;
 
-import java.util.*;
+import java.util.Collection;
+
 import org.apache.mahout.classifier.ClassifierResult;
 import org.apache.mahout.classifier.bayes.exceptions.InvalidDatastoreException;
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/bayes/BayesClassifierDriver.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/bayes/BayesClassifierDriver.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/bayes/BayesClassifierDriver.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/bayes/BayesClassifierDriver.java
Sun Sep  6 17:57:28 2009
@@ -21,7 +21,6 @@
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.io.DefaultStringifier;
 import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.SequenceFile;
 import org.apache.hadoop.io.Text;
@@ -40,11 +39,13 @@
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.regex.Pattern;
 
 /** Create and run the Bayes Classifier */
 public class BayesClassifierDriver {
 
   private static final Logger log = LoggerFactory.getLogger(BayesClassifierDriver.class);
+  private static final Pattern CHUNK_DEIMITER_PATTERN = Pattern.compile("____");
 
   /**
    * Run the job
@@ -99,7 +100,7 @@
       // the key is correctLabel____classifiedLabel value is count
       while (reader.next(key, value)) {
         String keyStr = key.toString();
-        String []chunks = keyStr.split("____");
+        String[] chunks = CHUNK_DEIMITER_PATTERN.split(keyStr);
         String correctLabel = chunks[0];
         String classifiedLabel = chunks[1];
         Map<String, Integer> rowMatrix = confusionMatrix.get(correctLabel);

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/bayes/BayesClassifierMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/bayes/BayesClassifierMapper.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/bayes/BayesClassifierMapper.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/bayes/BayesClassifierMapper.java
Sun Sep  6 17:57:28 2009
@@ -17,7 +17,6 @@
 
 package org.apache.mahout.classifier.bayes.mapreduce.bayes;
 
-import org.apache.hadoop.io.DefaultStringifier;
 import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.mapred.JobConf;
@@ -42,9 +41,7 @@
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 /** Reads the input train set(preprocessed using the {@link BayesFileFormatter}). */
 public class BayesClassifierMapper extends MapReduceBase implements
@@ -75,8 +72,8 @@
     String label = key.toString();
 
 
-    StringBuilder builder = new StringBuilder(label);
-    builder.ensureCapacity(32);// make sure we have a reasonably size buffer to
+    //StringBuilder builder = new StringBuilder(label);
+    //builder.ensureCapacity(32);// make sure we have a reasonably size buffer to
                                // begin with
     List<String> ngrams  = new NGrams(value.toString(), gramSize).generateNGramsWithoutLabel();

     

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/cbayes/CBayesThetaNormalizerReducer.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/cbayes/CBayesThetaNormalizerReducer.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/cbayes/CBayesThetaNormalizerReducer.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/cbayes/CBayesThetaNormalizerReducer.java
Sun Sep  6 17:57:28 2009
@@ -29,6 +29,8 @@
 import org.apache.hadoop.mapred.Reducer;
 import org.apache.hadoop.mapred.Reporter;
 import org.apache.mahout.common.Parameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.Iterator;
@@ -36,6 +38,10 @@
 /** Can also be used as a local Combiner beacuse only two values should be there inside the
values */
 public class CBayesThetaNormalizerReducer extends MapReduceBase implements
     Reducer<Text, DoubleWritable, Text, DoubleWritable> {
+
+  private static final Logger log = LoggerFactory
+      .getLogger(CBayesThetaNormalizerReducer.class);
+
   private HTable table;
 
   private HBaseConfiguration HBconf;
@@ -81,8 +87,7 @@
       HBconf = new HBaseConfiguration(job);
       table = new HTable(HBconf, job.get("output.table"));
     } catch (IOException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      log.error("Unexpected error during configuration", e);
     }
   }
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureDriver.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureDriver.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureDriver.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureDriver.java
Sun Sep  6 17:57:28 2009
@@ -19,7 +19,6 @@
 
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.io.DefaultStringifier;
 import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.mapred.FileInputFormat;

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureMapper.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureMapper.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureMapper.java
Sun Sep  6 17:57:28 2009
@@ -17,7 +17,6 @@
 
 package org.apache.mahout.classifier.bayes.mapreduce.common;
 
-import org.apache.hadoop.io.DefaultStringifier;
 import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.mapred.JobConf;

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfDriver.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfDriver.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfDriver.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfDriver.java
Sun Sep  6 17:57:28 2009
@@ -20,10 +20,10 @@
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.*;
-import org.apache.hadoop.hbase.io.*;
-import org.apache.hadoop.hbase.io.hfile.Compression.Algorithm;
-import org.apache.hadoop.hbase.client.*;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.io.DefaultStringifier;
 import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.Text;

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfMapper.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfMapper.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfMapper.java
Sun Sep  6 17:57:28 2009
@@ -58,7 +58,7 @@
       case '-': {// if it is the termDocumentCount
         labelFeaturePair = labelFeaturePair.substring(1);
         // -17th_century_mathematicians_anderson__alexander,1582
-        int idx = labelFeaturePair.indexOf(",");
+        int idx = labelFeaturePair.indexOf(',');
         if (idx != -1) {
           String label = labelFeaturePair.substring(0, idx);
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfReducer.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfReducer.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfReducer.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfReducer.java
Sun Sep  6 17:57:28 2009
@@ -81,7 +81,8 @@
       }
       if (numberofValues == 2) { // Found TFIdf
 
-        String label = token.split(",")[0];
+        int comma = token.indexOf(',');
+        String label = comma < 0 ? token : token.substring(0, comma);
         String feature = token.substring(label.length() + 1);
         if (useHbase) {
           Put bu = new Put(Bytes.toBytes(feature));
@@ -110,8 +111,7 @@
       table = new HTable(HBconf, job.get("output.table"));
 
     } catch (IOException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      log.error("Unexpected error during configuration", e);
     }
 
   }

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesWeightSummerReducer.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesWeightSummerReducer.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesWeightSummerReducer.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesWeightSummerReducer.java
Sun Sep  6 17:57:28 2009
@@ -29,6 +29,8 @@
 import org.apache.hadoop.mapred.Reducer;
 import org.apache.hadoop.mapred.Reporter;
 import org.apache.mahout.common.Parameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.Iterator;
@@ -36,6 +38,10 @@
 /** Can also be used as a local Combiner */
 public class BayesWeightSummerReducer extends MapReduceBase implements
     Reducer<Text, DoubleWritable, Text, DoubleWritable> {
+
+  private static final Logger log = LoggerFactory
+      .getLogger(BayesWeightSummerReducer.class);
+
   private HTable table;
 
   private HBaseConfiguration HBconf;
@@ -97,8 +103,7 @@
       HBconf = new HBaseConfiguration(job);
       table = new HTable(HBconf, job.get("output.table"));
     } catch (IOException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      log.error("Unexpected error during configuration", e);
     }
 
   }

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/FuzzyKMeansUtil.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/FuzzyKMeansUtil.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/FuzzyKMeansUtil.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/fuzzykmeans/FuzzyKMeansUtil.java
Sun Sep  6 17:57:28 2009
@@ -98,10 +98,7 @@
             }
           }
         } finally {
-          if (reader != null) {
-            reader.close();
-          }
-
+          reader.close();
         }
       }
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAPrintTopics.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAPrintTopics.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAPrintTopics.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAPrintTopics.java
Sun Sep  6 17:57:28 2009
@@ -28,6 +28,7 @@
 import java.util.List;
 import java.util.PriorityQueue;
 import java.util.Queue;
+import java.util.regex.Pattern;
 
 import org.apache.commons.cli2.CommandLine;
 import org.apache.commons.cli2.Group;
@@ -49,6 +50,8 @@
  * Class to print out the top K words for each topic.
  */
 public class LDAPrintTopics {
+  private static final Pattern TAB_PATTERN = Pattern.compile("\t");
+
   private LDAPrintTopics() {
   }
 
@@ -145,9 +148,9 @@
     // skip 2 lines
     rdr.readLine();
     rdr.readLine();
-    String line = null;
+    String line;
     while ( (line = rdr.readLine()) != null) {
-      String[] parts = line.split("\t");
+      String[] parts = TAB_PATTERN.split(line);
       String word = parts[0];
       int index = Integer.parseInt(parts[2]);
       assert index == result.size();
@@ -226,8 +229,6 @@
 
     } catch (OptionException e) {
       CommandLineUtil.printHelp(group);
-    } catch (IOException e) {
-      throw e;
     }
   }
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/Parameters.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/Parameters.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/Parameters.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/Parameters.java Sun Sep
 6 17:57:28 2009
@@ -7,7 +7,6 @@
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.io.DefaultStringifier;
 import org.apache.hadoop.util.GenericsUtil;
-import org.apache.mahout.classifier.bayes.datastore.HBaseBayesDatastore;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -17,7 +16,7 @@
 
   private Map<String, String> params = new HashMap<String, String>();
 
-  private Configuration conf = new Configuration();
+  //private Configuration conf = new Configuration();
 
   public Parameters() {
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/TimingStatistics.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/TimingStatistics.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/TimingStatistics.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/TimingStatistics.java Sun
Sep  6 17:57:28 2009
@@ -66,11 +66,11 @@
     public String toString() {
         return "\n" +
         		"nCalls = " + nCalls + ";\n" +
-                "sumTime = " + getSumTime()/1000000000f + "s;\n" +
-                "minTime = " + minTime/1000000f + "ms;\n" +
-                "maxTime = " + maxTime/1000000f + "ms;\n" +
-                "meanTime = " + getMeanTime()/1000000f + "ms;\n" +
-                "stdDevTime = " + getStdDevTime()/1000000f + "ms;";
+                "sumTime = " + getSumTime()/1000000000.0f + "s;\n" +
+                "minTime = " + minTime/1000000.0f + "ms;\n" +
+                "maxTime = " + maxTime/1000000.0f + "ms;\n" +
+                "meanTime = " + getMeanTime()/1000000.0f + "ms;\n" +
+                "stdDevTime = " + getStdDevTime()/1000000.0f + "ms;";
     }
     
     public Call newCall() {

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/cache/HybridCache.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/cache/HybridCache.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/cache/HybridCache.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/cache/HybridCache.java
Sun Sep  6 17:57:28 2009
@@ -1,6 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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 License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.mahout.utils.cache;
 
-public class HybridCache<K, V> implements org.apache.mahout.utils.Cache<K, V>
{
+import org.apache.mahout.utils.Cache;
+
+public class HybridCache<K, V> implements Cache<K, V> {
 
   private int LFUCapacity = 0;
 
@@ -68,10 +87,7 @@
 
   @Override
   public boolean contains(K key) {
-    if (lruCache.contains(key))
-      return true;
-    else
-      return lfuCache.contains(key);
+    return lruCache.contains(key) || lfuCache.contains(key);
   }
 
 }

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/cache/LFUCache.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/cache/LFUCache.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/cache/LFUCache.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/cache/LFUCache.java Sun
Sep  6 17:57:28 2009
@@ -1,10 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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 License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.mahout.utils.cache;
 
-import java.util.*;
+import java.util.ConcurrentModificationException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
 import org.apache.mahout.common.Pair;
+import org.apache.mahout.utils.Cache;
 
 
-public class LFUCache<K, V> implements org.apache.mahout.utils.Cache<K, V> {
+public class LFUCache<K, V> implements Cache<K, V> {
 
   SortedMap<Long, Set<K>> evictionMap = null;
 
@@ -61,7 +87,7 @@
       throw new ConcurrentModificationException();
     if (keys.remove(key) == false)
       throw new ConcurrentModificationException();
-    if (keys.size() == 0)
+    if (keys.isEmpty())
       evictionMap.remove(count);
     count = Long.valueOf(count.longValue() + 1);
     Set<K> keysNew = evictionMap.get(count);
@@ -98,7 +124,7 @@
     Iterator<K> it = values.iterator();
     K keyToBeRemoved = it.next();
     values.remove(keyToBeRemoved);
-    if (values.size() == 0)
+    if (values.isEmpty())
       evictionMap.remove(key);
     dataMap.remove(keyToBeRemoved);
     evictionCount++;

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/cache/LRUCache.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/cache/LRUCache.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/cache/LRUCache.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/cache/LRUCache.java Sun
Sep  6 17:57:28 2009
@@ -1,25 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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 License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.mahout.utils.cache;
 
+import org.apache.mahout.utils.Cache;
+
 import java.util.LinkedHashMap;
 import java.util.Map;
 
 
-public class LRUCache<K, V> implements org.apache.mahout.utils.Cache<K, V> {
+public class LRUCache<K, V> implements Cache<K, V> {
 
   int capacity = 0;
   
-  private  Map<K, V> lruCache = null;
+  private Map<K, V> lruCache = null;
   
   public LRUCache(final int capacity) {
 
     this.capacity = capacity;
 
     lruCache = new LinkedHashMap<K,V>( (int)(capacity/0.75f + 1), 0.75f, true) { 
-      private static final long serialVersionUID = -576585264027935752L;
-      private final int MAX_ENTRIES = capacity;
-      @Override protected boolean removeEldestEntry (Map.Entry<K,V> eldest) {
-         return size() > MAX_ENTRIES; 
-         }
+      @Override
+      protected boolean removeEldestEntry (Map.Entry<K,V> eldest) {
+        return size() > capacity;
+      }
     };
       
   }

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/nlp/NGrams.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/nlp/NGrams.java?rev=811845&r1=811844&r2=811845&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/nlp/NGrams.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/utils/nlp/NGrams.java Sun Sep
 6 17:57:28 2009
@@ -1,3 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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 License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.mahout.utils.nlp;
 
 import java.util.ArrayList;



Mime
View raw message