X-Git-Url: https://git.openstreetmap.org/nominatim.git/blobdiff_plain/16daa57e4757e4daeffec1e61630f989727dc563..8171fe4571a57bf8e5b2a8f676989e973897e2e7:/nominatim/tokenizer/icu_rule_loader.py diff --git a/nominatim/tokenizer/icu_rule_loader.py b/nominatim/tokenizer/icu_rule_loader.py index bd0739f2..330179bb 100644 --- a/nominatim/tokenizer/icu_rule_loader.py +++ b/nominatim/tokenizer/icu_rule_loader.py @@ -12,6 +12,7 @@ from icu import Transliterator from nominatim.db.properties import set_property, get_property from nominatim.errors import UsageError from nominatim.tokenizer.icu_name_processor import ICUNameProcessor +from nominatim.tokenizer.place_sanitizer import PlaceSanitizer import nominatim.tokenizer.icu_variants as variants LOG = logging.getLogger() @@ -65,6 +66,9 @@ class ICURuleLoader: self.analysis_rules = self._get_section(rules, 'variants') self._parse_variant_list() + # Load optional sanitizer rule set. + self.sanitizer_rules = rules.get('sanitizers', []) + def load_config_from_db(self, conn): """ Get previously saved parts of the configuration from the @@ -85,6 +89,12 @@ class ICURuleLoader: set_property(conn, DBCFG_IMPORT_ANALYSIS_RULES, json.dumps(self.analysis_rules)) + def make_sanitizer(self): + """ Create a place sanitizer from the configured rules. + """ + return PlaceSanitizer(self.sanitizer_rules) + + def make_token_analysis(self): """ Create a token analyser from the reviouly loaded rules. """