diff --git a/README.md b/README.md index 4aecce1..cf74490 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ raccoon.recommendFor('chrisId', 10, function(results){ raccoon.config.nearestNeighbors = 5; // number of neighbors you want to compare a user against raccoon.config.className = 'movie'; // prefix for your items (used for redis) raccoon.config.numOfRecsStore = 30; // number of recommendations to store per user +raccoon.config.updateRatingOnInput = true; // update recommendations on each input raccoon.config.factorLeastSimilarLeastLiked = false; // if you want to factor in items that // users least similar didn't like diff --git a/lib/config.js b/lib/config.js index c86cce7..b2c754c 100644 --- a/lib/config.js +++ b/lib/config.js @@ -4,6 +4,7 @@ function Config (){ this.className = 'movie'; this.numOfRecsStore = 30; this.factorLeastSimilarLeastLiked = false; + this.updateRatingOnInput = true; } module.exports = exports = new Config(); diff --git a/lib/input.js b/lib/input.js index ccaddb5..c9ed226 100644 --- a/lib/input.js +++ b/lib/input.js @@ -12,9 +12,13 @@ var updateSequence = function(userId, itemId, callback){ }); }, function(cb){ - algo.updateRecommendationsFor(userId, function(){ + if (config.updateRatingOnInput) { + algo.updateRecommendationsFor(userId, function(){ + cb(null); + }); + } else { cb(null); - }); + }; } ], function(err){ diff --git a/lib/raccoon.js b/lib/raccoon.js index 0246df3..37061e4 100644 --- a/lib/raccoon.js +++ b/lib/raccoon.js @@ -34,6 +34,7 @@ Raccoon.prototype.config = config; Raccoon.prototype.stat = stat; Raccoon.prototype.liked = input.liked; Raccoon.prototype.disliked = input.disliked; +Raccoon.prototype.updateRecommendationsFor = algo.updateRecommendationsFor; Raccoon.prototype.recommendFor = stat.recommendFor; Raccoon.prototype.bestRated = stat.bestRated; Raccoon.prototype.worstRated = stat.worstRated; diff --git a/package.json b/package.json index fe4e223..39292ec 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "raccoon", "author": "Guy Morita", "description": "A Collaborative Filtering Recommendation Engine for Node.js utilizing Redis", - "version": "0.2.3", + "version": "0.2.4", "repository": { "type": "git", "url": "https://github.com/guymorita/recommendationRaccoon.git"