mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-11-27 10:43:02 +03:00
16daa57e47
There is no need for the additional layer of indirection that the ICUNameProcessorRules class adds. The ICURuleLoader can fill the database properties directly.
26 lines
762 B
Python
26 lines
762 B
Python
"""
|
|
Data structures for saving variant expansions for ICU tokenizer.
|
|
"""
|
|
from collections import namedtuple
|
|
|
|
_ICU_VARIANT_PORPERTY_FIELDS = ['lang']
|
|
|
|
|
|
class ICUVariantProperties(namedtuple('_ICUVariantProperties', _ICU_VARIANT_PORPERTY_FIELDS)):
|
|
""" Data container for saving properties that describe when a variant
|
|
should be applied.
|
|
|
|
Property instances are hashable.
|
|
"""
|
|
@classmethod
|
|
def from_rules(cls, _):
|
|
""" Create a new property type from a generic dictionary.
|
|
|
|
The function only takes into account the properties that are
|
|
understood presently and ignores all others.
|
|
"""
|
|
return cls(lang=None)
|
|
|
|
|
|
ICUVariant = namedtuple('ICUVariant', ['source', 'replacement', 'properties'])
|