mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 18:37:58 +00:00
This adds the boilerplate for selecting configurable tokenizers. A tokenizer can be chosen at import time and will then install itself such that it is fixed for the given database import even when the software itself is updated. The legacy tokenizer implements Nominatim's traditional algorithms.
26 lines
547 B
Python
26 lines
547 B
Python
"""
|
|
Tokenizer for testing.
|
|
"""
|
|
|
|
def create(dsn, data_dir):
|
|
""" Create a new instance of the tokenizer provided by this module.
|
|
"""
|
|
return DummyTokenizer(dsn, data_dir)
|
|
|
|
class DummyTokenizer:
|
|
|
|
def __init__(self, dsn, data_dir):
|
|
self.dsn = dsn
|
|
self.data_dir = data_dir
|
|
self.init_state = None
|
|
|
|
|
|
def init_new_db(self, config):
|
|
assert self.init_state == None
|
|
self.init_state = "new"
|
|
|
|
|
|
def init_from_project(self):
|
|
assert self.init_state == None
|
|
self.init_state = "loaded"
|