Browse Source

adjusted 'exact' confidence to be within 1 meter

pull/274/head
Stephen Hess 9 years ago
parent
commit
5849477929
  1. 4
      middleware/confidenceScoreReverse.js
  2. 55
      test/unit/middleware/confidenceScoreReverse.js

4
middleware/confidenceScoreReverse.js

@ -39,9 +39,9 @@ function computeConfidenceScore(req, hit) {
// figure out which range the distance lies in and assign confidence accordingly
// TODO: this could probably be made more node-y with a map of function->number
if (meters === 0) {
if (meters < 1.0) {
hit.confidence = confidence.exact;
} else if (_.inRange(meters, 0, 10)) {
} else if (_.inRange(meters, 1, 10)) {
hit.confidence = confidence.excellent;
} else if (_.inRange(meters, 10, 100)) {
hit.confidence = confidence.good;

55
test/unit/middleware/confidenceScoreReverse.js

@ -3,34 +3,30 @@ var confidenceScoreReverse = require('../../../middleware/confidenceScoreReverse
module.exports.tests = {};
module.exports.tests.confidenceScoreReverse = function(test, common) {
test('distance == 0m should be given score 1.0', function(t) {
test('0m <= distance < 1m should be given score 1.0', function(t) {
var req = {
results: {
data: [
{
distance: 0
}
{ distance: 0.0000 / 1000.0 },
{ distance: 0.9999 / 1000.0 }
]
}
};
confidenceScoreReverse(req, null, function() {
t.equal(req.results.data[0].confidence, 1.0, 'score should be exact confidence');
t.equal(req.results.data[1].confidence, 1.0, 'score should be exact confidence');
t.end();
});
});
test('0m < distance < 10m should be given score 0.9', function(t) {
test('1m <= distance < 10m should be given score 0.9', function(t) {
var req = {
results: {
data: [
{
distance: 0.0001
},
{
distance: 0.0099
}
{ distance: 1.0000 / 1000.0 },
{ distance: 9.9999 / 1000.0 }
]
}
};
@ -47,12 +43,8 @@ module.exports.tests.confidenceScoreReverse = function(test, common) {
var req = {
results: {
data: [
{
distance: 0.010
},
{
distance: 0.099
}
{ distance: 10.0000 / 1000.0 },
{ distance: 99.9999 / 1000.0 }
]
}
};
@ -69,12 +61,8 @@ module.exports.tests.confidenceScoreReverse = function(test, common) {
var req = {
results: {
data: [
{
distance: 0.100
},
{
distance: 0.249
}
{ distance: 100.0000 / 1000.0 },
{ distance: 249.9999 / 1000.0 }
]
}
};
@ -91,12 +79,8 @@ module.exports.tests.confidenceScoreReverse = function(test, common) {
var req = {
results: {
data: [
{
distance: 0.250
},
{
distance: 0.999
}
{ distance: 250.0000 / 1000.0 },
{ distance: 999.9999 / 1000.0 }
]
}
};
@ -113,12 +97,8 @@ module.exports.tests.confidenceScoreReverse = function(test, common) {
var req = {
results: {
data: [
{
distance: 1
},
{
distance: 2
}
{ distance: 1000.0 / 1000.0 },
{ distance: 2000.0 / 1000.0 }
]
}
};
@ -135,9 +115,7 @@ module.exports.tests.confidenceScoreReverse = function(test, common) {
var req = {
results: {
data: [
{
distance: -0.0001
}
{ distance: -1.0000 / 1000.0 }
]
}
};
@ -174,7 +152,6 @@ module.exports.tests.confidenceScoreReverse = function(test, common) {
};
module.exports.all = function (tape, common) {
function test(name, testFunction) {
return tape('[middleware] confidenceScoreReverse: ' + name, testFunction);
}

Loading…
Cancel
Save