Browse Source

Merge remote-tracking branch 'origin' into dedupe-post-es

pull/376/head
Diana Shkolnikov 9 years ago
parent
commit
af7abce68f
  1. 2
      circle.yml
  2. 6
      middleware/confidenceScore.js
  3. 2
      package.json
  4. 2
      test/ciao/search/address_parsing.coffee
  5. 4
      test/unit/fixture/search_full_address.js
  6. 2
      test/unit/fixture/search_regions_address.js
  7. 18
      test/unit/helper/text_parser.js

2
circle.yml

@ -11,7 +11,7 @@ deployment:
- git clone git@github.com:mapzen/pelias-deploy.git && cd pelias-deploy && bundle install - git clone git@github.com:mapzen/pelias-deploy.git && cd pelias-deploy && bundle install
- cd pelias-deploy && bundle exec rake deploy:api[dev] - cd pelias-deploy && bundle exec rake deploy:api[dev]
prod_build: prod_build:
branch: production branch: staging
commands: commands:
- git clone git@github.com:mapzen/pelias-deploy.git && cd pelias-deploy && bundle install - git clone git@github.com:mapzen/pelias-deploy.git && cd pelias-deploy && bundle install
- cd pelias-deploy && bundle exec rake deploy:api[prod_build] - cd pelias-deploy && bundle exec rake deploy:api[prod_build]

6
middleware/confidenceScore.js

@ -100,8 +100,8 @@ function checkForDealBreakers(req, hit) {
return true; return true;
} }
if (check.assigned(req.clean.parsed_text.postalcode) && req.clean.parsed_text.postalcode !== hit.zip) { if (check.assigned(req.clean.parsed_text.postalcode) && req.clean.parsed_text.postalcode !== hit.address.zip) {
logger.debug('[confidence][deal-breaker]: postalcode !== zip'); logger.debug('[confidence][deal-breaker]: postalcode !== zip (' + req.clean.parsed_text.postalcode + ' !== ' + hit.address.zip + ')');
return true; return true;
} }
} }
@ -208,7 +208,7 @@ function propMatch(textProp, hitProp, expectEnriched) {
* @param {object} [hit.address] * @param {object} [hit.address]
* @param {string|number} [hit.address.number] * @param {string|number} [hit.address.number]
* @param {string} [hit.address.street] * @param {string} [hit.address.street]
* @param {string|number} [hit.zip] * @param {string|number} [hit.address.zip]
* @param {string} [hit.admin1_abbr] * @param {string} [hit.admin1_abbr]
* @param {string} [hit.alpha3] * @param {string} [hit.alpha3]
* @returns {number} * @returns {number}

2
package.json

@ -33,7 +33,7 @@
"elasticsearch": ">=1.2.1" "elasticsearch": ">=1.2.1"
}, },
"dependencies": { "dependencies": {
"addressit": "1.3.0", "addressit": "git://github.com/dianashk/addressit.git#temp",
"async": "^0.9.0", "async": "^0.9.0",
"check-types": "^3.3.1", "check-types": "^3.3.1",
"cluster2": "git://github.com/missinglink/cluster2.git#node_zero_twelve", "cluster2": "git://github.com/missinglink/cluster2.git#node_zero_twelve",

2
test/ciao/search/address_parsing.coffee

@ -34,7 +34,7 @@ json.geocoding.query['size'].should.eql 10
#? address parsing #? address parsing
json.geocoding.query.parsed_text['name'].should.eql '30 w 26th st' json.geocoding.query.parsed_text['name'].should.eql '30 w 26th st'
json.geocoding.query.parsed_text['number'].should.eql 30 json.geocoding.query.parsed_text['number'].should.eql '30'
json.geocoding.query.parsed_text['street'].should.eql 'w 26th st' json.geocoding.query.parsed_text['street'].should.eql 'w 26th st'
json.geocoding.query.parsed_text['state'].should.eql 'NY' json.geocoding.query.parsed_text['state'].should.eql 'NY'
json.geocoding.query.parsed_text['regions'].should.eql [] json.geocoding.query.parsed_text['regions'].should.eql []

4
test/unit/fixture/search_full_address.js

@ -86,7 +86,7 @@ module.exports = {
},{ },{
'match': { 'match': {
'address.number': { 'address.number': {
'query': 123, 'query': '123',
'boost': vs['address:housenumber:boost'], 'boost': vs['address:housenumber:boost'],
'analyzer': vs['address:housenumber:analyzer'] 'analyzer': vs['address:housenumber:analyzer']
} }
@ -102,7 +102,7 @@ module.exports = {
}, { }, {
'match': { 'match': {
'address.zip': { 'address.zip': {
'query': 10010, 'query': '10010',
'boost': vs['address:postcode:boost'], 'boost': vs['address:postcode:boost'],
'analyzer': vs['address:postcode:analyzer'] 'analyzer': vs['address:postcode:analyzer']
} }

2
test/unit/fixture/search_regions_address.js

@ -86,7 +86,7 @@ module.exports = {
},{ },{
'match': { 'match': {
'address.number': { 'address.number': {
'query': 1, 'query': '1',
'boost': vs['address:housenumber:boost'], 'boost': vs['address:housenumber:boost'],
'analyzer': vs['address:housenumber:analyzer'] 'analyzer': vs['address:housenumber:analyzer']
} }

18
test/unit/helper/text_parser.js

@ -85,7 +85,7 @@ module.exports.tests.parse_address = function(test, common) {
var address = parser.get_parsed_address(query_string); var address = parser.get_parsed_address(query_string);
t.equal(typeof address, 'object', 'valid object for the address'); t.equal(typeof address, 'object', 'valid object for the address');
t.equal(address.number, 123, 'parsed house number'); t.equal(address.number, '123', 'parsed house number');
t.equal(address.street, 'main st', 'parsed street'); t.equal(address.street, 'main st', 'parsed street');
t.deepEqual(address.regions, ['new york'], 'parsed city'); t.deepEqual(address.regions, ['new york'], 'parsed city');
t.equal(address.state , 'NY', 'parsed state'); t.equal(address.state , 'NY', 'parsed state');
@ -96,11 +96,23 @@ module.exports.tests.parse_address = function(test, common) {
var address = parser.get_parsed_address(query_string); var address = parser.get_parsed_address(query_string);
t.equal(typeof address, 'object', 'valid object for the address'); t.equal(typeof address, 'object', 'valid object for the address');
t.equal(address.number, 123, 'parsed house number'); t.equal(address.number, '123', 'parsed house number');
t.equal(address.street, 'main st', 'parsed street'); t.equal(address.street, 'main st', 'parsed street');
t.deepEqual(address.regions, ['new york'], 'parsed city'); t.deepEqual(address.regions, ['new york'], 'parsed city');
t.equal(address.state , 'NY', 'parsed state'); t.equal(address.state , 'NY', 'parsed state');
t.equal(address.postalcode, 10010, 'parsed zip'); t.equal(address.postalcode, '10010', 'parsed zip is a string');
t.end();
});
test('valid address with leading 0s in zipcode', function(t) {
var query_string = '339 W Main St, Cheshire, 06410';
var address = parser.get_parsed_address(query_string);
console.log(address);
t.equal(typeof address, 'object', 'valid object for the address');
t.equal(address.street, 'W Main St', 'parsed street');
t.deepEqual(address.regions, ['Cheshire'], 'parsed city');
t.equal(address.postalcode, '06410', 'parsed zip');
t.end(); t.end();
}); });
}; };

Loading…
Cancel
Save