Initial fork commit
This commit is contained in:
0
scripts/geodata/intersections/__init__.py
Normal file
0
scripts/geodata/intersections/__init__.py
Normal file
18
scripts/geodata/intersections/query.py
Normal file
18
scripts/geodata/intersections/query.py
Normal 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
|
||||
Reference in New Issue
Block a user