penalize name token splitting when phrases are used

This commit is contained in:
Sarah Hoffmann
2023-07-15 10:55:34 +02:00
parent 8366e4ca83
commit 4a00a3c0f5

View File

@@ -310,7 +310,8 @@ class _TokenSequence:
if (not base.housenumber or first.end >= base.housenumber.start)\
and (not base.qualifier or first.start >= base.qualifier.end):
base_penalty = self.penalty
if base.housenumber and base.housenumber.start > first.start:
if (base.housenumber and base.housenumber.start > first.start) \
or len(query.source) > 1:
base_penalty += 0.25
for i in range(first.start + 1, first.end):
name, addr = first.split(i)
@@ -327,6 +328,8 @@ class _TokenSequence:
base_penalty = self.penalty
if base.housenumber and base.housenumber.start < last.start:
base_penalty += 0.4
if len(query.source) > 1:
base_penalty += 0.25
for i in range(last.start + 1, last.end):
addr, name = last.split(i)
penalty = base_penalty + PENALTY_TOKENCHANGE[query.nodes[i].btype]