X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/c3788d765ed4e7ddf00794085af757714bc102cf..3905dd68dd5b261449df7df243c594b25995d8bd:/test/python/tokenizer/token_analysis/test_generic.py diff --git a/test/python/tokenizer/token_analysis/test_generic.py b/test/python/tokenizer/token_analysis/test_generic.py index 9b008cc5..191f551f 100644 --- a/test/python/tokenizer/token_analysis/test_generic.py +++ b/test/python/tokenizer/token_analysis/test_generic.py @@ -1,8 +1,8 @@ -# SPDX-License-Identifier: GPL-2.0-only +# SPDX-License-Identifier: GPL-3.0-or-later # # This file is part of Nominatim. (https://nominatim.org) # -# Copyright (C) 2022 by the Nominatim developer community. +# Copyright (C) 2024 by the Nominatim developer community. # For a full list of authors see the git log. """ Tests for import name normalisation and variant generation. @@ -11,8 +11,8 @@ import pytest from icu import Transliterator -import nominatim.tokenizer.token_analysis.generic as module -from nominatim.errors import UsageError +import nominatim_db.tokenizer.token_analysis.generic as module +from nominatim_db.errors import UsageError DEFAULT_NORMALIZATION = """ :: NFD (); '🜳' > ' '; @@ -30,23 +30,25 @@ def make_analyser(*variants, variant_only=False): rules = { 'analyzer': 'generic', 'variants': [{'words': variants}]} if variant_only: rules['mode'] = 'variant-only' - config = module.configure(rules, DEFAULT_NORMALIZATION) trans = Transliterator.createFromRules("test_trans", DEFAULT_TRANSLITERATION) + norm = Transliterator.createFromRules("test_norm", DEFAULT_NORMALIZATION) + config = module.configure(rules, norm, trans) - return module.create(trans, config) + return module.create(norm, trans, config) def get_normalized_variants(proc, name): norm = Transliterator.createFromRules("test_norm", DEFAULT_NORMALIZATION) - return proc.get_variants_ascii(norm.transliterate(name).strip()) + return proc.compute_variants(norm.transliterate(name).strip()) def test_no_variants(): rules = { 'analyzer': 'generic' } - config = module.configure(rules, DEFAULT_NORMALIZATION) trans = Transliterator.createFromRules("test_trans", DEFAULT_TRANSLITERATION) + norm = Transliterator.createFromRules("test_norm", DEFAULT_NORMALIZATION) + config = module.configure(rules, norm, trans) - proc = module.create(trans, config) + proc = module.create(norm, trans, config) assert get_normalized_variants(proc, '大德!') == ['dà dé'] @@ -121,7 +123,9 @@ class TestGetReplacements: @staticmethod def configure_rules(*variants): rules = { 'analyzer': 'generic', 'variants': [{'words': variants}]} - return module.configure(rules, DEFAULT_NORMALIZATION) + trans = Transliterator.createFromRules("test_trans", DEFAULT_TRANSLITERATION) + norm = Transliterator.createFromRules("test_norm", DEFAULT_NORMALIZATION) + return module.configure(rules, norm, trans) def get_replacements(self, *variants):