1 # SPDX-License-Identifier: GPL-3.0-or-later
3 # This file is part of Nominatim. (https://nominatim.org)
5 # Copyright (C) 2024 by the Nominatim developer community.
6 # For a full list of authors see the git log.
8 Normalize query text using the same ICU normalization rules that are
9 applied during import. If a phrase becomes empty because the normalization
10 removes all terms, then the phrase is deleted.
12 This preprocessor does not come with any extra information. Instead it will
13 use the configuration from the `normalization` section.
15 from typing import cast
17 from .config import QueryConfig
18 from .base import QueryProcessingFunc
19 from ..search.query import Phrase
22 def create(config: QueryConfig) -> QueryProcessingFunc:
23 normalizer = config.get('_normalizer')
28 return lambda phrases: list(
29 filter(lambda p: p.text,
30 (Phrase(p.ptype, cast(str, normalizer.transliterate(p.text)))