X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/d35e3c25b66d25e4a3dd073c7ba17b0c204ec8e8..78c19bc006d5957f183968d086226be4b2b65fe3:/nominatim/tokenizer/token_analysis/config_variants.py diff --git a/nominatim/tokenizer/token_analysis/config_variants.py b/nominatim/tokenizer/token_analysis/config_variants.py index e0d1579d..1258373e 100644 --- a/nominatim/tokenizer/token_analysis/config_variants.py +++ b/nominatim/tokenizer/token_analysis/config_variants.py @@ -12,8 +12,6 @@ from collections import defaultdict import itertools import re -from icu import Transliterator - from nominatim.config import flatten_config_list from nominatim.errors import UsageError @@ -25,7 +23,7 @@ class ICUVariant(NamedTuple): def get_variant_config(in_rules: Any, - normalization_rules: str) -> Tuple[List[Tuple[str, List[str]]], str]: + normalizer: Any) -> Tuple[List[Tuple[str, List[str]]], str]: """ Convert the variant definition from the configuration into replacement sets. @@ -39,7 +37,7 @@ def get_variant_config(in_rules: Any, vset: Set[ICUVariant] = set() rules = flatten_config_list(in_rules, 'variants') - vmaker = _VariantMaker(normalization_rules) + vmaker = _VariantMaker(normalizer) for section in rules: for rule in (section.get('words') or []): @@ -58,14 +56,13 @@ def get_variant_config(in_rules: Any, class _VariantMaker: - """ Generater for all necessary ICUVariants from a single variant rule. + """ Generator for all necessary ICUVariants from a single variant rule. All text in rules is normalized to make sure the variants match later. """ - def __init__(self, norm_rules: Any) -> None: - self.norm = Transliterator.createFromRules("rule_loader_normalization", - norm_rules) + def __init__(self, normalizer: Any) -> None: + self.norm = normalizer def compute(self, rule: Any) -> Iterator[ICUVariant]: