|
|
|
@ -137,6 +137,82 @@ module.exports.tests.confidenceScore = function(test, common) {
|
|
|
|
|
t.end(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('placeholder style search queries should get confidence score', function(t) { |
|
|
|
|
var req = { |
|
|
|
|
clean: { |
|
|
|
|
text: '123 Main St, City, NM', |
|
|
|
|
parsed_text: { |
|
|
|
|
number: 123, |
|
|
|
|
street: 'Main St', |
|
|
|
|
city: 'City', |
|
|
|
|
state: 'NM' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
var res = { |
|
|
|
|
data: [{ |
|
|
|
|
_score: 10, |
|
|
|
|
found: true, |
|
|
|
|
value: 1, |
|
|
|
|
layer: 'address', |
|
|
|
|
center_point: { lat: 100.1, lon: -50.5 }, |
|
|
|
|
name: { default: 'test name1' }, |
|
|
|
|
parent: { |
|
|
|
|
country: ['country1'], |
|
|
|
|
region: ['region1'], |
|
|
|
|
county: ['city1'] |
|
|
|
|
} |
|
|
|
|
}], |
|
|
|
|
meta: { |
|
|
|
|
scores: [10], |
|
|
|
|
query_type: 'address_search_with_ids' |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
confidenceScore(req, res, function() {}); |
|
|
|
|
t.equal(res.data[0].confidence, 1.0, 'max score was set'); |
|
|
|
|
t.equal(res.data[0].match_type, 'exact', 'exact match indicated'); |
|
|
|
|
t.end(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('structured search queries should get confidence score', function(t) { |
|
|
|
|
var req = { |
|
|
|
|
clean: { |
|
|
|
|
text: '123 Main St, City, NM', |
|
|
|
|
parsed_text: { |
|
|
|
|
number: 123, |
|
|
|
|
street: 'Main St', |
|
|
|
|
city: 'City', |
|
|
|
|
state: 'NM' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
var res = { |
|
|
|
|
data: [{ |
|
|
|
|
_score: 10, |
|
|
|
|
found: true, |
|
|
|
|
value: 1, |
|
|
|
|
layer: 'address', |
|
|
|
|
center_point: { lat: 100.1, lon: -50.5 }, |
|
|
|
|
name: { default: 'test name1' }, |
|
|
|
|
parent: { |
|
|
|
|
country: ['country1'], |
|
|
|
|
region: ['region1'], |
|
|
|
|
county: ['city1'] |
|
|
|
|
} |
|
|
|
|
}], |
|
|
|
|
meta: { |
|
|
|
|
scores: [10], |
|
|
|
|
query_type: 'structured' |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
confidenceScore(req, res, function() {}); |
|
|
|
|
t.equal(res.data[0].confidence, 1.0, 'max score was set'); |
|
|
|
|
t.equal(res.data[0].match_type, 'exact', 'exact match indicated'); |
|
|
|
|
t.end(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('no fallback street query should have max score', function(t) { |
|
|
|
|
var req = { |
|
|
|
|
clean: { |
|
|
|
|