You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by sr...@apache.org on 2009/06/01 20:53:00 UTC

svn commit: r780778 - /lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensDataModel.java

Author: srowen
Date: Mon Jun  1 18:53:00 2009
New Revision: 780778

URL: http://svn.apache.org/viewvc?rev=780778&view=rev
Log:
Always unpack data files -- using old copy was causing problems when existing copy was corrupted.

Modified:
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensDataModel.java

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensDataModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensDataModel.java?rev=780778&r1=780777&r2=780778&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensDataModel.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensDataModel.java Mon Jun  1 18:53:00 2009
@@ -85,27 +85,28 @@
     // Now translate the file; remove commas, then convert "::" delimiter to comma
     File resultFile = new File(new File(System.getProperty("java.io.tmpdir")),
                                         (ratings ? "ratings" : "movies") + ".txt");
-    if (!resultFile.exists()) {
-      PrintWriter writer = null;
-      try {
-        writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(resultFile), Charset.forName("UTF-8")));
-        for (String line : new FileLineIterable(originalFile, false)) {
-          String convertedLine;
-          if (ratings) {
-            // toss the last column of data, which is a timestamp we don't want
-            convertedLine = line.substring(0, line.lastIndexOf("::")).replace("::", ",");
-          } else {
-            convertedLine = line.replace(",", "").replace("::", ",");
-          }
-          writer.println(convertedLine);
+    if (resultFile.exists()) {
+      resultFile.delete();
+    }
+    PrintWriter writer = null;
+    try {
+      writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(resultFile), Charset.forName("UTF-8")));
+      for (String line : new FileLineIterable(originalFile, false)) {
+        String convertedLine;
+        if (ratings) {
+          // toss the last column of data, which is a timestamp we don't want
+          convertedLine = line.substring(0, line.lastIndexOf("::")).replace("::", ",");
+        } else {
+          convertedLine = line.replace(",", "").replace("::", ",");
         }
-        writer.flush();
-      } catch (IOException ioe) {
-        resultFile.delete();
-        throw ioe;
-      } finally {
-        IOUtils.quietClose(writer);
+        writer.println(convertedLine);
       }
+      writer.flush();
+    } catch (IOException ioe) {
+      resultFile.delete();
+      throw ioe;
+    } finally {
+      IOUtils.quietClose(writer);
     }
     return resultFile;
   }