]> git.openstreetmap.org Git - nominatim.git/blobdiff - src/nominatim_api/query_preprocessing/normalize.py
Merge pull request #3655 from lonvia/remove-name-ranking-in-postcode-search
[nominatim.git] / src / nominatim_api / query_preprocessing / normalize.py
index 0c12b93f169c672fda8a68c8270beb869a410e9e..0bb0c8ed744d00e1e97c3c114b05ed9d887729d2 100644 (file)
@@ -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)))