From d9f3e6aa9885bc2759ac8cec3dab42a713921df1 Mon Sep 17 00:00:00 2001 From: sweco-semhul Date: Fri, 27 Oct 2017 12:58:22 +0200 Subject: [PATCH 1/2] Adding unit attribute to address_parts in addresit parsers and tests for it --- src/addressItParser.js | 1 + test/addressItParser.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/addressItParser.js b/src/addressItParser.js index 71a2687..b4cda13 100644 --- a/src/addressItParser.js +++ b/src/addressItParser.js @@ -43,6 +43,7 @@ function parse(query) { addressWithAddressParts); var address_parts = [ 'name', + 'unit', 'number', 'street', 'city', diff --git a/test/addressItParser.js b/test/addressItParser.js index a035329..2495b1b 100644 --- a/test/addressItParser.js +++ b/test/addressItParser.js @@ -68,6 +68,17 @@ tape('tests', function(test) { t.equal(address.state , 'NY', 'parsed state'); t.end(); }); + test.test('valid address, unt', function(t) { + var query_string = 'Shop 8, 431 St Kilda Rd Melbourne'; + var address = parser.parse(query_string); + + t.equal(typeof address, 'object', 'valid object for the address'); + t.equal(address.unit , '8', 'parsed unit'); + t.equal(address.number, '431', 'parsed house number'); + t.equal(address.street, 'St Kilda Rd', 'parsed street'); + t.deepEqual(address.regions, ['Melbourne'], 'parsed city'); + t.end(); + }); test.test('valid address, house number', function(t) { var query_string = '123 main st new york ny'; var address = parser.parse(query_string); From 9e1b17449e199a6dbd821095a4b96908c9d4e903 Mon Sep 17 00:00:00 2001 From: sweco-semhul Date: Fri, 27 Oct 2017 12:58:40 +0200 Subject: [PATCH 2/2] Adding unit attribute to address_parts in libpostal parser and tests for it --- src/libpostalParser.js | 1 + test/libpostalParser.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/libpostalParser.js b/src/libpostalParser.js index 3e2b018..b075dcd 100644 --- a/src/libpostalParser.js +++ b/src/libpostalParser.js @@ -6,6 +6,7 @@ var field_mapping = { island: 'island', category: 'category', house: 'query', + unit: 'unit', house_number: 'number', road: 'street', suburb: 'neighbourhood', diff --git a/test/libpostalParser.js b/test/libpostalParser.js index 71f8e43..7118948 100644 --- a/test/libpostalParser.js +++ b/test/libpostalParser.js @@ -40,6 +40,10 @@ tape('tests', function(test) { component: 'house', value: 'house value' }, + { + component: 'unit', + value: 'unit value' + }, { component: 'house_number', value: 'house_number value' @@ -87,6 +91,7 @@ tape('tests', function(test) { island: 'island value', category: 'category value', query: 'house value', + unit: 'unit value', number: 'house_number value', street: 'road value', neighbourhood: 'suburb value',