mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r1137374 - in /mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/pseudo: RecommenderJob.java UserIDsMapper.java
Date Sun, 19 Jun 2011 14:50:29 GMT
Author: srowen
Date: Sun Jun 19 14:50:28 2011
New Revision: 1137374

URL: http://svn.apache.org/viewvc?rev=1137374&view=rev
Log:
Small improvement and typo fix from book

Modified:
    mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/pseudo/RecommenderJob.java
    mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/pseudo/UserIDsMapper.java

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/pseudo/RecommenderJob.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/pseudo/RecommenderJob.java?rev=1137374&r1=1137373&r2=1137374&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/pseudo/RecommenderJob.java
(original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/pseudo/RecommenderJob.java
Sun Jun 19 14:50:28 2011
@@ -109,7 +109,7 @@ public final class RecommenderJob extend
     addOutputOption();
     addOption("recommenderClassName", "r", "Name of recommender class to instantiate");
     addOption("numRecommendations", "n", "Number of recommendations per user", "10");
-    addOption("usersFile", "u", "Number of recommendations per user", null);
+    addOption("usersFile", "u", "File of users to recommend for", null);
     
     Map<String,String> parsedArgs = parseArguments(args);
     if (parsedArgs == null) {

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/pseudo/UserIDsMapper.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/pseudo/UserIDsMapper.java?rev=1137374&r1=1137373&r2=1137374&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/pseudo/UserIDsMapper.java
(original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/pseudo/UserIDsMapper.java
Sun Jun 19 14:50:28 2011
@@ -18,6 +18,7 @@
 package org.apache.mahout.cf.taste.hadoop.pseudo;
 
 import java.io.IOException;
+import java.util.regex.Pattern;
 
 import org.apache.hadoop.io.LongWritable;
 import org.apache.hadoop.io.NullWritable;
@@ -30,15 +31,16 @@ import org.apache.mahout.math.VarLongWri
  */
 public final class UserIDsMapper extends
     Mapper<LongWritable,Text, VarLongWritable,NullWritable> {
-  
+
+  private static final Pattern DELIMITER = Pattern.compile("[\t,]");
+
   @Override
   protected void map(LongWritable key,
                      Text value,
                      Context context) throws IOException, InterruptedException {
-    String line = value.toString();
-    int comma = line.indexOf(',');
-    long userID = comma >= 0 ? Long.parseLong(line.substring(0, comma)) : Long.parseLong(line);
+    String[] tokens = DELIMITER.split(value.toString());
+    long userID = Long.parseLong(tokens[0]);
     context.write(new VarLongWritable(userID), NullWritable.get());
   }
-  
+
 }
\ No newline at end of file



Mime
View raw message