]> git.openstreetmap.org Git - nominatim.git/blob - nominatim/tokenizer/icu_variants.py
introduce sanitizer step before token analysis
[nominatim.git] / nominatim / tokenizer / icu_variants.py
1 """
2 Data structures for saving variant expansions for ICU tokenizer.
3 """
4 from collections import namedtuple
5
6 _ICU_VARIANT_PORPERTY_FIELDS = ['lang']
7
8
9 class ICUVariantProperties(namedtuple('_ICUVariantProperties', _ICU_VARIANT_PORPERTY_FIELDS)):
10     """ Data container for saving properties that describe when a variant
11         should be applied.
12
13         Property instances are hashable.
14     """
15     @classmethod
16     def from_rules(cls, _):
17         """ Create a new property type from a generic dictionary.
18
19             The function only takes into account the properties that are
20             understood presently and ignores all others.
21         """
22         return cls(lang=None)
23
24
25 ICUVariant = namedtuple('ICUVariant', ['source', 'replacement', 'properties'])