]> git.openstreetmap.org Git - nominatim.git/blob - test/python/api/query_processing/test_split_japanese_phrases.py
Merge pull request #3626 from lonvia/import-performance
[nominatim.git] / test / python / api / query_processing / test_split_japanese_phrases.py
1 # SPDX-License-Identifier: GPL-3.0-or-later
2 #
3 # This file is part of Nominatim. (https://nominatim.org)
4 #
5 # Copyright (C) 2025 by the Nominatim developer community.
6 # For a full list of authors see the git log.
7 """
8 Tests for japanese phrase splitting.
9 """
10 from pathlib import Path
11
12 import pytest
13
14 from icu import Transliterator
15
16 import nominatim_api.search.query as qmod
17 from nominatim_api.query_preprocessing.config import QueryConfig
18 from nominatim_api.query_preprocessing import split_japanese_phrases
19
20 def run_preprocessor_on(query):
21     proc = split_japanese_phrases.create(QueryConfig().set_normalizer(None))
22
23     return proc(query)
24
25
26 @pytest.mark.parametrize('inp,outp', [('大阪府大阪市大阪', '大阪府:大阪市:大阪'),
27                                       ('大阪府大阪', '大阪府:大阪'),
28                                       ('大阪市大阪', '大阪市:大阪')])
29 def test_split_phrases(inp, outp):
30     query = [qmod.Phrase(qmod.PhraseType.NONE, inp)]
31
32     out = run_preprocessor_on(query)
33
34     assert out == [qmod.Phrase(qmod.PhraseType.NONE, outp)]