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/17 19:54:26 UTC
svn commit: r785745 -
/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/file/FileDataModel.java
Author: srowen
Date: Wed Jun 17 17:54:26 2009
New Revision: 785745
URL: http://svn.apache.org/viewvc?rev=785745&view=rev
Log:
Ignore blank lines or lines starting with # as a comment, per Grants suggestion
Modified:
lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/file/FileDataModel.java
Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/file/FileDataModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/file/FileDataModel.java?rev=785745&r1=785744&r2=785745&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/file/FileDataModel.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/file/FileDataModel.java Wed Jun 17 17:54:26 2009
@@ -64,7 +64,8 @@
* updates to {@link FileDataModel} without re-copying the entire data file.</p>
*
* <p>The line may contain a blank preference value (e.g. "123,ABC,"). This is interpreted to mean "delete
- * preference", and is only useful in the context of an update delta file (see above).</p>
+ * preference", and is only useful in the context of an update delta file (see above).
+ * Note that if the line is empty or begins with '#' it will be ignored as a comment.</p>
*
* <p>Finally, for application that have no notion of a preference value (that is, the user simply expresses
* a preference for an item, but no degree of preference), the caller can simply omit the third token in
@@ -204,12 +205,19 @@
* the item in question if needed, and use {@link #buildPreference(User, Item, double)} to
* build {@link Preference} objects as needed.</p>
*
+ * <p>Note that if the line is empty or begins with '#' it will be ignored as a comment.</p>
+ *
* @param line line from input data file
* @param data all data read so far, as a mapping from user IDs to preferences
* @see #buildPreference(User, Item, double)
* @see #buildItem(String)
*/
protected void processLine(String line, Map<String, List<Preference>> data, Map<String, Item> itemCache) {
+
+ if (line.length() == 0 || line.charAt(0) == '#') {
+ return;
+ }
+
int delimiterOne = line.indexOf((int) delimiter);
if (delimiterOne < 0) {
throw new IllegalArgumentException("Bad line: " + line);