1

Fixing rating system

This commit is contained in:
Alex Yatskov 2014-09-14 19:40:46 +09:00
parent d9e37574d5
commit f6d222b7ec

View File

@ -28,12 +28,17 @@ function scale(values, factor) {
function countData(searchParams, minScore) {
var dataCount = 0;
for (var i = 0, count = db_data.length; i < count; ++i) {
var record = db_data[i];
var score = 0.0;
for (var keyword in searchParams) {
var features = scale(db_keywords[keyword], searchParams[keyword]);
for (var i = 0, count = db_data.length; i < count; ++i) {
if (innerProduct(features, db_data[i].rating) >= minScore) {
++dataCount;
score += innerProduct(features, record.rating);
}
if (score >= minScore) {
++dataCount;
}
}
@ -43,11 +48,15 @@ function countData(searchParams, minScore) {
function findData(searchParams, minScore, maxResults) {
var results = [];
for (var keyword in searchParams) {
var features = scale(db_keywords[keyword], searchParams[keyword]);
for (var i = 0, count = db_data.length; i < count; ++i) {
var record = db_data[i];
var score = innerProduct(features, record.rating);
var score = 0.0;
for (var keyword in searchParams) {
var features = scale(db_keywords[keyword], searchParams[keyword]);
score += innerProduct(features, record.rating);
}
if (score >= minScore) {
results.push({
@ -57,7 +66,6 @@ function findData(searchParams, minScore, maxResults) {
});
}
}
}
results.sort(function(a, b) {
return b.score - a.score;