mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r797487 [4/5] - in /lucene/mahout/trunk: core/src/main/java/org/apache/mahout/cf/taste/eval/ core/src/main/java/org/apache/mahout/cf/taste/hadoop/ core/src/main/java/org/apache/mahout/cf/taste/impl/eval/ core/src/main/java/org/apache/mahout...
Date Fri, 24 Jul 2009 14:32:07 GMT
Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/similarity/ItemSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/similarity/ItemSimilarity.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/similarity/ItemSimilarity.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/similarity/ItemSimilarity.java Fri Jul 24 14:32:05 2009
@@ -19,10 +19,9 @@
 
 import org.apache.mahout.cf.taste.common.Refreshable;
 import org.apache.mahout.cf.taste.common.TasteException;
-import org.apache.mahout.cf.taste.model.Item;
 
 /**
- * <p>Implementations of this interface define a notion of similarity between two {@link Item}s. Implementations should
+ * <p>Implementations of this interface define a notion of similarity between two items. Implementations should
  * return values in the range -1.0 to 1.0, with 1.0 representing perfect similarity.</p>
  *
  * @see UserSimilarity
@@ -30,14 +29,14 @@
 public interface ItemSimilarity extends Refreshable {
 
   /**
-   * <p>Returns the degree of similarity, of two {@link Item}s, based on the preferences that {@link
+   * <p>Returns the degree of similarity, of two items, based on the preferences that {@link
    * org.apache.mahout.cf.taste.model.User}s have expressed for the items.</p>
    *
-   * @param item1 first item
-   * @param item2 second item
-   * @return similarity between the {@link Item}s, in [-1,1]
+   * @param itemID1 first item ID
+   * @param itemID2 second item ID
+   * @return similarity between the items, in [-1,1]
    * @throws TasteException if an error occurs while accessing the data
    */
-  double itemSimilarity(Item item1, Item item2) throws TasteException;
+  double itemSimilarity(Comparable<?> itemID1, Comparable<?> itemID2) throws TasteException;
 
 }

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/similarity/PreferenceInferrer.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/similarity/PreferenceInferrer.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/similarity/PreferenceInferrer.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/similarity/PreferenceInferrer.java Fri Jul 24 14:32:05 2009
@@ -19,24 +19,23 @@
 
 import org.apache.mahout.cf.taste.common.Refreshable;
 import org.apache.mahout.cf.taste.common.TasteException;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.User;
 
 /**
- * <p>Implementations of this interface compute an inferred preference for a {@link User} and an {@link Item} that the
+ * <p>Implementations of this interface compute an inferred preference for a {@link User} and an item that the
  * user has not expressed any preference for. This might be an average of other preferences scores from that user, for
  * example. This technique is sometimes called "default voting".</p>
  */
 public interface PreferenceInferrer extends Refreshable {
 
   /**
-   * <p>Infers the given {@link User}'s preference value for an {@link Item}.</p>
+   * <p>Infers the given {@link User}'s preference value for an item.</p>
    *
    * @param user {@link User} to infer preference for
-   * @param item {@link Item} to infer preference for
+   * @param itemID item ID to infer preference for
    * @return inferred preference
    * @throws TasteException if an error occurs while inferring
    */
-  double inferPreference(User user, Item item) throws TasteException;
+  double inferPreference(User user, Comparable<?> itemID) throws TasteException;
 
 }

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/LoadTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/LoadTest.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/LoadTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/LoadTest.java Fri Jul 24 14:32:05 2009
@@ -21,7 +21,6 @@
 import org.apache.mahout.cf.taste.common.TasteException;
 import org.apache.mahout.cf.taste.impl.common.RandomUtils;
 import org.apache.mahout.cf.taste.impl.model.GenericDataModel;
-import org.apache.mahout.cf.taste.impl.model.GenericItem;
 import org.apache.mahout.cf.taste.impl.model.GenericPreference;
 import org.apache.mahout.cf.taste.impl.model.GenericUser;
 import org.apache.mahout.cf.taste.impl.neighborhood.NearestNUserNeighborhood;
@@ -31,7 +30,6 @@
 import org.apache.mahout.cf.taste.impl.recommender.slopeone.SlopeOneRecommender;
 import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity;
 import org.apache.mahout.cf.taste.model.DataModel;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.Preference;
 import org.apache.mahout.cf.taste.model.User;
 import org.apache.mahout.cf.taste.neighborhood.UserNeighborhood;
@@ -93,9 +91,9 @@
 
   private DataModel createModel() {
 
-    List<Item> items = new ArrayList<Item>(NUM_ITEMS);
+    List<Comparable<?>> itemIDs = new ArrayList<Comparable<?>>(NUM_ITEMS);
     for (int i = 0; i < NUM_ITEMS; i++) {
-      items.add(new GenericItem<String>(String.valueOf(i)));
+      itemIDs.add(String.valueOf(i));
     }
 
     List<User> users = new ArrayList<User>(NUM_USERS);
@@ -103,9 +101,9 @@
       int numPrefs = random.nextInt(NUM_PREFS) + 1;
       List<Preference> prefs = new ArrayList<Preference>(numPrefs);
       for (int j = 0; j < numPrefs; j++) {
-        prefs.add(new GenericPreference(null, items.get(random.nextInt(NUM_ITEMS)), random.nextDouble()));
+        prefs.add(new GenericPreference(null, itemIDs.get(random.nextInt(NUM_ITEMS)), random.nextDouble()));
       }
-      GenericUser<String> user = new GenericUser<String>(String.valueOf(i), prefs);
+      GenericUser user = new GenericUser(String.valueOf(i), prefs);
       users.add(user);
     }
 

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/TasteTestCase.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/TasteTestCase.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/TasteTestCase.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/TasteTestCase.java Fri Jul 24 14:32:05 2009
@@ -20,7 +20,6 @@
 import junit.framework.TestCase;
 import org.apache.mahout.cf.taste.impl.common.RandomUtils;
 import org.apache.mahout.cf.taste.impl.model.GenericDataModel;
-import org.apache.mahout.cf.taste.impl.model.GenericItem;
 import org.apache.mahout.cf.taste.impl.model.GenericPreference;
 import org.apache.mahout.cf.taste.impl.model.GenericUser;
 import org.apache.mahout.cf.taste.model.DataModel;
@@ -47,11 +46,11 @@
     int i = 0;
     for (Double value : values) {
       if (value != null) {
-        prefs.add(new GenericPreference(null, new GenericItem<String>(String.valueOf(i)), value));
+        prefs.add(new GenericPreference(null, String.valueOf(i), value));
       }
       i++;
     }
-    return new GenericUser<String>(userID, prefs);
+    return new GenericUser(userID, prefs);
   }
 
   public static DataModel getDataModel(User... users) {

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/model/file/FileDataModelTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/model/file/FileDataModelTest.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/model/file/FileDataModelTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/model/file/FileDataModelTest.java Fri Jul 24 14:32:05 2009
@@ -23,7 +23,6 @@
 import org.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender;
 import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity;
 import org.apache.mahout.cf.taste.model.DataModel;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.Preference;
 import org.apache.mahout.cf.taste.model.User;
 import org.apache.mahout.cf.taste.neighborhood.UserNeighborhood;
@@ -101,8 +100,6 @@
 
   public void testTranspose() throws Exception {
     FileDataModel tModel = new FileDataModel(testFile, true);
-    Item item = tModel.getItem("A123");
-    assertNotNull("item is null and it shouldn't be", item);
     User user = tModel.getUser("456");
     assertNotNull("user is null and it shouldn't be", user);
     Preference[] pref = tModel.getPreferencesForItemAsArray("A123");
@@ -110,25 +107,21 @@
     assertEquals("pref Size: " + pref.length + " is not: " + 3, 3, pref.length);
   }
 
-  public void testItem() throws Exception {
-    assertEquals("456", model.getItem("456").getID());
-  }
-
   public void testGetItems() throws Exception {
-    Iterable<? extends Item> items = model.getItems();
+    Iterable<Comparable<?>> items = model.getItemIDs();
     assertNotNull(items);
-    Iterator<? extends Item> it = items.iterator();
+    Iterator<Comparable<?>> it = items.iterator();
     assertNotNull(it);
     assertTrue(it.hasNext());
-    assertEquals("123", it.next().getID());
+    assertEquals("123", it.next());
     assertTrue(it.hasNext());
-    assertEquals("234", it.next().getID());
+    assertEquals("234", it.next());
     assertTrue(it.hasNext());
-    assertEquals("456", it.next().getID());
+    assertEquals("456", it.next());
     assertTrue(it.hasNext());
-    assertEquals("654", it.next().getID());
+    assertEquals("654", it.next());
     assertTrue(it.hasNext());
-    assertEquals("789", it.next().getID());
+    assertEquals("789", it.next());
     assertFalse(it.hasNext());
     try {
       it.next();
@@ -146,11 +139,11 @@
     assertTrue(it.hasNext());
     Preference pref1 = it.next();
     assertEquals("A123", pref1.getUser().getID());
-    assertEquals("456", pref1.getItem().getID());
+    assertEquals("456", pref1.getItemID());
     assertTrue(it.hasNext());
     Preference pref2 = it.next();
     assertEquals("D456", pref2.getUser().getID());
-    assertEquals("456", pref2.getItem().getID());
+    assertEquals("456", pref2.getItemID());
     assertFalse(it.hasNext());
     try {
       it.next();

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/neighborhood/DummySimilarity.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/neighborhood/DummySimilarity.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/neighborhood/DummySimilarity.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/neighborhood/DummySimilarity.java Fri Jul 24 14:32:05 2009
@@ -18,7 +18,6 @@
 package org.apache.mahout.cf.taste.impl.neighborhood;
 
 import org.apache.mahout.cf.taste.common.Refreshable;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.User;
 import org.apache.mahout.cf.taste.similarity.ItemSimilarity;
 import org.apache.mahout.cf.taste.similarity.PreferenceInferrer;
@@ -35,9 +34,9 @@
   }
 
   @Override
-  public double itemSimilarity(Item item1, Item item2) {
+  public double itemSimilarity(Comparable<?> itemID1, Comparable<?> itemID2) {
     // Make up something wacky
-    return (double) (item1.hashCode() - item2.hashCode());
+    return (double) (itemID1.hashCode() - itemID2.hashCode());
   }
 
   @Override

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/CachingRecommenderTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/CachingRecommenderTest.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/CachingRecommenderTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/CachingRecommenderTest.java Fri Jul 24 14:32:05 2009
@@ -18,7 +18,6 @@
 package org.apache.mahout.cf.taste.impl.recommender;
 
 import org.apache.mahout.cf.taste.impl.TasteTestCase;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.recommender.Recommender;
 import org.apache.mahout.cf.taste.recommender.Rescorer;
 
@@ -49,7 +48,7 @@
     assertEquals(5, recommendCount.get());
 
     // Results from this recommend() method can be cached...
-    Rescorer<Item> rescorer = NullRescorer.getItemInstance();
+    Rescorer<Comparable<?>> rescorer = NullRescorer.getItemInstance();
     cachingRecommender.refresh(null);
     cachingRecommender.recommend("1", 1, rescorer);
     assertEquals(6, recommendCount.get());

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/GenericItemBasedRecommenderTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/GenericItemBasedRecommenderTest.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/GenericItemBasedRecommenderTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/GenericItemBasedRecommenderTest.java Fri Jul 24 14:32:05 2009
@@ -19,10 +19,8 @@
 
 import org.apache.mahout.cf.taste.impl.TasteTestCase;
 import org.apache.mahout.cf.taste.impl.model.GenericDataModel;
-import org.apache.mahout.cf.taste.impl.model.GenericItem;
 import org.apache.mahout.cf.taste.impl.similarity.GenericItemSimilarity;
 import org.apache.mahout.cf.taste.model.DataModel;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.User;
 import org.apache.mahout.cf.taste.recommender.ItemBasedRecommender;
 import org.apache.mahout.cf.taste.recommender.RecommendedItem;
@@ -42,10 +40,10 @@
     assertNotNull(recommended);
     assertEquals(1, recommended.size());
     RecommendedItem firstRecommended = recommended.get(0);
-    assertEquals(new GenericItem<String>("2"), firstRecommended.getItem());
+    assertEquals("2", firstRecommended.getItemID());
     assertEquals(0.1, firstRecommended.getValue(), EPSILON);
     recommender.refresh(null);
-    assertEquals(new GenericItem<String>("2"), firstRecommended.getItem());
+    assertEquals("2", firstRecommended.getItemID());
     assertEquals(0.1, firstRecommended.getValue(), EPSILON);
   }
 
@@ -62,8 +60,8 @@
     for (int i = 0; i < 6; i++) {
       for (int j = i + 1; j < 6; j++) {
         similarities.add(
-            new GenericItemSimilarity.ItemItemSimilarity(new GenericItem<String>(String.valueOf(i)),
-                new GenericItem<String>(String.valueOf(j)),
+            new GenericItemSimilarity.ItemItemSimilarity(String.valueOf(i),
+                String.valueOf(j),
                 1.0 / (1.0 + (double) i + (double) j)));
       }
     }
@@ -72,11 +70,11 @@
     List<RecommendedItem> fewRecommended = recommender.recommend("test1", 2);
     List<RecommendedItem> moreRecommended = recommender.recommend("test1", 4);
     for (int i = 0; i < fewRecommended.size(); i++) {
-      assertEquals(fewRecommended.get(i).getItem(), moreRecommended.get(i).getItem());
+      assertEquals(fewRecommended.get(i).getItemID(), moreRecommended.get(i).getItemID());
     }
     recommender.refresh(null);
     for (int i = 0; i < fewRecommended.size(); i++) {
-      assertEquals(fewRecommended.get(i).getItem(), moreRecommended.get(i).getItem());
+      assertEquals(fewRecommended.get(i).getItemID(), moreRecommended.get(i).getItemID());
     }
   }
 
@@ -86,10 +84,10 @@
     users.add(getUser("test2", 0.2, 0.3, 0.3, 0.6));
     users.add(getUser("test3", 0.4, 0.4, 0.5, 0.9));
     DataModel dataModel = new GenericDataModel(users);
-    Item item1 = new GenericItem<String>("0");
-    Item item2 = new GenericItem<String>("1");
-    Item item3 = new GenericItem<String>("2");
-    Item item4 = new GenericItem<String>("3");
+    Comparable<?> item1 = "0";
+    Comparable<?> item2 = "1";
+    Comparable<?> item3 = "2";
+    Comparable<?> item4 = "3";
     Collection<GenericItemSimilarity.ItemItemSimilarity> similarities =
         new ArrayList<GenericItemSimilarity.ItemItemSimilarity>(6);
     similarities.add(new GenericItemSimilarity.ItemItemSimilarity(item1, item2, 1.0));
@@ -102,13 +100,13 @@
     Recommender recommender = new GenericItemBasedRecommender(dataModel, similarity);
     List<RecommendedItem> originalRecommended = recommender.recommend("test1", 2);
     List<RecommendedItem> rescoredRecommended =
-        recommender.recommend("test1", 2, new ReversingRescorer<Item>());
+        recommender.recommend("test1", 2, new ReversingRescorer<Comparable<?>>());
     assertNotNull(originalRecommended);
     assertNotNull(rescoredRecommended);
     assertEquals(2, originalRecommended.size());
     assertEquals(2, rescoredRecommended.size());
-    assertEquals(originalRecommended.get(0).getItem(), rescoredRecommended.get(1).getItem());
-    assertEquals(originalRecommended.get(1).getItem(), rescoredRecommended.get(0).getItem());
+    assertEquals(originalRecommended.get(0).getItemID(), rescoredRecommended.get(1).getItemID());
+    assertEquals(originalRecommended.get(1).getItemID(), rescoredRecommended.get(0).getItemID());
   }
 
   public void testEstimatePref() throws Exception {
@@ -127,7 +125,7 @@
     assertEquals(1, recommended.size());
     RecommendedItem firstRecommended = recommended.get(0);
     // item one should be recommended because it has a greater rating/score
-    assertEquals(new GenericItem<String>("2"), firstRecommended.getItem());
+    assertEquals("2", firstRecommended.getItemID());
     assertEquals(0.1, firstRecommended.getValue(), EPSILON);
   }
 
@@ -138,15 +136,15 @@
     assertEquals(2, similar.size());
     RecommendedItem first = similar.get(0);
     RecommendedItem second = similar.get(1);
-    assertEquals("1", first.getItem().getID());
+    assertEquals("1", first.getItemID());
     assertEquals(1.0, first.getValue(), EPSILON);
-    assertEquals("2", second.getItem().getID());
+    assertEquals("2", second.getItemID());
     assertEquals(0.5, second.getValue(), EPSILON);
   }
 
   public void testMostSimilarToMultiple() throws Exception {
     ItemBasedRecommender recommender = buildRecommender2();
-    List<Object> itemIDs = new ArrayList<Object>(2);
+    List<Comparable<?>> itemIDs = new ArrayList<Comparable<?>>(2);
     itemIDs.add("0");
     itemIDs.add("1");
     List<RecommendedItem> similar = recommender.mostSimilarItems(itemIDs, 2);
@@ -154,9 +152,9 @@
     assertEquals(2, similar.size());
     RecommendedItem first = similar.get(0);
     RecommendedItem second = similar.get(1);
-    assertEquals("2", first.getItem().getID());
+    assertEquals("2", first.getItemID());
     assertEquals(0.85, first.getValue(), EPSILON);
-    assertEquals("3", second.getItem().getID());
+    assertEquals("3", second.getItemID());
     assertEquals(-0.3, second.getValue(), EPSILON);
   }
 
@@ -168,11 +166,11 @@
     RecommendedItem first = recommendedBecause.get(0);
     RecommendedItem second = recommendedBecause.get(1);
     RecommendedItem third = recommendedBecause.get(2);
-    assertEquals("2", first.getItem().getID());
+    assertEquals("2", first.getItemID());
     assertEquals(0.99, first.getValue(), EPSILON);
-    assertEquals("3", second.getItem().getID());
+    assertEquals("3", second.getItemID());
     assertEquals(0.4, second.getValue(), EPSILON);
-    assertEquals("0", third.getItem().getID());
+    assertEquals("0", third.getItemID());
     assertEquals(0.2, third.getValue(), EPSILON);
   }
 
@@ -180,9 +178,9 @@
     DataModel dataModel = new GenericDataModel(getMockUsers());
     Collection<GenericItemSimilarity.ItemItemSimilarity> similarities =
         new ArrayList<GenericItemSimilarity.ItemItemSimilarity>(2);
-    Item item1 = new GenericItem<String>("0");
-    Item item2 = new GenericItem<String>("1");
-    Item item3 = new GenericItem<String>("2");
+    Comparable<?> item1 = "0";
+    Comparable<?> item2 = "1";
+    Comparable<?> item3 = "2";
     similarities.add(new GenericItemSimilarity.ItemItemSimilarity(item1, item2, 1.0));
     similarities.add(new GenericItemSimilarity.ItemItemSimilarity(item1, item3, 0.5));
     ItemSimilarity similarity = new GenericItemSimilarity(similarities);
@@ -198,11 +196,11 @@
     DataModel dataModel = new GenericDataModel(users);
     Collection<GenericItemSimilarity.ItemItemSimilarity> similarities =
         new ArrayList<GenericItemSimilarity.ItemItemSimilarity>(10);
-    Item item1 = new GenericItem<String>("0");
-    Item item2 = new GenericItem<String>("1");
-    Item item3 = new GenericItem<String>("2");
-    Item item4 = new GenericItem<String>("3");
-    Item item5 = new GenericItem<String>("4");
+    Comparable<?> item1 = "0";
+    Comparable<?> item2 = "1";
+    Comparable<?> item3 = "2";
+    Comparable<?> item4 = "3";
+    Comparable<?> item5 = "4";
     similarities.add(new GenericItemSimilarity.ItemItemSimilarity(item1, item2, 1.0));
     similarities.add(new GenericItemSimilarity.ItemItemSimilarity(item1, item3, 0.8));
     similarities.add(new GenericItemSimilarity.ItemItemSimilarity(item1, item4, -0.6));

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/GenericUserBasedRecommenderTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/GenericUserBasedRecommenderTest.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/GenericUserBasedRecommenderTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/GenericUserBasedRecommenderTest.java Fri Jul 24 14:32:05 2009
@@ -19,11 +19,9 @@
 
 import org.apache.mahout.cf.taste.impl.TasteTestCase;
 import org.apache.mahout.cf.taste.impl.model.GenericDataModel;
-import org.apache.mahout.cf.taste.impl.model.GenericItem;
 import org.apache.mahout.cf.taste.impl.neighborhood.NearestNUserNeighborhood;
 import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity;
 import org.apache.mahout.cf.taste.model.DataModel;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.User;
 import org.apache.mahout.cf.taste.neighborhood.UserNeighborhood;
 import org.apache.mahout.cf.taste.recommender.RecommendedItem;
@@ -44,10 +42,10 @@
     assertNotNull(recommended);
     assertEquals(1, recommended.size());
     RecommendedItem firstRecommended = recommended.get(0);
-    assertEquals(new GenericItem<String>("2"), firstRecommended.getItem());
+    assertEquals("2", firstRecommended.getItemID());
     assertEquals(0.3, firstRecommended.getValue());
     recommender.refresh(null);
-    assertEquals(new GenericItem<String>("2"), firstRecommended.getItem());
+    assertEquals("2", firstRecommended.getItemID());
     assertEquals(0.3, firstRecommended.getValue());
   }
 
@@ -65,11 +63,11 @@
     List<RecommendedItem> fewRecommended = recommender.recommend("test1", 2);
     List<RecommendedItem> moreRecommended = recommender.recommend("test1", 4);
     for (int i = 0; i < fewRecommended.size(); i++) {
-      assertEquals(fewRecommended.get(i).getItem(), moreRecommended.get(i).getItem());
+      assertEquals(fewRecommended.get(i).getItemID(), moreRecommended.get(i).getItemID());
     }
     recommender.refresh(null);
     for (int i = 0; i < fewRecommended.size(); i++) {
-      assertEquals(fewRecommended.get(i).getItem(), moreRecommended.get(i).getItem());
+      assertEquals(fewRecommended.get(i).getItemID(), moreRecommended.get(i).getItemID());
     }
   }
 
@@ -84,13 +82,13 @@
     Recommender recommender = new GenericUserBasedRecommender(dataModel, neighborhood, similarity);
     List<RecommendedItem> originalRecommended = recommender.recommend("test1", 2);
     List<RecommendedItem> rescoredRecommended =
-        recommender.recommend("test1", 2, new ReversingRescorer<Item>());
+        recommender.recommend("test1", 2, new ReversingRescorer<Comparable<?>>());
     assertNotNull(originalRecommended);
     assertNotNull(rescoredRecommended);
     assertEquals(2, originalRecommended.size());
     assertEquals(2, rescoredRecommended.size());
-    assertEquals(originalRecommended.get(0).getItem(), rescoredRecommended.get(1).getItem());
-    assertEquals(originalRecommended.get(1).getItem(), rescoredRecommended.get(0).getItem());
+    assertEquals(originalRecommended.get(0).getItemID(), rescoredRecommended.get(1).getItemID());
+    assertEquals(originalRecommended.get(1).getItemID(), rescoredRecommended.get(0).getItemID());
   }
 
   public void testEstimatePref() throws Exception {
@@ -105,7 +103,7 @@
     assertEquals(1, recommended.size());
     RecommendedItem firstRecommended = recommended.get(0);
     // item one should be recommended because it has a greater rating/score
-    assertEquals(new GenericItem<String>("2"), firstRecommended.getItem());
+    assertEquals("2", firstRecommended.getItemID());
     assertEquals(0.3, firstRecommended.getValue(), EPSILON);
   }
 

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/MockRecommender.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/MockRecommender.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/MockRecommender.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/MockRecommender.java Fri Jul 24 14:32:05 2009
@@ -19,10 +19,8 @@
 
 import org.apache.mahout.cf.taste.common.Refreshable;
 import org.apache.mahout.cf.taste.impl.model.GenericDataModel;
-import org.apache.mahout.cf.taste.impl.model.GenericItem;
 import org.apache.mahout.cf.taste.impl.model.GenericUser;
 import org.apache.mahout.cf.taste.model.DataModel;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.Preference;
 import org.apache.mahout.cf.taste.model.User;
 import org.apache.mahout.cf.taste.recommender.RecommendedItem;
@@ -45,40 +43,40 @@
   }
 
   @Override
-  public List<RecommendedItem> recommend(Object userID, int howMany) {
+  public List<RecommendedItem> recommend(Comparable<?> userID, int howMany) {
     recommendCount.incrementAndGet();
     return Collections.<RecommendedItem>singletonList(
-        new GenericRecommendedItem(new GenericItem<String>("1"), 1.0));
+        new GenericRecommendedItem("1", 1.0));
   }
 
   @Override
-  public List<RecommendedItem> recommend(Object userID,
+  public List<RecommendedItem> recommend(Comparable<?> userID,
                                          int howMany,
-                                         Rescorer<Item> rescorer) {
+                                         Rescorer<Comparable<?>> rescorer) {
     return recommend(userID, howMany);
   }
 
   @Override
-  public double estimatePreference(Object userID, Object itemID) {
+  public double estimatePreference(Comparable<?> userID, Comparable<?> itemID) {
     recommendCount.incrementAndGet();
     return 0.0;
   }
 
   @Override
-  public void setPreference(Object userID, Object itemID, double value) {
+  public void setPreference(Comparable<?> userID, Comparable<?> itemID, double value) {
     // do nothing
   }
 
   @Override
-  public void removePreference(Object userID, Object itemID) {
+  public void removePreference(Comparable<?> userID, Comparable<?> itemID) {
     // do nothing
   }
 
   @Override
   public DataModel getDataModel() {
-    User user1 = new GenericUser<String>("1", Collections.<Preference>emptyList());
-    User user2 = new GenericUser<String>("2", Collections.<Preference>emptyList());
-    User user3 = new GenericUser<String>("3", Collections.<Preference>emptyList());
+    User user1 = new GenericUser("1", Collections.<Preference>emptyList());
+    User user2 = new GenericUser("2", Collections.<Preference>emptyList());
+    User user3 = new GenericUser("3", Collections.<Preference>emptyList());
     List<User> users = new ArrayList<User>(3);
     users.add(user1);
     users.add(user2);

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/NullRescorerTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/NullRescorerTest.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/NullRescorerTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/NullRescorerTest.java Fri Jul 24 14:32:05 2009
@@ -18,9 +18,7 @@
 package org.apache.mahout.cf.taste.impl.recommender;
 
 import org.apache.mahout.cf.taste.impl.TasteTestCase;
-import org.apache.mahout.cf.taste.impl.model.GenericItem;
 import org.apache.mahout.cf.taste.impl.model.GenericUser;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.Preference;
 import org.apache.mahout.cf.taste.model.User;
 import org.apache.mahout.cf.taste.recommender.Rescorer;
@@ -31,19 +29,18 @@
 public final class NullRescorerTest extends TasteTestCase {
 
   public void testItemRescorer() throws Exception {
-    Rescorer<Item> rescorer = NullRescorer.getItemInstance();
+    Rescorer<Comparable<?>> rescorer = NullRescorer.getItemInstance();
     assertNotNull(rescorer);
-    Item item = new GenericItem<String>("test");
-    assertEquals(1.0, rescorer.rescore(item, 1.0));
+    assertEquals(1.0, rescorer.rescore("test", 1.0));
     assertEquals(1.0, rescorer.rescore(null, 1.0));
-    assertEquals(0.0, rescorer.rescore(item, 0.0));
-    assertTrue(Double.isNaN(rescorer.rescore(item, Double.NaN)));
+    assertEquals(0.0, rescorer.rescore("test", 0.0));
+    assertTrue(Double.isNaN(rescorer.rescore("test", Double.NaN)));
   }
 
   public void testUserRescorer() throws Exception {
     Rescorer<User> rescorer = NullRescorer.getUserInstance();
     assertNotNull(rescorer);
-    User user = new GenericUser<String>("test", Collections.<Preference>emptyList());
+    User user = new GenericUser("test", Collections.<Preference>emptyList());
     assertEquals(1.0, rescorer.rescore(user, 1.0));
     assertEquals(1.0, rescorer.rescore(null, 1.0));
     assertEquals(0.0, rescorer.rescore(user, 0.0));

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommenderTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommenderTest.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommenderTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommenderTest.java Fri Jul 24 14:32:05 2009
@@ -19,10 +19,8 @@
 
 import org.apache.mahout.cf.taste.impl.TasteTestCase;
 import org.apache.mahout.cf.taste.impl.model.GenericDataModel;
-import org.apache.mahout.cf.taste.impl.model.GenericItem;
 import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity;
 import org.apache.mahout.cf.taste.model.DataModel;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.User;
 import org.apache.mahout.cf.taste.recommender.RecommendedItem;
 import org.apache.mahout.cf.taste.recommender.Recommender;
@@ -65,11 +63,11 @@
     List<RecommendedItem> fewRecommended = recommender.recommend("test1", 2);
     List<RecommendedItem> moreRecommended = recommender.recommend("test1", 4);
     for (int i = 0; i < fewRecommended.size(); i++) {
-      assertEquals(fewRecommended.get(i).getItem(), moreRecommended.get(i).getItem());
+      assertEquals(fewRecommended.get(i).getItemID(), moreRecommended.get(i).getItemID());
     }
     recommender.refresh(null);
     for (int i = 0; i < fewRecommended.size(); i++) {
-      assertEquals(fewRecommended.get(i).getItem(), moreRecommended.get(i).getItem());
+      assertEquals(fewRecommended.get(i).getItemID(), moreRecommended.get(i).getItemID());
     }
   }
 
@@ -84,13 +82,13 @@
     Recommender recommender = new TreeClusteringRecommender(dataModel, clusterSimilarity, 2);
     List<RecommendedItem> originalRecommended = recommender.recommend("test1", 2);
     List<RecommendedItem> rescoredRecommended =
-        recommender.recommend("test1", 2, new ReversingRescorer<Item>());
+        recommender.recommend("test1", 2, new ReversingRescorer<Comparable<?>>());
     assertNotNull(originalRecommended);
     assertNotNull(rescoredRecommended);
     assertEquals(2, originalRecommended.size());
     assertEquals(2, rescoredRecommended.size());
-    assertEquals(originalRecommended.get(0).getItem(), rescoredRecommended.get(1).getItem());
-    assertEquals(originalRecommended.get(1).getItem(), rescoredRecommended.get(0).getItem());
+    assertEquals(originalRecommended.get(0).getItemID(), rescoredRecommended.get(1).getItemID());
+    assertEquals(originalRecommended.get(1).getItemID(), rescoredRecommended.get(0).getItemID());
   }
 
   public void testEstimatePref() throws Exception {
@@ -121,7 +119,7 @@
     assertEquals(1, recommended.size());
     RecommendedItem firstRecommended = recommended.get(0);
     // item one should be recommended because it has a greater rating/score
-    assertEquals(new GenericItem<String>("2"), firstRecommended.getItem());
+    assertEquals("2", firstRecommended.getItemID());
     assertEquals(0.3, firstRecommended.getValue(), EPSILON);
   }
 

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/SlopeOneRecommenderTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/SlopeOneRecommenderTest.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/SlopeOneRecommenderTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/SlopeOneRecommenderTest.java Fri Jul 24 14:32:05 2009
@@ -20,10 +20,8 @@
 import org.apache.mahout.cf.taste.common.TasteException;
 import org.apache.mahout.cf.taste.impl.TasteTestCase;
 import org.apache.mahout.cf.taste.impl.model.GenericDataModel;
-import org.apache.mahout.cf.taste.impl.model.GenericItem;
 import org.apache.mahout.cf.taste.impl.recommender.ReversingRescorer;
 import org.apache.mahout.cf.taste.model.DataModel;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.User;
 import org.apache.mahout.cf.taste.recommender.RecommendedItem;
 import org.apache.mahout.cf.taste.recommender.Recommender;
@@ -40,10 +38,10 @@
     assertNotNull(recommended);
     assertEquals(1, recommended.size());
     RecommendedItem firstRecommended = recommended.get(0);
-    assertEquals(new GenericItem<String>("2"), firstRecommended.getItem());
+    assertEquals("2", firstRecommended.getItemID());
     assertEquals(0.34803885284992736, firstRecommended.getValue(), EPSILON);
     recommender.refresh(null);
-    assertEquals(new GenericItem<String>("2"), firstRecommended.getItem());
+    assertEquals("2", firstRecommended.getItemID());
     assertEquals(0.34803885284992736, firstRecommended.getValue(), EPSILON);
   }
 
@@ -59,11 +57,11 @@
     List<RecommendedItem> fewRecommended = recommender.recommend("test1", 2);
     List<RecommendedItem> moreRecommended = recommender.recommend("test1", 4);
     for (int i = 0; i < fewRecommended.size(); i++) {
-      assertEquals(fewRecommended.get(i).getItem(), moreRecommended.get(i).getItem());
+      assertEquals(fewRecommended.get(i).getItemID(), moreRecommended.get(i).getItemID());
     }
     recommender.refresh(null);
     for (int i = 0; i < fewRecommended.size(); i++) {
-      assertEquals(fewRecommended.get(i).getItem(), moreRecommended.get(i).getItem());
+      assertEquals(fewRecommended.get(i).getItemID(), moreRecommended.get(i).getItemID());
     }
   }
 
@@ -76,13 +74,13 @@
     Recommender recommender = new SlopeOneRecommender(dataModel);
     List<RecommendedItem> originalRecommended = recommender.recommend("test1", 2);
     List<RecommendedItem> rescoredRecommended =
-        recommender.recommend("test1", 2, new ReversingRescorer<Item>());
+        recommender.recommend("test1", 2, new ReversingRescorer<Comparable<?>>());
     assertNotNull(originalRecommended);
     assertNotNull(rescoredRecommended);
     assertEquals(2, originalRecommended.size());
     assertEquals(2, rescoredRecommended.size());
-    assertEquals(originalRecommended.get(0).getItem(), rescoredRecommended.get(1).getItem());
-    assertEquals(originalRecommended.get(1).getItem(), rescoredRecommended.get(0).getItem());
+    assertEquals(originalRecommended.get(0).getItemID(), rescoredRecommended.get(1).getItemID());
+    assertEquals(originalRecommended.get(1).getItemID(), rescoredRecommended.get(0).getItemID());
   }
 
   public void testEstimatePref() throws Exception {
@@ -102,7 +100,7 @@
     assertEquals(1, recommended.size());
     RecommendedItem firstRecommended = recommended.get(0);
     // item one should be recommended because it has a greater rating/score
-    assertEquals(new GenericItem<String>("2"), firstRecommended.getItem());
+    assertEquals("2", firstRecommended.getItemID());
     assertEquals(0.2400938676203033, firstRecommended.getValue(), EPSILON);
   }
 

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/AveragingPreferenceInferrerTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/AveragingPreferenceInferrerTest.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/AveragingPreferenceInferrerTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/AveragingPreferenceInferrerTest.java Fri Jul 24 14:32:05 2009
@@ -20,9 +20,7 @@
 import org.apache.mahout.cf.taste.common.TasteException;
 import org.apache.mahout.cf.taste.impl.TasteTestCase;
 import org.apache.mahout.cf.taste.impl.model.GenericDataModel;
-import org.apache.mahout.cf.taste.impl.model.GenericItem;
 import org.apache.mahout.cf.taste.model.DataModel;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.User;
 import org.apache.mahout.cf.taste.similarity.PreferenceInferrer;
 
@@ -33,10 +31,9 @@
 
   public void testInferrer() throws TasteException {
     User user1 = getUser("test1", 3.0, -2.0, 5.0);
-    Item item = new GenericItem<String>("3");
     DataModel model = new GenericDataModel(Collections.singletonList(user1));
     PreferenceInferrer inferrer = new AveragingPreferenceInferrer(model);
-    double inferred = inferrer.inferPreference(user1, item);
+    double inferred = inferrer.inferPreference(user1, "3");
     assertEquals(2.0, inferred);
   }
 

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/EuclideanDistanceSimilarityTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/EuclideanDistanceSimilarityTest.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/EuclideanDistanceSimilarityTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/EuclideanDistanceSimilarityTest.java Fri Jul 24 14:32:05 2009
@@ -19,7 +19,6 @@
 
 import org.apache.mahout.cf.taste.common.TasteException;
 import org.apache.mahout.cf.taste.common.Weighting;
-import org.apache.mahout.cf.taste.impl.model.GenericItem;
 import org.apache.mahout.cf.taste.impl.model.GenericPreference;
 import org.apache.mahout.cf.taste.impl.model.GenericUser;
 import org.apache.mahout.cf.taste.model.DataModel;
@@ -73,10 +72,10 @@
   }
 
   public void testNoCorrelation2() throws Exception {
-    Preference pref1 = new GenericPreference(null, new GenericItem<String>("1"), 1.0);
-    GenericUser<String> user1 = new GenericUser<String>("test1", Collections.singletonList(pref1));
-    Preference pref2 = new GenericPreference(null, new GenericItem<String>("2"), 1.0);
-    GenericUser<String> user2 = new GenericUser<String>("test2", Collections.singletonList(pref2));
+    Preference pref1 = new GenericPreference(null, "1", 1.0);
+    GenericUser user1 = new GenericUser("test1", Collections.singletonList(pref1));
+    Preference pref2 = new GenericPreference(null, "2", 1.0);
+    GenericUser user2 = new GenericUser("test2", Collections.singletonList(pref2));
     DataModel dataModel = getDataModel(user1, user2);
     double correlation = new EuclideanDistanceSimilarity(dataModel).userSimilarity(user1, user2);
     assertTrue(Double.isNaN(correlation));
@@ -111,7 +110,7 @@
     User user2 = getUser("test2", -2.0, -2.0);
     DataModel dataModel = getDataModel(user1, user2);
     double correlation =
-        new EuclideanDistanceSimilarity(dataModel).itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
+        new EuclideanDistanceSimilarity(dataModel).itemSimilarity("0", "1");
     assertCorrelationEquals(1.0, correlation);
   }
 
@@ -120,7 +119,7 @@
     User user2 = getUser("test2", 3.0, 3.0);
     DataModel dataModel = getDataModel(user1, user2);
     double correlation =
-        new EuclideanDistanceSimilarity(dataModel).itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
+        new EuclideanDistanceSimilarity(dataModel).itemSimilarity("0", "1");
     // Yeah, undefined in this case
     assertTrue(Double.isNaN(correlation));
   }
@@ -130,18 +129,18 @@
     User user2 = getUser("test2", -2.0, 2.0);
     DataModel dataModel = getDataModel(user1, user2);
     double correlation =
-        new EuclideanDistanceSimilarity(dataModel).itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
+        new EuclideanDistanceSimilarity(dataModel).itemSimilarity("0", "1");
     assertCorrelationEquals(0.424465381883345, correlation);
   }
 
   public void testNoItemCorrelation2() throws Exception {
-    Preference pref1 = new GenericPreference(null, new GenericItem<String>("1"), 1.0);
-    GenericUser<String> user1 = new GenericUser<String>("test1", Collections.singletonList(pref1));
-    Preference pref2 = new GenericPreference(null, new GenericItem<String>("2"), 1.0);
-    GenericUser<String> user2 = new GenericUser<String>("test2", Collections.singletonList(pref2));
+    Preference pref1 = new GenericPreference(null, "1", 1.0);
+    GenericUser user1 = new GenericUser("test1", Collections.singletonList(pref1));
+    Preference pref2 = new GenericPreference(null, "2", 1.0);
+    GenericUser user2 = new GenericUser("test2", Collections.singletonList(pref2));
     DataModel dataModel = getDataModel(user1, user2);
     double correlation =
-        new EuclideanDistanceSimilarity(dataModel).itemSimilarity(dataModel.getItem("1"), dataModel.getItem("2"));
+        new EuclideanDistanceSimilarity(dataModel).itemSimilarity("1", "2");
     assertTrue(Double.isNaN(correlation));
   }
 
@@ -151,7 +150,7 @@
     User user3 = getUser("test3", 70.0, 90.0);
     DataModel dataModel = getDataModel(user1, user2, user3);
     double correlation =
-        new EuclideanDistanceSimilarity(dataModel).itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
+        new EuclideanDistanceSimilarity(dataModel).itemSimilarity("0", "1");
     assertCorrelationEquals(0.3606507916004517, correlation);
   }
 
@@ -161,7 +160,7 @@
     User user3 = getUser("test3", 3.0, 6.0);
     DataModel dataModel = getDataModel(user1, user2, user3);
     double correlation =
-        new EuclideanDistanceSimilarity(dataModel).itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
+        new EuclideanDistanceSimilarity(dataModel).itemSimilarity("0", "1");
     assertCorrelationEquals(0.5896248568217328, correlation);
   }
 
@@ -171,7 +170,7 @@
     User user3 = getUser("test3", 3.0, 6.0);
     DataModel dataModel = getDataModel(user1, user2, user3);
     ItemSimilarity itemSimilarity = new EuclideanDistanceSimilarity(dataModel, Weighting.WEIGHTED);
-    double correlation = itemSimilarity.itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
+    double correlation = itemSimilarity.itemSimilarity("0", "1");
     assertCorrelationEquals(0.8974062142054332, correlation);
   }
 

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/GenericItemSimilarityTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/GenericItemSimilarityTest.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/GenericItemSimilarityTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/GenericItemSimilarityTest.java Fri Jul 24 14:32:05 2009
@@ -16,9 +16,7 @@
  */
 package org.apache.mahout.cf.taste.impl.similarity;
 
-import org.apache.mahout.cf.taste.impl.model.GenericItem;
 import org.apache.mahout.cf.taste.model.DataModel;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.User;
 import org.apache.mahout.cf.taste.similarity.ItemSimilarity;
 
@@ -29,10 +27,10 @@
 public final class GenericItemSimilarityTest extends SimilarityTestCase {
 
   public void testSimple() {
-    Item item1 = new GenericItem<String>("1");
-    Item item2 = new GenericItem<String>("2");
-    Item item3 = new GenericItem<String>("3");
-    Item item4 = new GenericItem<String>("4");
+    Comparable<?> item1 = "1";
+    Comparable<?> item2 = "2";
+    Comparable<?> item3 = "3";
+    Comparable<?> item4 = "4";
     List<GenericItemSimilarity.ItemItemSimilarity> similarities =
         new ArrayList<GenericItemSimilarity.ItemItemSimilarity>(4);
     similarities.add(new GenericItemSimilarity.ItemItemSimilarity(item1, item2, 0.5));
@@ -54,10 +52,8 @@
     DataModel dataModel = getDataModel(user1, user2, user3);
     ItemSimilarity otherSimilarity = new PearsonCorrelationSimilarity(dataModel);
     ItemSimilarity itemSimilarity = new GenericItemSimilarity(otherSimilarity, dataModel);
-    assertCorrelationEquals(1.0,
-        itemSimilarity.itemSimilarity(dataModel.getItem("0"), dataModel.getItem("0")));
-    assertCorrelationEquals(0.960768922830523,
-        itemSimilarity.itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1")));
+    assertCorrelationEquals(1.0, itemSimilarity.itemSimilarity("0", "0"));
+    assertCorrelationEquals(0.960768922830523, itemSimilarity.itemSimilarity("0", "1"));
   }
 
 }

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/LogLikelihoodSimilarityTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/LogLikelihoodSimilarityTest.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/LogLikelihoodSimilarityTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/LogLikelihoodSimilarityTest.java Fri Jul 24 14:32:05 2009
@@ -31,28 +31,22 @@
     User user5 = getUser("test5", null, 1.0, 1.0, 1.0, 1.0);
     DataModel dataModel = getDataModel(user1, user2, user3, user4, user5);
 
-    double correlation = new LogLikelihoodSimilarity(dataModel).
-        itemSimilarity(dataModel.getItem("1"), dataModel.getItem("0"));
+    double correlation = new LogLikelihoodSimilarity(dataModel).itemSimilarity("1", "0");
     assertCorrelationEquals(0.12160727029227925, correlation);
 
-    correlation = new LogLikelihoodSimilarity(dataModel).
-        itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
+    correlation = new LogLikelihoodSimilarity(dataModel).itemSimilarity("0", "1");
     assertCorrelationEquals(0.12160727029227925, correlation);
 
-    correlation = new LogLikelihoodSimilarity(dataModel).
-        itemSimilarity(dataModel.getItem("2"), dataModel.getItem("1"));
+    correlation = new LogLikelihoodSimilarity(dataModel).itemSimilarity("2", "1");
     assertCorrelationEquals(0.5423213660693733, correlation);
 
-    correlation = new LogLikelihoodSimilarity(dataModel).
-        itemSimilarity(dataModel.getItem("2"), dataModel.getItem("3"));
+    correlation = new LogLikelihoodSimilarity(dataModel).itemSimilarity("2", "3");
     assertCorrelationEquals(0.6905400104897509, correlation);
 
-    correlation = new LogLikelihoodSimilarity(dataModel).
-        itemSimilarity(dataModel.getItem("3"), dataModel.getItem("4"));
+    correlation = new LogLikelihoodSimilarity(dataModel).itemSimilarity("3", "4");
     assertCorrelationEquals(0.8706358464330881, correlation);
 
-    correlation = new LogLikelihoodSimilarity(dataModel).
-        itemSimilarity(dataModel.getItem("4"), dataModel.getItem("3"));
+    correlation = new LogLikelihoodSimilarity(dataModel).itemSimilarity("4", "3");
     assertCorrelationEquals(0.8706358464330881, correlation);
   }
 

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/PearsonCorrelationSimilarityTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/PearsonCorrelationSimilarityTest.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/PearsonCorrelationSimilarityTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/similarity/PearsonCorrelationSimilarityTest.java Fri Jul 24 14:32:05 2009
@@ -18,7 +18,6 @@
 package org.apache.mahout.cf.taste.impl.similarity;
 
 import org.apache.mahout.cf.taste.common.Weighting;
-import org.apache.mahout.cf.taste.impl.model.GenericItem;
 import org.apache.mahout.cf.taste.impl.model.GenericPreference;
 import org.apache.mahout.cf.taste.impl.model.GenericUser;
 import org.apache.mahout.cf.taste.model.DataModel;
@@ -73,10 +72,10 @@
   }
 
   public void testNoCorrelation2() throws Exception {
-    Preference pref1 = new GenericPreference(null, new GenericItem<String>("1"), 1.0);
-    GenericUser<String> user1 = new GenericUser<String>("test1", Collections.singletonList(pref1));
-    Preference pref2 = new GenericPreference(null, new GenericItem<String>("2"), 1.0);
-    GenericUser<String> user2 = new GenericUser<String>("test2", Collections.singletonList(pref2));
+    Preference pref1 = new GenericPreference(null, "1", 1.0);
+    GenericUser user1 = new GenericUser("test1", Collections.singletonList(pref1));
+    Preference pref2 = new GenericPreference(null, "2", 1.0);
+    GenericUser user2 = new GenericUser("test2", Collections.singletonList(pref2));
     DataModel dataModel = getDataModel(user1, user2);
     double correlation = new PearsonCorrelationSimilarity(dataModel).userSimilarity(user1, user2);
     assertTrue(Double.isNaN(correlation));
@@ -111,7 +110,7 @@
     User user2 = getUser("test2", -2.0, -2.0);
     DataModel dataModel = getDataModel(user1, user2);
     double correlation =
-        new PearsonCorrelationSimilarity(dataModel).itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
+        new PearsonCorrelationSimilarity(dataModel).itemSimilarity("0", "1");
     assertCorrelationEquals(1.0, correlation);
   }
 
@@ -120,7 +119,7 @@
     User user2 = getUser("test2", 3.0, 3.0);
     DataModel dataModel = getDataModel(user1, user2);
     double correlation =
-        new PearsonCorrelationSimilarity(dataModel).itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
+        new PearsonCorrelationSimilarity(dataModel).itemSimilarity("0", "1");
     // Yeah, undefined in this case
     assertTrue(Double.isNaN(correlation));
   }
@@ -130,18 +129,18 @@
     User user2 = getUser("test2", -2.0, 2.0);
     DataModel dataModel = getDataModel(user1, user2);
     double correlation =
-        new PearsonCorrelationSimilarity(dataModel).itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
+        new PearsonCorrelationSimilarity(dataModel).itemSimilarity("0", "1");
     assertCorrelationEquals(-1.0, correlation);
   }
 
   public void testNoItemCorrelation2() throws Exception {
-    Preference pref1 = new GenericPreference(null, new GenericItem<String>("1"), 1.0);
-    GenericUser<String> user1 = new GenericUser<String>("test1", Collections.singletonList(pref1));
-    Preference pref2 = new GenericPreference(null, new GenericItem<String>("2"), 1.0);
-    GenericUser<String> user2 = new GenericUser<String>("test2", Collections.singletonList(pref2));
+    Preference pref1 = new GenericPreference(null, "1", 1.0);
+    GenericUser user1 = new GenericUser("test1", Collections.singletonList(pref1));
+    Preference pref2 = new GenericPreference(null, "2", 1.0);
+    GenericUser user2 = new GenericUser("test2", Collections.singletonList(pref2));
     DataModel dataModel = getDataModel(user1, user2);
     double correlation =
-        new PearsonCorrelationSimilarity(dataModel).itemSimilarity(dataModel.getItem("1"), dataModel.getItem("2"));
+        new PearsonCorrelationSimilarity(dataModel).itemSimilarity("1", "2");
     assertTrue(Double.isNaN(correlation));
   }
 
@@ -151,7 +150,7 @@
     User user3 = getUser("test3", 70.0, 90.0);
     DataModel dataModel = getDataModel(user1, user2, user3);
     double correlation =
-        new PearsonCorrelationSimilarity(dataModel).itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
+        new PearsonCorrelationSimilarity(dataModel).itemSimilarity("0", "1");
     assertCorrelationEquals(-1.0, correlation);
   }
 
@@ -161,7 +160,7 @@
     User user3 = getUser("test3", 3.0, 6.0);
     DataModel dataModel = getDataModel(user1, user2, user3);
     double correlation =
-        new PearsonCorrelationSimilarity(dataModel).itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
+        new PearsonCorrelationSimilarity(dataModel).itemSimilarity("0", "1");
     assertCorrelationEquals(0.9607689228305227, correlation);
   }
 
@@ -171,7 +170,7 @@
     User user3 = getUser("test3", 3.0, 6.0);
     DataModel dataModel = getDataModel(user1, user2, user3);
     ItemSimilarity itemSimilarity = new PearsonCorrelationSimilarity(dataModel, Weighting.WEIGHTED);
-    double correlation = itemSimilarity.itemSimilarity(dataModel.getItem("0"), dataModel.getItem("1"));
+    double correlation = itemSimilarity.itemSimilarity("0", "1");
     assertCorrelationEquals(0.9901922307076306, correlation);
   }
 

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJB.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJB.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJB.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJB.java Fri Jul 24 14:32:05 2009
@@ -19,7 +19,6 @@
 
 import org.apache.mahout.cf.taste.common.Refreshable;
 import org.apache.mahout.cf.taste.common.TasteException;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.recommender.Rescorer;
 
 import javax.ejb.EJBObject;
@@ -36,28 +35,29 @@
 public interface RecommenderEJB extends EJBObject {
 
   /**
-   * @see org.apache.mahout.cf.taste.recommender.Recommender#recommend(Object, int)
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#recommend(Comparable, int)
    */
-  List<Item> recommend(Object userID, int howMany) throws TasteException, RemoteException;
+  List<Comparable<?>> recommend(Object userID, int howMany) throws TasteException, RemoteException;
 
   /**
-   * @see org.apache.mahout.cf.taste.recommender.Recommender#recommend(Object, int, Rescorer)
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#recommend(Comparable, int, Rescorer)
    */
-  List<Item> recommend(Object userID, int howMany, Rescorer<Item> rescorer) throws TasteException, RemoteException;
+  List<Comparable<?>> recommend(Object userID, int howMany, Rescorer<Comparable<?>> rescorer)
+          throws TasteException, RemoteException;
 
   /**
-   * @see org.apache.mahout.cf.taste.recommender.Recommender#estimatePreference(Object, Object)
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#estimatePreference(Comparable, Comparable)
    */
   double estimatePreference(Object userID, Object itemID) throws TasteException, RemoteException;
 
   /**
-   * @see org.apache.mahout.cf.taste.recommender.Recommender#setPreference(Object, Object, double)
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#setPreference(Comparable, Comparable, double)
    */
   void setPreference(Object userID, Object itemID, double value)
           throws TasteException, RemoteException;
 
   /**
-   * @see org.apache.mahout.cf.taste.recommender.Recommender#removePreference(Object, Object)
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#removePreference(Comparable, Comparable)
    */
   void removePreference(Object userID, Object itemID) throws TasteException, RemoteException;
 

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBBean.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBBean.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBBean.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBBean.java Fri Jul 24 14:32:05 2009
@@ -19,7 +19,6 @@
 
 import org.apache.mahout.cf.taste.common.Refreshable;
 import org.apache.mahout.cf.taste.common.TasteException;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.recommender.RecommendedItem;
 import org.apache.mahout.cf.taste.recommender.Recommender;
 import org.apache.mahout.cf.taste.recommender.Rescorer;
@@ -44,25 +43,25 @@
 
   private Recommender recommender;
 
-  public List<RecommendedItem> recommend(Object userID, int howMany) throws TasteException {
+  public List<RecommendedItem> recommend(Comparable<?> userID, int howMany) throws TasteException {
     return recommender.recommend(userID, howMany);
   }
 
-  public List<RecommendedItem> recommend(Object userID, int howMany, Rescorer<Item> rescorer)
+  public List<RecommendedItem> recommend(Comparable<?> userID, int howMany, Rescorer<Comparable<?>> rescorer)
           throws TasteException {
     return recommender.recommend(userID, howMany, rescorer);
   }
 
 
-  public double estimatePreference(Object userID, Object itemID) throws TasteException {
+  public double estimatePreference(Comparable<?> userID, Comparable<?> itemID) throws TasteException {
     return recommender.estimatePreference(userID, itemID);
   }
 
-  public void setPreference(Object userID, Object itemID, double value) throws TasteException {
+  public void setPreference(Comparable<?> userID, Comparable<?> itemID, double value) throws TasteException {
     recommender.setPreference(userID, itemID, value);
   }
 
-  public void removePreference(Object userID, Object itemID) throws TasteException {
+  public void removePreference(Comparable<?> userID, Comparable<?> itemID) throws TasteException {
     recommender.removePreference(userID, itemID);
   }
 

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBLocal.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBLocal.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBLocal.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBLocal.java Fri Jul 24 14:32:05 2009
@@ -19,7 +19,6 @@
 
 import org.apache.mahout.cf.taste.common.Refreshable;
 import org.apache.mahout.cf.taste.common.TasteException;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.recommender.Rescorer;
 
 import javax.ejb.EJBLocalObject;
@@ -35,27 +34,27 @@
 public interface RecommenderEJBLocal extends EJBLocalObject {
 
   /**
-   * @see org.apache.mahout.cf.taste.recommender.Recommender#recommend(Object, int)
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#recommend(Comparable, int)
    */
-  List<Item> recommend(Object userID, int howMany) throws TasteException;
+  List<Comparable<?>> recommend(Object userID, int howMany) throws TasteException;
 
   /**
-   * @see org.apache.mahout.cf.taste.recommender.Recommender#recommend(Object, int, Rescorer)
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#recommend(Comparable, int, Rescorer)
    */
-  List<Item> recommend(Object userID, int howMany, Rescorer<Item> rescorer) throws TasteException;
+  List<Comparable<?>> recommend(Object userID, int howMany, Rescorer<Comparable<?>> rescorer) throws TasteException;
 
   /**
-   * @see org.apache.mahout.cf.taste.recommender.Recommender#estimatePreference(Object, Object)
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#estimatePreference(Comparable, Comparable)
    */
   double estimatePreference(Object userID, Object itemID) throws TasteException;
 
   /**
-   * @see org.apache.mahout.cf.taste.recommender.Recommender#setPreference(Object, Object, double)
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#setPreference(Comparable, Comparable, double)
    */
   void setPreference(Object userID, Object itemID, double value) throws TasteException;
 
   /**
-   * @see org.apache.mahout.cf.taste.recommender.Recommender#removePreference(Object, Object)
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#removePreference(Comparable, Comparable)
    */
   void removePreference(Object userID, Object itemID) throws TasteException;
 

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingDataModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingDataModel.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingDataModel.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingDataModel.java Fri Jul 24 14:32:05 2009
@@ -21,7 +21,6 @@
 import org.apache.mahout.cf.taste.impl.common.FileLineIterable;
 import org.apache.mahout.cf.taste.impl.common.IOUtils;
 import org.apache.mahout.cf.taste.impl.model.file.FileDataModel;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.User;
 import org.apache.mahout.cf.taste.model.Preference;
 import org.apache.mahout.cf.taste.example.grouplens.GroupLensDataModel;
@@ -38,41 +37,28 @@
 
 public final class BookCrossingDataModel extends FileDataModel {
 
-  private Map<String, Book> bookMap;
   private Map<String, String[]> userDataMap;
-  private final File booksFile;
   private final File usersFile;
 
   public BookCrossingDataModel() throws IOException {
     this(GroupLensDataModel.readResourceToTempFile("/org/apache/mahout/cf/taste/example/bookcrossing/BX-Book-Ratings.csv"),
-         GroupLensDataModel.readResourceToTempFile("/org/apache/mahout/cf/taste/example/bookcrossing/BX-Books.csv"),
          GroupLensDataModel.readResourceToTempFile("/org/apache/mahout/cf/taste/example/bookcrossing/BX-Users.csv"));
   }
 
   /**
    * @param ratingsFile BookCrossing ratings file in its native format
-   * @param booksFile BookCrossing books file in its native format
    * @param usersFile BookCrossing books file in its native format
    * @throws IOException if an error occurs while reading or writing files
    */
-  public BookCrossingDataModel(File ratingsFile, File booksFile, File usersFile) throws IOException {
+  public BookCrossingDataModel(File ratingsFile, File usersFile) throws IOException {
     super(convertBCFile(ratingsFile));
-    this.booksFile = booksFile;
     this.usersFile = usersFile;
   }
 
   @Override
   protected void reload() {
-    bookMap = new FastMap<String, Book>(5001);
     userDataMap = new FastMap<String, String[]>(5001);
 
-    for (String line : new FileLineIterable(booksFile, true)) {
-      String[] tokens = tokenizeLine(line, 5);
-      if (tokens != null) {
-        String id = tokens[0];
-        bookMap.put(id, new Book(id, tokens[1], tokens[2], Integer.parseInt(tokens[3]), tokens[4]));
-      }
-    }
     for (String line : new FileLineIterable(usersFile, true)) {
       String[] tokens = tokenizeLine(line, 3);
       if (tokens != null) {
@@ -80,9 +66,7 @@
         userDataMap.put(id, new String[] { tokens[1], tokens[2] });
       }
     }
-
     super.reload();
-    bookMap = null;
     userDataMap = null;
   }
 
@@ -161,16 +145,6 @@
     return new BookCrossingUser(id, prefs, city, state, country, age);
   }
 
-  @Override
-  protected Item buildItem(String id) {
-    Item item = bookMap.get(id);
-    if (item == null) {
-      // some books aren't in books file?
-      return new Book(id, null, null, 0, null);
-    }
-    return item;
-  }
-
   private static File convertBCFile(File originalFile) throws IOException {
     File resultFile = new File(new File(System.getProperty("java.io.tmpdir")), "taste.bookcrossing.txt");
     if (!resultFile.exists()) {

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommender.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommender.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommender.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingRecommender.java Fri Jul 24 14:32:05 2009
@@ -23,7 +23,6 @@
 import org.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender;
 import org.apache.mahout.cf.taste.impl.neighborhood.NearestNUserNeighborhood;
 import org.apache.mahout.cf.taste.model.DataModel;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.recommender.RecommendedItem;
 import org.apache.mahout.cf.taste.recommender.Recommender;
 import org.apache.mahout.cf.taste.recommender.Rescorer;
@@ -48,28 +47,28 @@
   }
 
   @Override
-  public List<RecommendedItem> recommend(Object userID, int howMany) throws TasteException {
+  public List<RecommendedItem> recommend(Comparable<?> userID, int howMany) throws TasteException {
     return recommender.recommend(userID, howMany);
   }
 
   @Override
-  public List<RecommendedItem> recommend(Object userID, int howMany, Rescorer<Item> rescorer)
+  public List<RecommendedItem> recommend(Comparable<?> userID, int howMany, Rescorer<Comparable<?>> rescorer)
           throws TasteException {
     return recommender.recommend(userID, howMany, rescorer);
   }
 
   @Override
-  public double estimatePreference(Object userID, Object itemID) throws TasteException {
+  public double estimatePreference(Comparable<?> userID, Comparable<?> itemID) throws TasteException {
     return recommender.estimatePreference(userID, itemID);
   }
 
   @Override
-  public void setPreference(Object userID, Object itemID, double value) throws TasteException {
+  public void setPreference(Comparable<?> userID, Comparable<?> itemID, double value) throws TasteException {
     recommender.setPreference(userID, itemID, value);
   }
 
   @Override
-  public void removePreference(Object userID, Object itemID) throws TasteException {
+  public void removePreference(Comparable<?> userID, Comparable<?> itemID) throws TasteException {
     recommender.removePreference(userID, itemID);
   }
 

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingUser.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingUser.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingUser.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/bookcrossing/BookCrossingUser.java Fri Jul 24 14:32:05 2009
@@ -22,7 +22,7 @@
 
 import java.util.List;
 
-final class BookCrossingUser extends GenericUser<String> {
+final class BookCrossingUser extends GenericUser {
 
   private final String city;
   private final String state;

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=797487&r1=797486&r2=797487&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 Fri Jul 24 14:32:05 2009
@@ -17,11 +17,9 @@
 
 package org.apache.mahout.cf.taste.example.grouplens;
 
-import org.apache.mahout.cf.taste.impl.common.FastMap;
 import org.apache.mahout.cf.taste.impl.common.FileLineIterable;
 import org.apache.mahout.cf.taste.impl.common.IOUtils;
 import org.apache.mahout.cf.taste.impl.model.file.FileDataModel;
-import org.apache.mahout.cf.taste.model.Item;
 
 import java.io.File;
 import java.io.FileOutputStream;
@@ -30,61 +28,25 @@
 import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.io.OutputStreamWriter;
-import java.util.Map;
-import java.util.NoSuchElementException;
 import java.nio.charset.Charset;
 
 public final class GroupLensDataModel extends FileDataModel {
 
-  private Map<String, Movie> movieMap;
-  private final File moviesFile;
-
   public GroupLensDataModel() throws IOException {
-    this(readResourceToTempFile("/org/apache/mahout/cf/taste/example/grouplens/ratings.dat"),
-         readResourceToTempFile("/org/apache/mahout/cf/taste/example/grouplens/movies.dat"));
+    this(readResourceToTempFile("/org/apache/mahout/cf/taste/example/grouplens/ratings.dat"));
   }
 
   /**
    * @param ratingsFile GroupLens ratings.dat file in its native format
-   * @param moviesFile GroupLens movies.dat file in its native format
    * @throws IOException if an error occurs while reading or writing files
    */
-  public GroupLensDataModel(File ratingsFile, File moviesFile) throws IOException {
-    super(convertGLFile(ratingsFile, true));
-    this.moviesFile = moviesFile;
+  public GroupLensDataModel(File ratingsFile) throws IOException {
+    super(convertGLFile(ratingsFile));
   }
 
-  @Override
-  protected Item buildItem(String id) {
-    Item item = movieMap.get(id);
-    if (item == null) {
-      throw new NoSuchElementException();
-    }
-    return item;
-  }
-
-  @Override
-  protected void reload() {
-    File convertedMoviesFile;
-    try {
-      convertedMoviesFile = convertGLFile(moviesFile, false);
-    } catch (IOException ioe) {
-      throw new RuntimeException(ioe); // better way?
-    }
-    movieMap = new FastMap<String, Movie>(5001);
-    for (String line : new FileLineIterable(convertedMoviesFile, false)) {
-      String[] tokens = line.split(",");
-      String id = tokens[0];
-      movieMap.put(id, new Movie(id, tokens[1], tokens[2]));
-    }
-    super.reload();
-    movieMap = null;
-  }
-
-  private static File convertGLFile(File originalFile, boolean ratings) throws IOException {
+  private static File convertGLFile(File originalFile) throws IOException {
     // 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");
+    File resultFile = new File(new File(System.getProperty("java.io.tmpdir")), "ratings.txt");
     if (resultFile.exists()) {
       resultFile.delete();
     }
@@ -92,13 +54,7 @@
     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("::", ",");
-        }
+        String convertedLine = line.substring(0, line.lastIndexOf("::")).replace("::", ",");
         writer.println(convertedLine);
       }
       writer.flush();

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommender.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommender.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommender.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommender.java Fri Jul 24 14:32:05 2009
@@ -22,7 +22,6 @@
 import org.apache.mahout.cf.taste.impl.recommender.CachingRecommender;
 import org.apache.mahout.cf.taste.impl.recommender.slopeone.SlopeOneRecommender;
 import org.apache.mahout.cf.taste.model.DataModel;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.recommender.RecommendedItem;
 import org.apache.mahout.cf.taste.recommender.Recommender;
 import org.apache.mahout.cf.taste.recommender.Rescorer;
@@ -58,28 +57,28 @@
   }
 
   @Override
-  public List<RecommendedItem> recommend(Object userID, int howMany) throws TasteException {
+  public List<RecommendedItem> recommend(Comparable<?> userID, int howMany) throws TasteException {
     return recommender.recommend(userID, howMany);
   }
 
   @Override
-  public List<RecommendedItem> recommend(Object userID, int howMany, Rescorer<Item> rescorer)
+  public List<RecommendedItem> recommend(Comparable<?> userID, int howMany, Rescorer<Comparable<?>> rescorer)
           throws TasteException {
     return recommender.recommend(userID, howMany, rescorer);
   }
 
   @Override
-  public double estimatePreference(Object userID, Object itemID) throws TasteException {
+  public double estimatePreference(Comparable<?> userID, Comparable<?> itemID) throws TasteException {
     return recommender.estimatePreference(userID, itemID);
   }
 
   @Override
-  public void setPreference(Object userID, Object itemID, double value) throws TasteException {
+  public void setPreference(Comparable<?> userID, Comparable<?> itemID, double value) throws TasteException {
     recommender.setPreference(userID, itemID, value);
   }
 
   @Override
-  public void removePreference(Object userID, Object itemID) throws TasteException {
+  public void removePreference(Comparable<?> userID, Comparable<?> itemID) throws TasteException {
     recommender.removePreference(userID, itemID);
   }
 

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterDataModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterDataModel.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterDataModel.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterDataModel.java Fri Jul 24 14:32:05 2009
@@ -21,7 +21,6 @@
 import org.apache.mahout.cf.taste.impl.model.file.FileDataModel;
 import org.apache.mahout.cf.taste.impl.model.GenericPreference;
 import org.apache.mahout.cf.taste.model.Preference;
-import org.apache.mahout.cf.taste.model.Item;
 
 import java.io.File;
 import java.io.IOException;
@@ -52,7 +51,7 @@
   }
 
   @Override
-  protected void processLine(String line, Map<String, List<Preference>> data, Map<String, Item> itemCache) {
+  protected void processLine(String line, Map<String, List<Preference>> data) {
     String userID = String.valueOf(userBeingRead);
     String[] jokePrefs = line.split(",");
     List<Preference> prefs = new ArrayList<Preference>(101);
@@ -61,12 +60,7 @@
       if (!"99".equals(jokePref)) {
         double jokePrefValue = Double.parseDouble(jokePref);        
         String itemID = String.valueOf(itemIDNum);
-        Item item = itemCache.get(itemID);
-        if (item == null) {
-          item = buildItem(itemID);
-          itemCache.put(itemID, item);
-        }
-        prefs.add(new GenericPreference(null, item, jokePrefValue));
+        prefs.add(new GenericPreference(null, itemID, jokePrefValue));
       }
     }
     data.put(userID, prefs);

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterRecommender.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterRecommender.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterRecommender.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/jester/JesterRecommender.java Fri Jul 24 14:32:05 2009
@@ -22,7 +22,6 @@
 import org.apache.mahout.cf.taste.impl.recommender.CachingRecommender;
 import org.apache.mahout.cf.taste.impl.recommender.slopeone.SlopeOneRecommender;
 import org.apache.mahout.cf.taste.model.DataModel;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.recommender.RecommendedItem;
 import org.apache.mahout.cf.taste.recommender.Recommender;
 import org.apache.mahout.cf.taste.recommender.Rescorer;
@@ -43,28 +42,28 @@
   }
 
   @Override
-  public List<RecommendedItem> recommend(Object userID, int howMany) throws TasteException {
+  public List<RecommendedItem> recommend(Comparable<?> userID, int howMany) throws TasteException {
     return recommender.recommend(userID, howMany);
   }
 
   @Override
-  public List<RecommendedItem> recommend(Object userID, int howMany, Rescorer<Item> rescorer)
+  public List<RecommendedItem> recommend(Comparable<?> userID, int howMany, Rescorer<Comparable<?>> rescorer)
           throws TasteException {
     return recommender.recommend(userID, howMany, rescorer);
   }
 
   @Override
-  public double estimatePreference(Object userID, Object itemID) throws TasteException {
+  public double estimatePreference(Comparable<?> userID, Comparable<?> itemID) throws TasteException {
     return recommender.estimatePreference(userID, itemID);
   }
 
   @Override
-  public void setPreference(Object userID, Object itemID, double value) throws TasteException {
+  public void setPreference(Comparable<?> userID, Comparable<?> itemID, double value) throws TasteException {
     recommender.setPreference(userID, itemID, value);
   }
 
   @Override
-  public void removePreference(Object userID, Object itemID) throws TasteException {
+  public void removePreference(Comparable<?> userID, Comparable<?> itemID) throws TasteException {
     recommender.removePreference(userID, itemID);
   }
 

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixDataModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixDataModel.java?rev=797487&r1=797486&r2=797487&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixDataModel.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/netflix/NetflixDataModel.java Fri Jul 24 14:32:05 2009
@@ -25,7 +25,6 @@
 import org.apache.mahout.cf.taste.impl.common.FastMap;
 import org.apache.mahout.cf.taste.impl.common.FileLineIterable;
 import org.apache.mahout.cf.taste.model.DataModel;
-import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.Preference;
 import org.apache.mahout.cf.taste.model.User;
 import org.slf4j.LoggerFactory;
@@ -57,6 +56,7 @@
    * @param dataDirectory root directory of Netflix data set, unpacked
    * @param useSubset if true, will use only a small fraction of the data -- may be useful
    *  for quick experiments
+   * @throws IOException
    */
 	public NetflixDataModel(File dataDirectory, boolean useSubset) throws IOException {
 		if (dataDirectory == null) {
@@ -70,17 +70,27 @@
 
 		log.info("Creating NetflixDataModel for directory: {}", dataDirectory);
 
-		log.info("Reading movie data...");
-		List<NetflixMovie> movies = NetflixMovie.readMovies(dataDirectory);
-
 		log.info("Reading preference data...");
-		List<User> users = readUsers(dataDirectory, movies);
+		List<User> users = readUsers(dataDirectory);
 
 		log.info("Creating delegate DataModel...");
 		delegate = new GenericDataModel(users);
 	}
 
-	private List<User> readUsers(File dataDirectory, List<NetflixMovie> movies) throws IOException {
+  static List<Comparable<?>> readMovies(File dataDirectory) {
+		List<Comparable<?>> movies = new ArrayList<Comparable<?>>(17770);
+    for (String line : new FileLineIterable(new File(dataDirectory, "movie_titles.txt"), false)) {
+			int firstComma = line.indexOf((int) ',');
+			Integer id = Integer.valueOf(line.substring(0, firstComma));
+			movies.add(id);
+      if (id != movies.size()) {
+        throw new IllegalStateException("A movie is missing from movie_titles.txt");
+      }
+		}
+		return movies;
+	}
+
+	private List<User> readUsers(File dataDirectory) throws IOException {
 		Map<Integer, List<Preference>> userIDPrefMap = new FastMap<Integer, List<Preference>>();
 
 		int counter = 0;
@@ -88,11 +98,7 @@
 		for (File movieFile : new File(dataDirectory, "training_set").listFiles(filenameFilter)) {
       Iterator<String> lineIterator = new FileLineIterable(movieFile, false).iterator();
 			String line = lineIterator.next();
-			int movieID = Integer.parseInt(line.substring(0, line.length() - 1)); // strip colon
-			NetflixMovie movie = movies.get(movieID - 1);
-			if (movie == null) {
-				throw new IllegalArgumentException("No such movie: " + movieID);
-			}
+			Integer movieID = Integer.valueOf(line.substring(0, line.length() - 1)); // strip colon
 			while (lineIterator.hasNext()) {
         line = lineIterator.next();
 				counter++;
@@ -108,13 +114,13 @@
 					userPrefs = new ArrayList<Preference>();
 					userIDPrefMap.put(userID, userPrefs);
 				}
-				userPrefs.add(new GenericPreference(null, movie, rating));
+				userPrefs.add(new GenericPreference(null, movieID, rating));
 			}
 		}
 
 		List<User> users = new ArrayList<User>(userIDPrefMap.size());
 		for (Map.Entry<Integer, List<Preference>> entry : userIDPrefMap.entrySet()) {
-			users.add(new GenericUser<Integer>(entry.getKey(), entry.getValue()));
+			users.add(new GenericUser(entry.getKey(), entry.getValue()));
 		}
 		return users;
 	}
@@ -125,27 +131,22 @@
 	}
 
 	@Override
-  public User getUser(Object id) throws TasteException {
+  public User getUser(Comparable<?> id) throws TasteException {
 		return delegate.getUser(id);
 	}
 
 	@Override
-  public Iterable<? extends Item> getItems() throws TasteException {
-		return delegate.getItems();
-	}
-
-	@Override
-  public Item getItem(Object id) throws TasteException {
-		return delegate.getItem(id);
+  public Iterable<Comparable<?>> getItemIDs() throws TasteException {
+		return delegate.getItemIDs();
 	}
 
 	@Override
-  public Iterable<? extends Preference> getPreferencesForItem(Object itemID) throws TasteException {
+  public Iterable<? extends Preference> getPreferencesForItem(Comparable<?> itemID) throws TasteException {
 		return delegate.getPreferencesForItem(itemID);
 	}
 
 	@Override
-  public Preference[] getPreferencesForItemAsArray(Object itemID) throws TasteException {
+  public Preference[] getPreferencesForItemAsArray(Comparable<?> itemID) throws TasteException {
 		return delegate.getPreferencesForItemAsArray(itemID);
 	}
 
@@ -160,17 +161,17 @@
 	}
 
   @Override
-  public int getNumUsersWithPreferenceFor(Object... itemIDs) throws TasteException {
+  public int getNumUsersWithPreferenceFor(Comparable<?>... itemIDs) throws TasteException {
     return delegate.getNumUsersWithPreferenceFor(itemIDs);
   }
 
   @Override
-  public void setPreference(Object userID, Object itemID, double value) {
+  public void setPreference(Comparable<?> userID, Comparable<?> itemID, double value) {
 		throw new UnsupportedOperationException();
 	}
 
 	@Override
-  public void removePreference(Object userID, Object itemID) {
+  public void removePreference(Comparable<?> userID, Comparable<?> itemID) {
 		throw new UnsupportedOperationException();
 	}
 



Mime
View raw message