+ self.analysis_rules = self._get_section(rules, 'token-analysis')
+ self._setup_analysis()
+
+ # 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
+ database.
+ """
+ self.normalization_rules = get_property(conn, DBCFG_IMPORT_NORM_RULES)
+ self.transliteration_rules = get_property(conn, DBCFG_IMPORT_TRANS_RULES)
+ self.analysis_rules = json.loads(get_property(conn, DBCFG_IMPORT_ANALYSIS_RULES))
+ self._setup_analysis()
+
+
+ def save_config_to_db(self, conn):
+ """ Save the part of the configuration that cannot be changed into
+ the database.
+ """
+ set_property(conn, DBCFG_IMPORT_NORM_RULES, self.normalization_rules)
+ set_property(conn, DBCFG_IMPORT_TRANS_RULES, self.transliteration_rules)
+ 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.
+ """
+ return self.analysis[None].create(self.normalization_rules,
+ self.transliteration_rules)