X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/2b87c016db1dd7a03b5cafe385209529a7457fc6..6ff51712fe3800800d2d1e36a56794ae02b9fd91:/src/nominatim_api/query_preprocessing/normalize.py?ds=sidebyside diff --git a/src/nominatim_api/query_preprocessing/normalize.py b/src/nominatim_api/query_preprocessing/normalize.py index 0c12b93f..0bb0c8ed 100644 --- a/src/nominatim_api/query_preprocessing/normalize.py +++ b/src/nominatim_api/query_preprocessing/normalize.py @@ -5,7 +5,12 @@ # Copyright (C) 2024 by the Nominatim developer community. # For a full list of authors see the git log. """ -Normalize query test using an ICU transliterator. +Normalize query text using the same ICU normalization rules that are +applied during import. If a phrase becomes empty because the normalization +removes all terms, then the phrase is deleted. + +This preprocessor does not come with any extra information. Instead it will +use the configuration from the `normalization` section. """ from typing import cast @@ -22,5 +27,5 @@ def create(config: QueryConfig) -> QueryProcessingFunc: return lambda phrases: list( filter(lambda p: p.text, - (Phrase(p.ptype, cast(str, normalizer.transliterate(p.text))) + (Phrase(p.ptype, cast(str, normalizer.transliterate(p.text)).strip('-: ')) for p in phrases)))