Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved classification of subdivision/unit #180

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions classifier/scheme/street.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,17 @@ module.exports = [
]
},
{
// Am Falkplatz
// N Main
confidence: 0.98,
Class: StreetClassification,
scheme: [
{
is: ['StopWordClassification'],
not: ['IntersectionClassification']
is: ['DirectionalClassification'],
not: ['IntersectionClassification', 'StreetClassification']
},
{
is: ['StreetClassification'],
not: ['StopWordClassification']
not: ['IntersectionClassification', 'DirectionalClassification']
}
]
},
Expand Down
19 changes: 19 additions & 0 deletions classifier/scheme/subdivision.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const HouseNumberClassification = require('../../classification/HouseNumberClassification')

module.exports = [
{
// 10 bis / 10 ter
confidence: 0.99,
Class: HouseNumberClassification,
scheme: [
{
is: ['HouseNumberClassification'],
not: ['IntersectionClassification']
},
{
is: ['StopWordClassification'],
not: ['IntersectionClassification', 'PunctuationClassification']
}
]
}
]
1 change: 1 addition & 0 deletions parser/AddressParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class AddressParser extends Parser {
new CompositeClassifier(require('../classifier/scheme/street')),
new CompositeClassifier(require('../classifier/scheme/venue')),
new CompositeClassifier(require('../classifier/scheme/intersection')),
new CompositeClassifier(require('../classifier/scheme/subdivision')),

// additional classifiers which act on unclassified tokens
new CentralEuropeanStreetNameClassifier()
Expand Down
1 change: 1 addition & 0 deletions resources/pelias/dictionaries/libpostal/de/stopwords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!am
2 changes: 2 additions & 0 deletions resources/pelias/dictionaries/libpostal/fr/stopwords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bis
ter
16 changes: 16 additions & 0 deletions test/address.fra.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,22 @@ const testcase = (test, common) => {
assert(`Esplanade de la Liberté`, [{ street: 'Esplanade de la Liberté' }])
assert(`Esplanade du Géneral de Gaulle`, [{ street: 'Esplanade du Géneral de Gaulle' }])
assert(`Esplanade Méditerranée`, [{ street: 'Esplanade Méditerranée' }])

// bis/ter housenumber prefixes
assert(`1 bis Av. Amélie, 92320 Châtillon, France`, [
{ housenumber: '1 bis' },
{ street: 'Av. Amélie' },
{ postcode: '92320' },
{ locality: 'Châtillon' },
{ country: 'France' }
])
assert(`1 ter Av. Amélie, 92320 Châtillon, France`, [
{ housenumber: '1 ter' },
{ street: 'Av. Amélie' },
{ postcode: '92320' },
{ locality: 'Châtillon' },
{ country: 'France' }
])
}

module.exports.all = (tape, common) => {
Expand Down
8 changes: 4 additions & 4 deletions test/address.usa.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,23 +217,23 @@ const testcase = (test, common) => {
]], false)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are required as the parser previously returned a single result for these queries, it now returns two, but the expected result is still the highest scoring.


// NYC Boroughs
assert('866 E 178th St, Bronx, NY 10460, USA', [[
assert('866 E 178th St, Bronx, NY 10460, USA', [
{ housenumber: '866' },
{ street: 'E 178th St' },
{ locality: 'Bronx' },
{ region: 'NY' },
{ postcode: '10460' },
{ country: 'USA' }
]], false)
])

assert('866 E 178th St, Staten Island, NY 10460, USA', [[
assert('866 E 178th St, Staten Island, NY 10460, USA', [
{ housenumber: '866' },
{ street: 'E 178th St' },
{ locality: 'Staten Island' },
{ region: 'NY' },
{ postcode: '10460' },
{ country: 'USA' }
]], false)
])

// 'Massachusetts' and 'MA' should be interchangeable and both
// forms should allow 'Boston' to be parsed as a locality.
Expand Down
Loading