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 keyword in searchParams) {
|
for (var i = 0, count = db_data.length; i < count; ++i) {
|
||||||
var features = scale(db_keywords[keyword], searchParams[keyword]);
|
var record = db_data[i];
|
||||||
for (var i = 0, count = db_data.length; i < count; ++i) {
|
var score = 0.0;
|
||||||
if (innerProduct(features, db_data[i].rating) >= minScore) {
|
|
||||||
++dataCount;
|
for (var keyword in searchParams) {
|
||||||
}
|
var features = scale(db_keywords[keyword], searchParams[keyword]);
|
||||||
|
score += innerProduct(features, record.rating);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (score >= minScore) {
|
||||||
|
++dataCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,19 +48,22 @@ function countData(searchParams, minScore) {
|
|||||||
function findData(searchParams, minScore, maxResults) {
|
function findData(searchParams, minScore, maxResults) {
|
||||||
var results = [];
|
var results = [];
|
||||||
|
|
||||||
for (var keyword in searchParams) {
|
for (var i = 0, count = db_data.length; i < count; ++i) {
|
||||||
var features = scale(db_keywords[keyword], searchParams[keyword]);
|
var record = db_data[i];
|
||||||
for (var i = 0, count = db_data.length; i < count; ++i) {
|
var score = 0.0;
|
||||||
var record = db_data[i];
|
|
||||||
var score = innerProduct(features, record.rating);
|
|
||||||
|
|
||||||
if (score >= minScore) {
|
for (var keyword in searchParams) {
|
||||||
results.push({
|
var features = scale(db_keywords[keyword], searchParams[keyword]);
|
||||||
name: record.name,
|
score += innerProduct(features, record.rating);
|
||||||
url: 'http://www.tripadvisor.com' + record.relativeUrl,
|
|
||||||
score: score
|
}
|
||||||
});
|
|
||||||
}
|
if (score >= minScore) {
|
||||||
|
results.push({
|
||||||
|
name: record.name,
|
||||||
|
url: 'http://www.tripadvisor.com' + record.relativeUrl,
|
||||||
|
score: score
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user