I have an application where users can:
- Write reviews about products
- Add comments to products
- Up / Down vote reviews
- Up / Down vote comments
Every Up/Down vote is recorded in a db table.
What i want to do now is to create a ranking of the most active users in the last 4 weeks. Of course good reviews should be weighted more than good comments. But also e.g. 10 good comments should be weighted more than just one good review.
Example:
// reviews created in recent 4 weeks
//format: [ upVoteCount, downVoteCount ]
var reviews = [ [120,23], [32,12], [12,0], [23,45] ];
// comments created in recent 4 weeks
// format: [ upVoteCount, downVoteCount ]
var comme开发者_高级运维nts = [ [1,2], [322,1], [0,0], [0,45] ];
// create weight vector
// format: [ reviewWeight, commentsWeight ]
var weight = [0.60, 0.40];
// signature: activties..., activityWeight
var userActivityScore = score(reviews, comments, weight);
... update user table ...
List<Users> users = "from users u order by u.userActivityScore desc";
How would a fair scoring function look like?
How could an implementation of the score()
function look like? How to add a weight g
to the function so that reviews are weighted heavier? How would such a function look like if, for example, votes for pictures would be added?
These kinds of algorithms can be quite complex. You might want to take a look into these books:
- Collective Intelligence in Action, Satnam Alag, Manning, 2008, ISBN 1933988312
- Algorithms of the Intelligent Web, Haralambos Marmanis, Manning 2009, ISBN 1933988665
- Programming Collective Intelligence: Building Smart Web 2.0 Applications, Toby Segaran, O'Reilly Media 2007, ISBN 0596529325
精彩评论