Created
November 25, 2009 21:34
-
-
Save RedBeard0531/243047 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function( key , values ){ | |
var confidence_threshold = 0.0 | |
var total = 0 | |
var sc = 0.0 | |
var cats = [] | |
var links = [] | |
for ( var i=0; i<values.length; i++ ) { | |
total += values[i].count | |
sc += (values[i].score || 0) | |
links.push({hash:values[i].hash,title:values[i].title, | |
score:values[i].score}) | |
for (var j=0; j<values[i].categories.length; j++) { | |
var cat = values[i].categories[j] | |
if (cats.indexOf(cat) < 0) { | |
cats.push(cat) | |
} | |
} | |
} | |
return {count: total, categories: cats, score: sc/values.length, | |
destinationUrl : null, | |
originalImage : null, | |
mediumThumbnail : null, | |
smallThumbnail : null, | |
products: links.sort(function(a,b){ | |
if (a.score > b.score) | |
return 1 | |
else if (a.score < b.score) | |
return -1 | |
return 0 | |
})} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment