[formatting] adding non-zero invert probabilities to all the former Soviet states. Other template insertions can still apply afterward for #125
This commit is contained in:
@@ -8,6 +8,9 @@ global:
|
||||
ko_rm: en
|
||||
zh_pinyin: en
|
||||
|
||||
# Former Soviet states sometimes write addresses generai-to-specific
|
||||
invert_probability: 0.0
|
||||
|
||||
insertions:
|
||||
# For each component, insertions are mutually exclusive
|
||||
# They don't have to sum to 1 (especially for components
|
||||
@@ -857,3 +860,63 @@ countries:
|
||||
|
||||
kr_en:
|
||||
insertions: *us_template_insertions
|
||||
|
||||
# Russia
|
||||
ru:
|
||||
invert_probability: 0.2
|
||||
|
||||
# Ukraine
|
||||
uk:
|
||||
invert_probability: 0.2
|
||||
|
||||
# Belarus (using inverted by default)
|
||||
by:
|
||||
invert_probability: 0.4
|
||||
|
||||
# Kazakhstan (using inverted by default)
|
||||
kz:
|
||||
invert_probability: 0.4
|
||||
|
||||
# Kyrgyzstan (using inverted by default)
|
||||
kg:
|
||||
invert_probability: 0.4
|
||||
|
||||
# Latvia
|
||||
lv:
|
||||
invert_probability: 0.2
|
||||
|
||||
# Lithuania
|
||||
lt:
|
||||
invert_probability: 0.2
|
||||
|
||||
# Estonia
|
||||
ee:
|
||||
invert_probability: 0.2
|
||||
|
||||
# Armenia
|
||||
am:
|
||||
invert_probability: 0.2
|
||||
|
||||
# Azerbaijan
|
||||
az:
|
||||
invert_probability: 0.2
|
||||
|
||||
# Georgia
|
||||
ge:
|
||||
invert_probability: 0.2
|
||||
|
||||
# Moldova
|
||||
md:
|
||||
invert_probability: 0.2
|
||||
|
||||
# Uzbekistan
|
||||
uz:
|
||||
invert_probability: 0.2
|
||||
|
||||
# Tajikistan
|
||||
tj:
|
||||
invert_probability: 0.2
|
||||
|
||||
# Turkmenistan
|
||||
tm:
|
||||
invert_probability: 0.2
|
||||
|
||||
@@ -630,8 +630,13 @@ class AddressFormatter(object):
|
||||
|
||||
invert_probability = self.country_invert_probabilities.get(country, self.global_invert_probability)
|
||||
if random.random() < invert_probability:
|
||||
template = self.inverted(template)
|
||||
cache_keys.append('inverted')
|
||||
cache_key = tuple(sorted(cache_keys))
|
||||
if cache_key in self.template_cache:
|
||||
template = self.template_cache[cache_key]
|
||||
else:
|
||||
template = self.inverted(template)
|
||||
self.template_cache[cache_key] = template
|
||||
|
||||
for component in sorted(components, key=self.component_order.get):
|
||||
scope = country
|
||||
|
||||
Reference in New Issue
Block a user