]> git.openstreetmap.org Git - nominatim.git/commitdiff
add postcodes patterns without optional spaces
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 19 May 2022 14:26:51 +0000 (16:26 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 23 Jun 2022 21:42:31 +0000 (23:42 +0200)
settings/country_settings.yaml
test/python/tokenizer/sanitizers/test_clean_postcodes.py

index 972e267042b0cb97056986d03540a9d770769cc5..684b0e44e949332e59c0d03e8e9c43332ed19c53 100644 (file)
@@ -82,6 +82,8 @@ ar:
     partition: 39
     languages: es
     names: !include country-names/ar.yaml
     partition: 39
     languages: es
     names: !include country-names/ar.yaml
+    postcode:
+      pattern: "l?dddd(?:lll)?"
 
 
 #  (American Samoa)
 
 
 #  (American Samoa)
@@ -187,6 +189,8 @@ bh:
     partition: 62
     languages: ar
     names: !include country-names/bh.yaml
     partition: 62
     languages: ar
     names: !include country-names/bh.yaml
+    postcode:
+      pattern: "d?ddd"
 
 
 # Burundi (Burundi)
 
 
 # Burundi (Burundi)
@@ -441,6 +445,8 @@ cy:
     partition: 114
     languages: el, tr
     names: !include country-names/cy.yaml
     partition: 114
     languages: el, tr
     names: !include country-names/cy.yaml
+    postcode:
+      pattern: "(?:99|d)ddd"
 
 
 # Czechia (Česko)
 
 
 # Czechia (Česko)
@@ -582,6 +588,8 @@ fk:
     partition: 91
     languages: en
     names: !include country-names/fk.yaml
     partition: 91
     languages: en
     names: !include country-names/fk.yaml
+    postcode:
+      pattern: "FIQQ 1ZZ"
 
 
 # Federated States of Micronesia (Micronesia)
 
 
 # Federated States of Micronesia (Micronesia)
@@ -660,6 +668,8 @@ gh:
     partition: 211
     languages: en
     names: !include country-names/gh.yaml
     partition: 211
     languages: en
     names: !include country-names/gh.yaml
+    postcode:
+      pattern: "ll-d?ddd-dddd"
 
 
 # Gibraltar (Gibraltar)
 
 
 # Gibraltar (Gibraltar)
@@ -1005,6 +1015,8 @@ kz:
     partition: 94
     languages: kk, ru
     names: !include country-names/kz.yaml
     partition: 94
     languages: kk, ru
     names: !include country-names/kz.yaml
+    postcode:
+      pattern: "(?:lddldld|dddddd)"
 
 
 # Laos (ປະເທດລາວ)
 
 
 # Laos (ປະເທດລາວ)
@@ -1111,6 +1123,8 @@ mc:
     partition: 242
     languages: fr
     names: !include country-names/mc.yaml
     partition: 242
     languages: fr
     names: !include country-names/mc.yaml
+    postcode:
+      pattern: "980dd"
 
 
 # Moldova (Moldova)
 
 
 # Moldova (Moldova)
@@ -1494,6 +1508,8 @@ pw:
     partition: 195
     languages: en, pau, ja, sov, tox
     names: !include country-names/pw.yaml
     partition: 195
     languages: en, pau, ja, sov, tox
     names: !include country-names/pw.yaml
+    postcode:
+      pattern: "969(39|40)"
 
 
 # Paraguay (Paraguay)
 
 
 # Paraguay (Paraguay)
@@ -1646,6 +1662,8 @@ sm:
     partition: 153
     languages: it
     names: !include country-names/sm.yaml
     partition: 153
     languages: it
     names: !include country-names/sm.yaml
+    postcode:
+      pattern: "4789d"
 
 
 # Senegal (Sénégal)
 
 
 # Senegal (Sénégal)
@@ -1717,6 +1735,8 @@ sz:
     partition: 82
     languages: en, ss
     names: !include country-names/sz.yaml
     partition: 82
     languages: en, ss
     names: !include country-names/sz.yaml
+    postcode:
+      pattern: "lddd"
 
 
 # Turks and Caicos Islands (Turks and Caicos Islands)
 
 
 # Turks and Caicos Islands (Turks and Caicos Islands)
@@ -1873,6 +1893,8 @@ um:
     partition: 198
     languages: en
     names: !include country-names/um.yaml
     partition: 198
     languages: en
     names: !include country-names/um.yaml
+    postcode:
+      pattern: "96898"
 
 
 # United States (United States)
 
 
 # United States (United States)
@@ -1905,6 +1927,8 @@ va:
     partition: 107
     languages: it
     names: !include country-names/va.yaml
     partition: 107
     languages: it
     names: !include country-names/va.yaml
+    postcode:
+      pattern: "00120"
 
 
 # Saint Vincent and the Grenadines (Saint Vincent and the Grenadines)
 
 
 # Saint Vincent and the Grenadines (Saint Vincent and the Grenadines)
index 7cb3c70fae165dd5156131def0064f3ac5887ac6..d6371e075ba52c448a097780d7c19be042de1758 100644 (file)
@@ -52,3 +52,26 @@ def test_postcode_pass_good_format(sanitize, postcode):
 @pytest.mark.sanitizer_params(convert_to_address=False)
 def test_postcode_drop_bad_format(sanitize, postcode):
     assert sanitize(country='de', postcode=postcode) == []
 @pytest.mark.sanitizer_params(convert_to_address=False)
 def test_postcode_drop_bad_format(sanitize, postcode):
     assert sanitize(country='de', postcode=postcode) == []
+
+
+@pytest.mark.parametrize("postcode", ('1234', '9435', '99000'))
+def test_postcode_cyprus_pass(sanitize, postcode):
+    assert sanitize(country='cy', postcode=postcode) == [('postcode', postcode)]
+
+
+@pytest.mark.parametrize("postcode", ('91234', '99a45', '567'))
+@pytest.mark.sanitizer_params(convert_to_address=False)
+def test_postcode_cyprus_fail(sanitize, postcode):
+    assert sanitize(country='cy', postcode=postcode) == []
+
+
+@pytest.mark.parametrize("postcode", ('123456', 'A33F2G7'))
+def test_postcode_kazakhstan_pass(sanitize, postcode):
+    assert sanitize(country='kz', postcode=postcode) == [('postcode', postcode)]
+
+
+@pytest.mark.parametrize("postcode", ('V34T6Y923456', '99345'))
+@pytest.mark.sanitizer_params(convert_to_address=False)
+def test_postcode_kazakhstan_fail(sanitize, postcode):
+    assert sanitize(country='kz', postcode=postcode) == []
+