Browse Source

Merge pull request #368 from pelias/postal-code-strip-zeros

Update addressit module to not strip 0s from zipcodes
pull/367/head
Diana Shkolnikov 9 years ago
parent
commit
36035131f0
  1. 2
      package.json
  2. 2
      test/ciao/search/address_parsing.coffee
  3. 4
      test/unit/fixture/search_full_address.js
  4. 2
      test/unit/fixture/search_regions_address.js
  5. 18
      test/unit/helper/text_parser.js

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

@ -88,7 +88,7 @@ module.exports = {
},{ },{
'match': { 'match': {
'address.number': { 'address.number': {
'query': 123, 'query': '123',
'boost': vs.var('address:housenumber:boost').get(), 'boost': vs.var('address:housenumber:boost').get(),
'analyzer': vs.var('address:housenumber:analyzer').get() 'analyzer': vs.var('address:housenumber:analyzer').get()
} }
@ -104,7 +104,7 @@ module.exports = {
}, { }, {
'match': { 'match': {
'address.zip': { 'address.zip': {
'query': 10010, 'query': '10010',
'boost': vs.var('address:postcode:boost').get(), 'boost': vs.var('address:postcode:boost').get(),
'analyzer': vs.var('address:postcode:analyzer').get() 'analyzer': vs.var('address:postcode:analyzer').get()
} }

2
test/unit/fixture/search_regions_address.js

@ -87,7 +87,7 @@ module.exports = {
},{ },{
'match': { 'match': {
'address.number': { 'address.number': {
'query': 1, 'query': '1',
'boost': vs.var('address:housenumber:boost').get(), 'boost': vs.var('address:housenumber:boost').get(),
'analyzer': vs.var('address:housenumber:analyzer').get() 'analyzer': vs.var('address:housenumber:analyzer').get()
} }

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