4 from nominatim.indexer.place_info import PlaceInfo
6 def create(dsn, data_dir):
7 """ Create a new instance of the tokenizer provided by this module.
9 return DummyTokenizer(dsn, data_dir)
13 def __init__(self, dsn, data_dir):
15 self.data_dir = data_dir
16 self.init_state = None
17 self.analyser_cache = {}
20 def init_new_db(self, *args, **kwargs):
21 assert self.init_state is None
22 self.init_state = "new"
25 def init_from_project(self):
26 assert self.init_state is None
27 self.init_state = "loaded"
31 def finalize_import(_):
35 def name_analyzer(self):
36 return DummyNameAnalyzer(self.analyser_cache)
39 class DummyNameAnalyzer:
44 def __exit__(self, exc_type, exc_value, traceback):
48 def __init__(self, cache):
49 self.analyser_cache = cache
50 cache['countries'] = []
57 def normalize_postcode(postcode):
61 def update_postcodes_from_db():
64 def update_special_phrases(self, phrases, should_replace):
65 self.analyser_cache['special_phrases'] = phrases
67 def add_country_names(self, code, names):
68 self.analyser_cache['countries'].append((code, names))
71 def process_place(place):
72 assert isinstance(place, PlaceInfo)