Browse Source

Merge pull request #613 from pelias/staging

Merge staging into production
pull/745/head
Julian Simioni 8 years ago committed by GitHub
parent
commit
cf5cbf6f7d
  1. 6
      middleware/confidenceScore.js
  2. 2
      package.json
  3. 32
      test/unit/middleware/confidenceScore.js

6
middleware/confidenceScore.js

@ -93,7 +93,7 @@ function checkForDealBreakers(req, hit) {
return false; return false;
} }
if (check.assigned(req.clean.parsed_text.state) && req.clean.parsed_text.state !== hit.parent.region_a[0]) { if (check.assigned(req.clean.parsed_text.state) && hit.parent.region_a && req.clean.parsed_text.state !== hit.parent.region_a[0]) {
logger.debug('[confidence][deal-breaker]: state !== region_a'); logger.debug('[confidence][deal-breaker]: state !== region_a');
return true; return true;
} }
@ -219,8 +219,8 @@ function checkAddress(text, hit) {
res += propMatch(text.number, (hit.address_parts ? hit.address_parts.number : null), false); res += propMatch(text.number, (hit.address_parts ? hit.address_parts.number : null), false);
res += propMatch(text.street, (hit.address_parts ? hit.address_parts.street : null), false); res += propMatch(text.street, (hit.address_parts ? hit.address_parts.street : null), false);
res += propMatch(text.postalcode, (hit.address_parts ? hit.address_parts.zip: null), true); res += propMatch(text.postalcode, (hit.address_parts ? hit.address_parts.zip: null), true);
res += propMatch(text.state, hit.parent.region_a[0], true); res += propMatch(text.state, (hit.parent.region_a ? hit.parent.region_a[0] : null), true);
res += propMatch(text.country, hit.parent.country_a[0], true); res += propMatch(text.country, (hit.parent.country_a ? hit.parent.country_a[0] :null), true);
res /= checkCount; res /= checkCount;
} }

2
package.json

@ -53,7 +53,7 @@
"pelias-logger": "0.0.8", "pelias-logger": "0.0.8",
"pelias-model": "4.1.0", "pelias-model": "4.1.0",
"pelias-query": "8.1.3", "pelias-query": "8.1.3",
"pelias-text-analyzer": "1.1.0", "pelias-text-analyzer": "1.2.0",
"stats-lite": "2.0.3", "stats-lite": "2.0.3",
"through2": "2.0.1" "through2": "2.0.1"
}, },

32
test/unit/middleware/confidenceScore.js

@ -94,6 +94,38 @@ module.exports.tests.confidenceScore = function(test, common) {
t.end(); t.end();
}); });
test('undefined region fields should be handled gracefully', function(t) {
var req = {
clean: {
text: '123 Main St, City, NM',
parsed_text: {
number: 123,
street: 'Main St',
state: 'NM'
}
}
};
var res = {
data: [{
_score: 10,
found: true,
value: 1,
center_point: { lat: 100.1, lon: -50.5 },
name: { default: 'test name1' },
parent: {
country: ['country1'],
region: undefined,
region_a: undefined,
county: ['city1']
}
}],
meta: {scores: [10]}
};
confidenceScore(req, res, function() {});
t.equal(res.data[0].confidence, 0.28, 'score was set');
t.end();
});
}; };
module.exports.all = function (tape, common) { module.exports.all = function (tape, common) {

Loading…
Cancel
Save