[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 probability: 0.05
country: country:
probability: 0.8 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: countries:
# Anguilla
ai: *add_west_indies
# Antigua and Barbuda
ag: *add_west_indies
# Australia # Australia
au: au:
components: components:
@@ -34,12 +49,21 @@ countries:
country: country:
probability: 0.5 probability: 0.5
# Barbados
bb: *add_west_indies
# Bermuda
bm: *add_west_indies
# Brazil # Brazil
br: br:
components: components:
state: state:
probability: 0.6 probability: 0.6
# Bahamas
bs: *add_west_indies
# Canada # Canada
ca: ca:
components: components:
@@ -48,6 +72,9 @@ countries:
country: country:
probability: 0.2 probability: 0.2
# Dominica
dm: *add_west_indies
# France # France
fr: fr:
components: components:
@@ -64,6 +91,11 @@ countries:
country: country:
probability: 0.6 probability: 0.6
# Grenada
gd: *add_west_indies
# Indonesia # Indonesia
id: id:
components: components:
@@ -84,6 +116,9 @@ countries:
type: relation type: relation
probability: 0.0 probability: 0.0
# Jamaica
jm: *add_west_indies
# Japan # Japan
jp: jp:
components: components:
@@ -110,6 +145,16 @@ countries:
components: components:
island: island:
probability: 0.8 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 # Mexico
mx: mx:
@@ -134,6 +179,15 @@ countries:
island: island:
probability: 0.8 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 # United States
us: us:
# Definitions # Definitions
@@ -234,14 +288,19 @@ countries:
island: island:
probability: 0.8 probability: 0.8
# Saint Vincent and the Grenadines
vc: *add_west_indies
# US Virgin Islands # US Virgin Islands
vi: vi:
components: components:
island: island:
probability: 0.8 probability: 0.8
world_region: *add_west_indies_world_region
# British Virgin Islands # British Virgin Islands
vg: vg:
components: components:
island: island:
probability: 0.8 probability: 0.8
world_region: *add_west_indies_world_region

View File

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

View File

@@ -30,6 +30,7 @@ class PlaceConfig(object):
AddressFormatter.STATE, AddressFormatter.STATE,
AddressFormatter.COUNTRY_REGION, AddressFormatter.COUNTRY_REGION,
AddressFormatter.COUNTRY, AddressFormatter.COUNTRY,
AddressFormatter.WORLD_REGION,
} }
numeric_ops = (('lte', operator.le), numeric_ops = (('lte', operator.le),
@@ -139,6 +140,13 @@ class PlaceConfig(object):
value = components[component] value = components[component]
for c in names[value]: for c in names[value]:
new_components.pop(c, None) 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 return new_components