4 from nominatim.indexer.place_info import PlaceInfo
5 from nominatim.config import Configuration
7 def create(dsn, data_dir):
8 """ Create a new instance of the tokenizer provided by this module.
10 return DummyTokenizer(dsn, data_dir)
14 def __init__(self, dsn, data_dir):
16 self.data_dir = data_dir
17 self.init_state = None
18 self.analyser_cache = {}
21 def init_new_db(self, *args, **kwargs):
22 assert self.init_state is None
23 self.init_state = "new"
26 def init_from_project(self, config):
27 assert isinstance(config, Configuration)
28 assert self.init_state is None
29 self.init_state = "loaded"
33 def finalize_import(_):
37 def name_analyzer(self):
38 return DummyNameAnalyzer(self.analyser_cache)
41 class DummyNameAnalyzer:
46 def __exit__(self, exc_type, exc_value, traceback):
50 def __init__(self, cache):
51 self.analyser_cache = cache
52 cache['countries'] = []
59 def normalize_postcode(postcode):
63 def update_postcodes_from_db():
66 def update_special_phrases(self, phrases, should_replace):
67 self.analyser_cache['special_phrases'] = phrases
69 def add_country_names(self, code, names):
70 self.analyser_cache['countries'].append((code, names))
73 def process_place(place):
74 assert isinstance(place, PlaceInfo)