[dictionaries] Updates to German dictionaries

This commit is contained in:
Al
2016-06-01 12:35:48 -04:00
parent b6fe41451f
commit 010d03b55b
7 changed files with 43 additions and 31 deletions

View File

@@ -5,8 +5,10 @@ g
h h
i i
k k
l
n n
o o
r
s s
u u
v v

View File

@@ -0,0 +1 @@
eingang

View File

@@ -1 +1,3 @@
etage
obergeschoss|og|o g obergeschoss|og|o g
stock

View File

@@ -1 +1,2 @@
stiege|stg stiege|stg
treppe

View File

@@ -0,0 +1,2 @@
links|l
rechts|r

View File

@@ -1,5 +1,5 @@
abteilung|abt appartement|apt|app
büro|buro|buero büro|buro|buero
top top
wohnung|whg|w wohnung|whg|w|/ w|/ / w
zimmer|zi zimmer|zi

View File

@@ -399,26 +399,31 @@ class AddressComponents(object):
def combine_fields(self, address_components, language, country=None, generated_components=None): def combine_fields(self, address_components, language, country=None, generated_components=None):
combo_config = address_config.get_property('components.combinations', language, country=country, default={}) combo_config = address_config.get_property('components.combinations', language, country=country, default={})
values = [] combos = []
probs = [] probs = {}
generated_components = generated_components or set() generated_components = generated_components or set()
for k, v in six.iteritems(combo_config): for k, combo in six.iteritems(combo_config):
values.append(v)
probs.append(v['probability'])
if not isclose(sum(probs), 1.0):
values.append(None)
probs.append(1.0 - sum(probs))
probs = cdf(probs)
combo = weighted_choice(values, probs)
if combo is not None:
components = OrderedDict.fromkeys(combo['components']).keys() components = OrderedDict.fromkeys(combo['components']).keys()
if not all((c in address_components and (c in generated_components or self.is_numeric(address_components[c])) for c in components)): if not all((c in address_components and (c in generated_components or self.is_numeric(address_components[c])) for c in components)):
continue
combos.append((len(components), combo))
if not combos:
return None return None
combos.sort(key=operator.itemgetter(0), reverse=True)
for num_components, combo in combos:
prob = combo['probability']
if random.random() < prob:
break
else:
return None
components = OrderedDict.fromkeys(combo['components']).keys()
values = [] values = []
probs = [] probs = []
for s in combo['separators']: for s in combo['separators']:
@@ -432,7 +437,6 @@ class AddressComponents(object):
new_value = separator.join([address_components.pop(c) for c in components]) new_value = separator.join([address_components.pop(c) for c in components])
address_components[new_label] = new_value address_components[new_label] = new_value
return new_label return new_label
return None
def generated_type(self, component, existing_components, language, country=None): def generated_type(self, component, existing_components, language, country=None):
component_config = address_config.get_property('components.{}'.format(component), language, country=country) component_config = address_config.get_property('components.{}'.format(component), language, country=country)