Skip to content

Instantly share code, notes, and snippets.

@RedBeard0531
Created November 25, 2009 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RedBeard0531/243047 to your computer and use it in GitHub Desktop.
Save RedBeard0531/243047 to your computer and use it in GitHub Desktop.
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