mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tdunn...@apache.org
Subject svn commit: r990912 - /mahout/trunk/core/src/main/java/org/apache/mahout/vectors/InteractionValueEncoder.java
Date Mon, 30 Aug 2010 19:34:06 GMT
Author: tdunning
Date: Mon Aug 30 19:34:06 2010
New Revision: 990912

URL: http://svn.apache.org/viewvc?rev=990912&view=rev
Log:
MAHOUT-492 - several small bug fixes for InteractionValueEncoder

Modified:
    mahout/trunk/core/src/main/java/org/apache/mahout/vectors/InteractionValueEncoder.java

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/vectors/InteractionValueEncoder.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/vectors/InteractionValueEncoder.java?rev=990912&r1=990911&r2=990912&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/vectors/InteractionValueEncoder.java
(original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/vectors/InteractionValueEncoder.java
Mon Aug 30 19:34:06 2010
@@ -26,9 +26,9 @@ public class InteractionValueEncoder ext
   protected static final int INTERACTION_VALUE_HASH_SEED_1 = 100;
   protected static final int INTERACTION_VALUE_HASH_SEED_2 = 200;
 
-  protected InteractionValueEncoder(String name) {
-    super(name, 2);
-  }
+    public InteractionValueEncoder(String name) {
+       super(name, 2);
+     }
 
   /**
    * Adds a value to a vector.
@@ -55,6 +55,9 @@ public class InteractionValueEncoder ext
          int h2 = hash2(name, originalForm1, i, data.size());
          int j =  hash1(name, originalForm2, i, data.size());
          int n = (h1 + (j+1)*h2) % data.size();
+         if(n < 0){
+             n = n+data.size();
+         }
          trace(String.format("%s:%s", originalForm1, originalForm2), n);
          data.set(n, data.get(n) + 1);
        }



Mime
View raw message