org.apache.mahout.cf.taste.web
Class RecommenderWrapper
java.lang.Object
org.apache.mahout.cf.taste.web.RecommenderWrapper
- All Implemented Interfaces:
- Refreshable, Recommender
public abstract class RecommenderWrapper
- extends Object
- implements Recommender
Users of the packaging and deployment mechanism in this module need
to produce a Recommender
implementation with a no-arg constructor,
which will internally build the desired Recommender
and delegate
to it. This wrapper simplifies that process. Simply extend this class and
implement buildRecommender()
.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RecommenderWrapper
protected RecommenderWrapper()
throws TasteException,
IOException
- Throws:
TasteException
IOException
buildRecommender
protected abstract Recommender buildRecommender()
throws IOException,
TasteException
- Returns:
- the
Recommender
which should be used to produce recommendations
by this wrapper implementation
- Throws:
IOException
TasteException
recommend
public List<RecommendedItem> recommend(long userID,
int howMany)
throws TasteException
- Specified by:
recommend
in interface Recommender
- Throws:
TasteException
recommend
public List<RecommendedItem> recommend(long userID,
int howMany,
IDRescorer rescorer)
throws TasteException
- Specified by:
recommend
in interface Recommender
- Throws:
TasteException
estimatePreference
public float estimatePreference(long userID,
long itemID)
throws TasteException
- Specified by:
estimatePreference
in interface Recommender
- Throws:
TasteException
setPreference
public void setPreference(long userID,
long itemID,
float value)
throws TasteException
- Specified by:
setPreference
in interface Recommender
- Throws:
TasteException
removePreference
public void removePreference(long userID,
long itemID)
throws TasteException
- Specified by:
removePreference
in interface Recommender
- Throws:
TasteException
getDataModel
public DataModel getDataModel()
- Specified by:
getDataModel
in interface Recommender
refresh
public void refresh(Collection<Refreshable> alreadyRefreshed)
- Specified by:
refresh
in interface Refreshable
readResourceToTempFile
public static File readResourceToTempFile(String resourceName)
throws IOException
- Reads the given resource into a temporary file. This is intended to be used
to read data files which are stored as a resource available on the classpath,
such as in a JAR file. However for convenience the resource name will also
be interpreted as a relative path to a local file, if no such resource is
found. This facilitates testing.
- Parameters:
resourceName
- name of resource in classpath, or relative path to file
- Returns:
- temporary
File
with resource data
- Throws:
IOException
- if an error occurs while reading or writing data
Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.