Skip to content

Commit

Permalink
feat(poland): classifying more addresses for poland (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
JanF01 committed Aug 15, 2023
1 parent ff961cc commit 7d28b15
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 4 deletions.
2 changes: 1 addition & 1 deletion classifier/PlaceClassifier.js
Expand Up @@ -9,7 +9,7 @@ class PlaceClassifier extends WordClassifier {
setup () {
// load index tokens
this.index = {}
libpostal.load(this.index, ['fr', 'de', 'en'], 'place_names.txt')
libpostal.load(this.index, ['fr', 'de', 'en', 'pl'], 'place_names.txt')
libpostal.generatePlurals(this.index)
}

Expand Down
2 changes: 1 addition & 1 deletion classifier/PostcodeClassifier.js
Expand Up @@ -10,7 +10,7 @@ const dictPath = path.join(__dirname, `../resources/chromium-i18n/ssl-address`)
// const countryCodes = fs.readdirSync(dictPath)
// .filter(p => p.endsWith('.json'))
// .map(p => p.split('.')[0])
const countryCodes = ['us', 'gb', 'fr', 'de', 'es', 'pt', 'au', 'nz', 'kr', 'jp', 'in', 'ru', 'br', 'nl']
const countryCodes = ['us', 'gb', 'fr', 'de', 'es', 'pt', 'au', 'nz', 'kr', 'jp', 'in', 'ru', 'br', 'nl', 'pl']

class PostcodeClassifier extends WordClassifier {
setup () {
Expand Down
2 changes: 1 addition & 1 deletion classifier/StreetPrefixClassifier.js
Expand Up @@ -7,7 +7,7 @@ const libpostal = require('../resources/libpostal/libpostal')

// prefix languages
// languages which use a street prefix instead of a suffix
const prefix = ['fr', 'ca', 'es', 'pt', 'ro']
const prefix = ['fr', 'ca', 'es', 'pt', 'ro', 'pl']

class StreetPrefixClassifier extends WordClassifier {
setup () {
Expand Down
2 changes: 1 addition & 1 deletion classifier/StreetSuffixClassifier.js
Expand Up @@ -7,7 +7,7 @@ const libpostal = require('../resources/libpostal/libpostal')

// prefix languages
// languages which use a street prefix instead of a suffix
const prefix = ['fr', 'ca', 'es', 'pt', 'ro']
const prefix = ['fr', 'ca', 'es', 'pt', 'ro', 'pl']

class StreetSuffixClassifier extends WordClassifier {
setup () {
Expand Down
38 changes: 38 additions & 0 deletions classifier/scheme/street.js
Expand Up @@ -216,6 +216,44 @@ module.exports = [
}
]
},
{
// Aleja Wojska Polskiego
confidence: 0.91,
Class: StreetClassification,
scheme: [
{
is: ['StreetPrefixClassification'],
not: ['StreetClassification', 'IntersectionClassification']
},
{
is: ['PlaceClassification'],
not: ['StreetClassification', 'IntersectionClassification']
},
{
is: ['AlphaClassification', 'GivenNameClassification', 'PersonClassification'],
not: ['StreetClassification', 'StreetPrefixClassification']
}
]
},
{
// Aleja 11 Listopada
confidence: 0.84,
Class: StreetClassification,
scheme: [
{
is: ['StreetPrefixClassification'],
not: ['StreetClassification', 'IntersectionClassification']
},
{
is: ['NumericClassification'],
not: ['StreetClassification', 'IntersectionClassification']
},
{
is: ['AlphaClassification', 'GivenNameClassification', 'PersonClassification'],
not: ['StreetClassification', 'StreetPrefixClassification']
}
]
},
{
// Boulevard du Général Charles De Gaulle
confidence: 0.81,
Expand Down
1 change: 1 addition & 0 deletions resources/pelias/dictionaries/libpostal/pl/place_names.txt
@@ -0,0 +1 @@
wojsko|wojska|wojsk
1 change: 1 addition & 0 deletions resources/pelias/dictionaries/libpostal/pl/synonyms.txt
@@ -0,0 +1 @@
polskiego|polski|pol
22 changes: 22 additions & 0 deletions test/address.pol.test.js
Expand Up @@ -5,6 +5,28 @@ const testcase = (test, common) => {
{ street: 'Szewska' }, { housenumber: '6' },
{ locality: 'Kraków' }
])

assert('aleja Wojska Polskiego 178', [
{ street: 'aleja Wojska Polskiego' }, { housenumber: '178' }
])

assert('aleja 29 listopada 11', [
{ street: 'aleja 29 listopada' }, { housenumber: '11' }
])

assert('aleja Wojska 178', [
{ street: 'aleja Wojska' }, { housenumber: '178' }
])

assert('Ulica Strzelecka 12, Nowy Sącz', [
{ street: 'Ulica Strzelecka' }, { housenumber: '12' },
{ locality: 'Nowy Sącz' }
])

assert('Żorska 11, 47-400', [
{ street: 'Żorska' }, { housenumber: '11' },
{ postcode: '47-400' }
])
}

module.exports.all = (tape, common) => {
Expand Down

0 comments on commit 7d28b15

Please sign in to comment.