[intersections] Adding places to intersection template, intersection phrase generator

This commit is contained in:
Al
2016-05-30 21:07:14 -04:00
parent 701e67614a
commit 5075128ada
7 changed files with 43 additions and 4 deletions

View File

@@ -0,0 +1,18 @@
from collections import namedtuple
from geodata.addresses.config import address_config
from geodata.math.sampling import weighted_choice
IntersectionQuery = namedtuple('IntersectionQuery', 'road1, intersection_phrase, road2')
NULL_INTERSECTION_QUERY = IntersectionQuery(None, None, None)
class Intersection(object):
@classmethod
def phrase(cls, language, country=None):
values, probs = address_config.alternative_probabilities('cross_streets.intersection', language, country=country)
if not values:
return None
phrase, props = weighted_choice(values, probs)
return phrase