Skip to content

Commit

Permalink
feat: add Swedish separable addresses (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joxit authored Sep 3, 2021
1 parent 94eae1b commit e92f96c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion classifier/CompoundStreetClassifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CompoundStreetClassifier extends WordClassifier {
// load street suffixes
this.suffixes = {}

libpostal.load(this.suffixes, ['de', 'nl'], 'concatenated_suffixes_separable.txt', {
libpostal.load(this.suffixes, ['de', 'nl', 'sv'], 'concatenated_suffixes_separable.txt', {
// remove any suffixes which contain less than 3 characters (excluding a period)
// this removes suffixes such as 'r.' which can be ambiguous
minlength: 3
Expand Down
3 changes: 2 additions & 1 deletion classifier/CompoundStreetClassifier.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ module.exports.tests.german_compound = (test) => {
'testallee',
'testweg',
'testplatz',
'testpl.'
'testpl.',
'testvägen'
]

let invalid = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vägen|vagen|v.
27 changes: 27 additions & 0 deletions test/address.swe.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const testcase = (test, common) => {
let assert = common.assert(test)

assert('Gamla Varmdovagen 6', [
{ street: 'Gamla Varmdovagen' }, { housenumber: '6' }
])

assert('Gamla Varmdovägen 6', [
{ street: 'Gamla Varmdovägen' }, { housenumber: '6' }
])

assert('Gamla Varmdo vägen 6', [
{ street: 'Gamla Varmdo vägen' }, { housenumber: '6' }
])

assert('Ångermannagatan 80, Vällingby', [
{ street: 'Ångermannagatan' }, { housenumber: '80' } /*, { locality: 'Vällingby' } */
])
}

module.exports.all = (tape, common) => {
function test (name, testFunction) {
return tape(`address AUS: ${name}`, testFunction)
}

testcase(test, common)
}

0 comments on commit e92f96c

Please sign in to comment.