From 32729089c1727266872ff4bc06b3dac2025287de Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Tue, 28 May 2019 14:17:32 +0200 Subject: [PATCH] feat(place): support for places such as "Air & Space Museum" (#31) --- classifier/scheme/place.js | 19 +++++++++++++++++++ parser/AddressParser.js | 4 ++-- test/venue.usa.test.js | 19 +++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 test/venue.usa.test.js diff --git a/classifier/scheme/place.js b/classifier/scheme/place.js index 2cb27479..20cfe628 100644 --- a/classifier/scheme/place.js +++ b/classifier/scheme/place.js @@ -45,5 +45,24 @@ module.exports = [ not: [] } ] + }, + { + // Air & Space Museum + confidence: 0.8, + Class: PlaceClassification, + scheme: [ + { + is: ['AlphaClassification'], + not: ['StreetClassification', 'IntersectionClassification', 'StopWordClassification'] + }, + { + is: ['StopWordClassification'], + not: ['StreetClassification'] + }, + { + is: ['PlaceClassification'], + not: [] + } + ] } ] diff --git a/parser/AddressParser.js b/parser/AddressParser.js index e6f4cd8f..ce92378c 100644 --- a/parser/AddressParser.js +++ b/parser/AddressParser.js @@ -64,8 +64,8 @@ class AddressParser extends Parser { new CompositeClassifier(require('../classifier/scheme/person')), new CompositeClassifier(require('../classifier/scheme/street_name')), new CompositeClassifier(require('../classifier/scheme/street')), - new CompositeClassifier(require('../classifier/scheme/intersection')), - new CompositeClassifier(require('../classifier/scheme/place')) + new CompositeClassifier(require('../classifier/scheme/place')), + new CompositeClassifier(require('../classifier/scheme/intersection')) ], // solvers [ diff --git a/test/venue.usa.test.js b/test/venue.usa.test.js new file mode 100644 index 00000000..2f263a12 --- /dev/null +++ b/test/venue.usa.test.js @@ -0,0 +1,19 @@ +const AddressParser = require('../parser/AddressParser') + +const testcase = (test, common) => { + let parser = new AddressParser() + let assert = common.assert.bind(null, test, parser) + + assert('Air & Space Museum Washington DC', [ + { place: 'Air & Space Museum' }, + { locality: 'Washington' }, { region: 'DC' } + ], true) +} + +module.exports.all = (tape, common) => { + function test (name, testFunction) { + return tape(`USA: ${name}`, testFunction) + } + + testcase(test, common) +}