@Override
 public final void setPreferenceInferrer(PreferenceInferrer inferrer) {
   if (inferrer == null) {
     throw new IllegalArgumentException("inferrer is null");
   }
   refreshHelper.addDependency(inferrer);
   refreshHelper.removeDependency(this.inferrer);
   this.inferrer = inferrer;
 }
 @Override
 public void refresh(Collection<Refreshable> alreadyRefreshed) {
   alreadyRefreshed = RefreshHelper.buildRefreshed(alreadyRefreshed);
   RefreshHelper.maybeRefresh(alreadyRefreshed, getDataModel());
   try {
     refreshUserAndItemPrefNum();
   } catch (TasteException e) {
     e.printStackTrace();
   }
 }
 public ItemUserAverageRecommender(DataModel dataModel) throws TasteException {
   super(dataModel);
   this.itemAverages = new FastByIDMap<RunningAverage>();
   this.userAverages = new FastByIDMap<RunningAverage>();
   this.overallAveragePrefValue = new FullRunningAverage();
   this.buildAveragesLock = new ReentrantReadWriteLock();
   this.refreshHelper =
       new RefreshHelper(
           new Callable<Object>() {
             @Override
             public Object call() throws TasteException {
               buildAverageDiffs();
               return null;
             }
           });
   refreshHelper.addDependency(dataModel);
   buildAverageDiffs();
 }
Exemplo n.º 4
0
 public CachingRecommender(Recommender recommender) throws TasteException {
   Preconditions.checkArgument(recommender != null, "recommender is null");
   this.recommender = recommender;
   maxHowMany = new int[] {1};
   // Use "num users" as an upper limit on cache size. Rough guess.
   int numUsers = recommender.getDataModel().getNumUsers();
   recommendationsRetriever = new RecommendationRetriever();
   recommendationCache = new Cache<>(recommendationsRetriever, numUsers);
   estimatedPrefCache = new Cache<>(new EstimatedPrefRetriever(), numUsers);
   refreshHelper =
       new RefreshHelper(
           new Callable<Object>() {
             @Override
             public Object call() {
               clear();
               return null;
             }
           });
   refreshHelper.addDependency(recommender);
 }
 @Override
 public void refresh(Collection<Refreshable> alreadyRefreshed) {
   alreadyRefreshed = RefreshHelper.buildRefreshed(alreadyRefreshed);
   RefreshHelper.maybeRefresh(alreadyRefreshed, dataModel);
 }
 @Override
 public void refresh(Collection<Refreshable> alreadyRefreshed) {
   refreshHelper.refresh(alreadyRefreshed);
 }
Exemplo n.º 7
0
 @Override
 public void refresh(Collection<Refreshable> alreadyRefreshed) {
   neighborhoodCache.clear();
   alreadyRefreshed = RefreshHelper.buildRefreshed(alreadyRefreshed);
   RefreshHelper.maybeRefresh(alreadyRefreshed, neighborhood);
 }
 public final void setPrefTransform(PreferenceTransform prefTransform) {
   refreshHelper.addDependency(prefTransform);
   refreshHelper.removeDependency(this.prefTransform);
   this.prefTransform = prefTransform;
 }
 public final void setSimilarityTransform(SimilarityTransform similarityTransform) {
   refreshHelper.addDependency(similarityTransform);
   refreshHelper.removeDependency(this.similarityTransform);
   this.similarityTransform = similarityTransform;
 }