com.planetj.taste.impl.recommender
Class AbstractRecommender

java.lang.Object
  extended by com.planetj.taste.impl.recommender.AbstractRecommender
All Implemented Interfaces:
Refreshable, Recommender
Direct Known Subclasses:
GenericItemBasedRecommender, GenericUserBasedRecommender, ItemAverageRecommender, ItemUserAverageRecommender, SlopeOneRecommender, TreeClusteringRecommender, TreeClusteringRecommender2

public abstract class AbstractRecommender
extends java.lang.Object
implements Recommender

Author:
Sean Owen

Constructor Summary
protected AbstractRecommender(DataModel dataModel)
           
 
Method Summary
protected  java.util.Set<Item> getAllOtherItems(User theUser)
           
 DataModel getDataModel()
          
 java.util.List<RecommendedItem> recommend(java.lang.Object userID, int howMany)
          Default implementation which just calls Recommender.recommend(Object, int,com.planetj.taste.recommender.Rescorer), with a Rescorer that does nothing.
 void refresh()
          

Triggers "refresh" -- whatever that means -- of the implementation.

 void removePreference(java.lang.Object userID, java.lang.Object itemID)
          Default implementation which just calls DataModel.removePreference(Object, Object) (Object, Object)}.
 void setPreference(java.lang.Object userID, java.lang.Object itemID, double value)
          Default implementation which just calls DataModel.setPreference(Object, Object, double).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.planetj.taste.recommender.Recommender
estimatePreference, recommend
 

Constructor Detail

AbstractRecommender

protected AbstractRecommender(DataModel dataModel)
Method Detail

recommend

@NotNull
public java.util.List<RecommendedItem> recommend(java.lang.Object userID,
                                                         int howMany)
                                          throws TasteException

Default implementation which just calls Recommender.recommend(Object, int,com.planetj.taste.recommender.Rescorer), with a Rescorer that does nothing.

Specified by:
recommend in interface Recommender
Parameters:
userID - user for which recommendations are to be computed
howMany - desired number of recommendations
Returns:
List of recommended RecommendedItems, ordered from most strongly recommend to least
Throws:
TasteException - if an error occurs while accessing the DataModel

setPreference

public void setPreference(java.lang.Object userID,
                          java.lang.Object itemID,
                          double value)
                   throws TasteException

Default implementation which just calls DataModel.setPreference(Object, Object, double).

Specified by:
setPreference in interface Recommender
Parameters:
userID - user to set preference for
itemID - item to set preference for
value - preference value
Throws:
java.lang.IllegalArgumentException - if userID or itemID is null, or if value is Double.NaN
TasteException - if an error occurs while accessing the DataModel

removePreference

public void removePreference(java.lang.Object userID,
                             java.lang.Object itemID)
                      throws TasteException

Default implementation which just calls DataModel.removePreference(Object, Object) (Object, Object)}.

Specified by:
removePreference in interface Recommender
Parameters:
userID - user from which to remove preference
itemID - item for which to remove preference
Throws:
java.lang.IllegalArgumentException - if userID or itemID is null
TasteException - if an error occurs while accessing the DataModel

getDataModel

@NotNull
public DataModel getDataModel()

Specified by:
getDataModel in interface Recommender
Returns:
DataModel used by this Recommender

refresh

public void refresh()

Triggers "refresh" -- whatever that means -- of the implementation. The general contract is that any Refreshable should always leave itself in a consistent, operational state, and that the refresh atomically updates internal state from old to new.

Specified by:
refresh in interface Refreshable

getAllOtherItems

@NotNull
protected java.util.Set<Item> getAllOtherItems(User theUser)
                                        throws TasteException
Parameters:
theUser - User being evaluated
Returns:
all Items in the DataModel for which the User has not expressed a preference
Throws:
TasteException - if an error occurs while listing Items