You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by td...@apache.org on 2010/09/22 22:28:14 UTC
svn commit: r1000189 - in
/mahout/trunk/core/src/main/java/org/apache/mahout/vectors:
ConstantValueEncoder.java ContinuousValueEncoder.java
FeatureVectorEncoder.java
Author: tdunning
Date: Wed Sep 22 20:28:13 2010
New Revision: 1000189
URL: http://svn.apache.org/viewvc?rev=1000189&view=rev
Log:
The rest of the fix for TrainLogistic
Modified:
mahout/trunk/core/src/main/java/org/apache/mahout/vectors/ConstantValueEncoder.java
mahout/trunk/core/src/main/java/org/apache/mahout/vectors/ContinuousValueEncoder.java
mahout/trunk/core/src/main/java/org/apache/mahout/vectors/FeatureVectorEncoder.java
Modified: mahout/trunk/core/src/main/java/org/apache/mahout/vectors/ConstantValueEncoder.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/vectors/ConstantValueEncoder.java?rev=1000189&r1=1000188&r2=1000189&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/vectors/ConstantValueEncoder.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/vectors/ConstantValueEncoder.java Wed Sep 22 20:28:13 2010
@@ -34,7 +34,7 @@ public class ConstantValueEncoder extend
for (int i = 0; i < probes; i++) {
int n = hashForProbe(originalForm, data.size(), name, i);
if(isTraceEnabled()){
- trace(name, n);
+ trace((String) null, n);
}
data.set(n, data.get(n) + getWeight(originalForm,weight));
}
Modified: mahout/trunk/core/src/main/java/org/apache/mahout/vectors/ContinuousValueEncoder.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/vectors/ContinuousValueEncoder.java?rev=1000189&r1=1000188&r2=1000189&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/vectors/ContinuousValueEncoder.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/vectors/ContinuousValueEncoder.java Wed Sep 22 20:28:13 2010
@@ -42,7 +42,7 @@ public class ContinuousValueEncoder exte
for (int i = 0; i < probes; i++) {
int n = hashForProbe(originalForm, data.size(), name, i);
if(isTraceEnabled()){
- trace(name.getBytes(Charsets.UTF_8), n);
+ trace((String) null, n);
}
data.set(n, data.get(n) + getWeight(originalForm,weight));
}
Modified: mahout/trunk/core/src/main/java/org/apache/mahout/vectors/FeatureVectorEncoder.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/vectors/FeatureVectorEncoder.java?rev=1000189&r1=1000188&r2=1000189&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/vectors/FeatureVectorEncoder.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/vectors/FeatureVectorEncoder.java Wed Sep 22 20:28:13 2010
@@ -33,10 +33,11 @@ import java.util.Set;
* dictionary.
*/
public abstract class FeatureVectorEncoder {
-
protected static final int CONTINUOUS_VALUE_HASH_SEED = 1;
protected static final int WORD_LIKE_VALUE_HASH_SEED = 100;
+ private static final byte[] EMPTY_ARRAY = new byte[0];;
+
private final String name;
private int probes;
@@ -272,7 +273,11 @@ public abstract class FeatureVectorEncod
this.traceDictionary = traceDictionary;
}
- protected byte[] bytesForString(String x){
- return x.getBytes(Charsets.UTF_8);
+ protected byte[] bytesForString(String x) {
+ if (x != null) {
+ return x.getBytes(Charsets.UTF_8);
+ } else {
+ return EMPTY_ARRAY;
+ }
}
}