[places] adding world_region tag and adding the phrase West Indies with small random probability for English-speaking Caribbean nations. Ref: #113

This commit is contained in:
Al
2016-09-11 21:54:47 -04:00
parent 069e4c348c
commit 55e9ab1978
3 changed files with 71 additions and 0 deletions

View File

@@ -24,8 +24,23 @@ global:
probability: 0.05
country:
probability: 0.8
world_region:
probability: 0.001
add_west_indies: &add_west_indies
components:
world_region: &add_west_indies_world_region
probability: 0.1
value: West Indies
countries:
# Anguilla
ai: *add_west_indies
# Antigua and Barbuda
ag: *add_west_indies
# Australia
au:
components:
@@ -34,12 +49,21 @@ countries:
country:
probability: 0.5
# Barbados
bb: *add_west_indies
# Bermuda
bm: *add_west_indies
# Brazil
br:
components:
state:
probability: 0.6
# Bahamas
bs: *add_west_indies
# Canada
ca:
components:
@@ -48,6 +72,9 @@ countries:
country:
probability: 0.2
# Dominica
dm: *add_west_indies
# France
fr:
components:
@@ -64,6 +91,11 @@ countries:
country:
probability: 0.6
# Grenada
gd: *add_west_indies
# Indonesia
id:
components:
@@ -84,6 +116,9 @@ countries:
type: relation
probability: 0.0
# Jamaica
jm: *add_west_indies
# Japan
jp:
components:
@@ -110,6 +145,16 @@ countries:
components:
island:
probability: 0.8
world_region: *add_west_indies_world_region
# Cayman Islands
ky: *add_west_indies
# Saint Lucia
lc: *add_west_indies
# Montserrat
ms: *add_west_indies
# Mexico
mx:
@@ -134,6 +179,15 @@ countries:
island:
probability: 0.8
# Sint Maarten
sx: *add_west_indies
# Turks and Caicos
tc: *add_west_indies
# Trinidad and Tobago
tt: *add_west_indies
# United States
us:
# Definitions
@@ -234,14 +288,19 @@ countries:
island:
probability: 0.8
# Saint Vincent and the Grenadines
vc: *add_west_indies
# US Virgin Islands
vi:
components:
island:
probability: 0.8
world_region: *add_west_indies_world_region
# British Virgin Islands
vg:
components:
island:
probability: 0.8
world_region: *add_west_indies_world_region

View File

@@ -75,6 +75,7 @@ class AddressFormatter(object):
POSTCODE = 'postcode'
COUNTRY_REGION = 'country_region'
COUNTRY = 'country'
WORLD_REGION = 'world_region'
component_order = {k: i for i, k in enumerate([
CATEGORY,
@@ -102,6 +103,7 @@ class AddressFormatter(object):
POSTCODE,
COUNTRY_REGION,
COUNTRY,
WORLD_REGION,
])}
BOUNDARY_COMPONENTS_ORDERED = [
@@ -115,6 +117,7 @@ class AddressFormatter(object):
STATE,
COUNTRY_REGION,
COUNTRY,
WORLD_REGION,
]
BOUNDARY_COMPONENTS = set(BOUNDARY_COMPONENTS_ORDERED)
@@ -153,6 +156,7 @@ class AddressFormatter(object):
('county', STATE_DISTRICT),
('state_code', STATE),
('country_name', COUNTRY),
('continent', WORLD_REGION),
('postal_code', POSTCODE),
('post_code', POSTCODE),
])

View File

@@ -30,6 +30,7 @@ class PlaceConfig(object):
AddressFormatter.STATE,
AddressFormatter.COUNTRY_REGION,
AddressFormatter.COUNTRY,
AddressFormatter.WORLD_REGION,
}
numeric_ops = (('lte', operator.le),
@@ -139,6 +140,13 @@ class PlaceConfig(object):
value = components[component]
for c in names[value]:
new_components.pop(c, None)
for component in self.ADMIN_COMPONENTS:
value = self.get_property(('components', component, 'value'), country=country, default=None)
if value is not None and component not in components and self.include_component(component, containing_ids, country=country, population=population):
new_components[component] = value
return new_components