Skip to content

Commit

Permalink
feat(fr): bis/ter housenumber suffixes
Browse files Browse the repository at this point in the history
  • Loading branch information
missinglink committed Sep 9, 2024
1 parent 14c5be7 commit e98ff9c
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
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
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)

// 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

0 comments on commit e98ff9c

Please sign in to comment.