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.
7 from typing import Mapping, Optional, List
10 from nominatim_db.data.place_info import PlaceInfo
11 from nominatim_db.data.place_name import PlaceName
12 from nominatim_db.tokenizer.place_sanitizer import PlaceSanitizer
14 class TestTagJapanese:
15 @pytest.fixture(autouse=True)
16 def setup_country(self, def_config):
17 self.config = def_config
19 def run_sanitizer_on(self,type, **kwargs):
24 sanitizer_args = {'step': 'tag-japanese'}
25 _, address = PlaceSanitizer([sanitizer_args], self.config).process_names(place)
26 tmp_list = [(p.name,p.kind) for p in address]
27 return sorted(tmp_list)
29 def test_on_address(self):
30 res = self.run_sanitizer_on('address', name='foo', ref='bar', ref_abc='baz')
31 assert res == [('bar','ref'),('baz','ref_abc'),('foo','name')]
33 def test_housenumber(self):
34 res = self.run_sanitizer_on('address', housenumber='2')
35 assert res == [('2','housenumber')]
37 def test_blocknumber(self):
38 res = self.run_sanitizer_on('address', block_number='6')
39 assert res == [('6','housenumber')]
41 def test_neighbourhood(self):
42 res = self.run_sanitizer_on('address', neighbourhood='8')
43 assert res == [('8','place')]
45 def test_quarter(self):
46 res = self.run_sanitizer_on('address', quarter='kase')
47 assert res==[('kase','place')]
49 def test_housenumber_blocknumber(self):
50 res = self.run_sanitizer_on('address', housenumber='2', block_number='6')
51 assert res == [('6-2','housenumber')]
53 def test_quarter_neighbourhood(self):
54 res = self.run_sanitizer_on('address', quarter='kase', neighbourhood='8')
55 assert res == [('kase8','place')]
57 def test_blocknumber_housenumber_quarter(self):
58 res = self.run_sanitizer_on('address', block_number='6', housenumber='2', quarter='kase')
59 assert res == [('6-2','housenumber'),('kase','place')]
61 def test_blocknumber_housenumber_quarter_neighbourhood(self):
62 res = self.run_sanitizer_on('address', block_number='6', housenumber='2', neighbourhood='8')
63 assert res == [('6-2','housenumber'),('8','place')]
65 def test_blocknumber_quarter_neighbourhood(self):
66 res = self.run_sanitizer_on('address',block_number='6', quarter='kase', neighbourhood='8')
67 assert res == [('6','housenumber'),('kase8','place')]
69 def test_blocknumber_quarter(self):
70 res = self.run_sanitizer_on('address',block_number='6', quarter='kase')
71 assert res == [('6','housenumber'),('kase','place')]
73 def test_blocknumber_neighbourhood(self):
74 res = self.run_sanitizer_on('address',block_number='6', neighbourhood='8')
75 assert res == [('6','housenumber'),('8','place')]
77 def test_housenumber_quarter_neighbourhood(self):
78 res = self.run_sanitizer_on('address',housenumber='2', quarter='kase', neighbourhood='8')
79 assert res == [('2','housenumber'),('kase8','place')]
81 def test_housenumber_quarter(self):
82 res = self.run_sanitizer_on('address',housenumber='2', quarter='kase')
83 assert res == [('2','housenumber'),('kase','place')]
85 def test_housenumber_blocknumber_neighbourhood_quarter(self):
86 res = self.run_sanitizer_on('address', block_number='6', housenumber='2', quarter='kase', neighbourhood='8')
87 assert res == [('6-2','housenumber'),('kase8','place')]