]> git.openstreetmap.org Git - nominatim.git/commitdiff
penalize name token splitting when phrases are used
authorSarah Hoffmann <lonvia@denofr.de>
Sat, 15 Jul 2023 08:55:34 +0000 (10:55 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 17 Jul 2023 14:27:25 +0000 (16:27 +0200)
nominatim/api/search/token_assignment.py

index f1c2f8e8bf94f98c6ae6817eae19b8425fe40565..c05c271a3d411dc23d084dec8266a70241a3651a 100644 (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]