Fixing rating system
This commit is contained in:
parent
d9e37574d5
commit
f6d222b7ec
@ -28,12 +28,17 @@ function scale(values, factor) {
|
|||||||
function countData(searchParams, minScore) {
|
function countData(searchParams, minScore) {
|
||||||
var dataCount = 0;
|
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) {
|
for (var keyword in searchParams) {
|
||||||
var features = scale(db_keywords[keyword], searchParams[keyword]);
|
var features = scale(db_keywords[keyword], searchParams[keyword]);
|
||||||
for (var i = 0, count = db_data.length; i < count; ++i) {
|
score += innerProduct(features, record.rating);
|
||||||
if (innerProduct(features, db_data[i].rating) >= minScore) {
|
|
||||||
++dataCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (score >= minScore) {
|
||||||
|
++dataCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,11 +48,15 @@ function countData(searchParams, minScore) {
|
|||||||
function findData(searchParams, minScore, maxResults) {
|
function findData(searchParams, minScore, maxResults) {
|
||||||
var results = [];
|
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) {
|
for (var i = 0, count = db_data.length; i < count; ++i) {
|
||||||
var record = db_data[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) {
|
if (score >= minScore) {
|
||||||
results.push({
|
results.push({
|
||||||
@ -57,7 +66,6 @@ function findData(searchParams, minScore, maxResults) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
results.sort(function(a, b) {
|
results.sort(function(a, b) {
|
||||||
return b.score - a.score;
|
return b.score - a.score;
|
||||||
|
Loading…
Reference in New Issue
Block a user