From: Sarah Hoffmann Date: Wed, 8 Jun 2022 05:42:35 +0000 (+0200) Subject: fix postcode pattern for Mozambique X-Git-Tag: v4.1.0~22^2~9 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/e86db3001f90012029a59ec6b313a4f7257035d4?ds=sidebyside fix postcode pattern for Mozambique Optional groups are not implemented yet. --- diff --git a/nominatim/tokenizer/sanitizers/clean_postcodes.py b/nominatim/tokenizer/sanitizers/clean_postcodes.py index fbc46fa5..43d29769 100644 --- a/nominatim/tokenizer/sanitizers/clean_postcodes.py +++ b/nominatim/tokenizer/sanitizers/clean_postcodes.py @@ -57,7 +57,8 @@ class _PostcodeSanitizer: if match is None: return None - return self.matcher.normalize(country, match), ' '.join(match.groups()) + return self.matcher.normalize(country, match),\ + ' '.join(filter(lambda p: p is not None, match.groups())) diff --git a/settings/country_settings.yaml b/settings/country_settings.yaml index 67905ea2..14d08de3 100644 --- a/settings/country_settings.yaml +++ b/settings/country_settings.yaml @@ -1386,8 +1386,7 @@ mz: languages: pt names: !include country-names/mz.yaml postcode: - pattern: "(dddd)-?(dd)?" - output: \1-\2 + pattern: "(dddd)(?:-dd)?" # Namibia (Namibia)