1

Fixing innerProduct

This commit is contained in:
Alex Yatskov 2014-09-12 23:12:11 +09:00
parent f3f23a288b
commit 89a2de1e15
2 changed files with 10 additions and 5 deletions

View File

@ -6,19 +6,23 @@ var db_data = require('./data.json');
function innerProduct(values1, values2) {
var result = 0;
var result = 0.0;
for (var feature in values1) {
result += (values1[feature] || 0.0) * (values2[feature] || 0.0);
result += values1[feature] * (values2[feature] || 0.0);
}
return result;
}
function scale(values, factor) {
return _.map(values, function(value) {
return value * factor;
});
var result = {};
for (var feature in values) {
result[feature] = values[feature] * factor;
}
return result;
}
function countData(searchParams, minScore) {

View File

@ -16,6 +16,7 @@ function main() {
app.use('/search', function(req, res) {
console.log('Requesting search');
console.log(req.query);
res.json(search.execQuery(req.query));
});