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