mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
avoid splitting of first token when a housenumber is present
This only covers the case of <poi name> <street name> <housenumber> which is exceedingly rare.
This commit is contained in:
@@ -225,9 +225,7 @@ class SearchBuilder:
|
|||||||
# This might yield wrong results, nothing we can do about that.
|
# This might yield wrong results, nothing we can do about that.
|
||||||
if not partials_indexed:
|
if not partials_indexed:
|
||||||
addr_tokens = [t.token for t in addr_partials if t.is_indexed]
|
addr_tokens = [t.token for t in addr_partials if t.is_indexed]
|
||||||
log().var_dump('before', penalty)
|
|
||||||
penalty += 1.2 * sum(t.penalty for t in addr_partials if not t.is_indexed)
|
penalty += 1.2 * sum(t.penalty for t in addr_partials if not t.is_indexed)
|
||||||
log().var_dump('after', penalty)
|
|
||||||
if rare_names:
|
if rare_names:
|
||||||
# Any of the full names applies with all of the partials from the address
|
# Any of the full names applies with all of the partials from the address
|
||||||
lookup = [dbf.FieldLookup('name_vector', [t.token for t in rare_names], 'lookup_any')]
|
lookup = [dbf.FieldLookup('name_vector', [t.token for t in rare_names], 'lookup_any')]
|
||||||
|
|||||||
@@ -309,9 +309,12 @@ class _TokenSequence:
|
|||||||
first = base.address[0]
|
first = base.address[0]
|
||||||
if (not base.housenumber or first.end >= base.housenumber.start)\
|
if (not base.housenumber or first.end >= base.housenumber.start)\
|
||||||
and (not base.qualifier or first.start >= base.qualifier.end):
|
and (not base.qualifier or first.start >= base.qualifier.end):
|
||||||
|
base_penalty = self.penalty
|
||||||
|
if base.housenumber and base.housenumber.start > first.start:
|
||||||
|
base_penalty += 0.25
|
||||||
for i in range(first.start + 1, first.end):
|
for i in range(first.start + 1, first.end):
|
||||||
name, addr = first.split(i)
|
name, addr = first.split(i)
|
||||||
penalty = self.penalty + PENALTY_TOKENCHANGE[query.nodes[i].btype]
|
penalty = base_penalty + PENALTY_TOKENCHANGE[query.nodes[i].btype]
|
||||||
log().comment(f'split first word = name ({i - first.start})')
|
log().comment(f'split first word = name ({i - first.start})')
|
||||||
yield dataclasses.replace(base, name=name, penalty=penalty,
|
yield dataclasses.replace(base, name=name, penalty=penalty,
|
||||||
address=[addr] + base.address[1:])
|
address=[addr] + base.address[1:])
|
||||||
@@ -321,9 +324,12 @@ class _TokenSequence:
|
|||||||
last = base.address[-1]
|
last = base.address[-1]
|
||||||
if (not base.housenumber or last.start <= base.housenumber.end)\
|
if (not base.housenumber or last.start <= base.housenumber.end)\
|
||||||
and (not base.qualifier or last.end <= base.qualifier.start):
|
and (not base.qualifier or last.end <= base.qualifier.start):
|
||||||
|
base_penalty = self.penalty
|
||||||
|
if base.housenumber and base.housenumber.start < last.start:
|
||||||
|
base_penalty += 0.4
|
||||||
for i in range(last.start + 1, last.end):
|
for i in range(last.start + 1, last.end):
|
||||||
addr, name = last.split(i)
|
addr, name = last.split(i)
|
||||||
penalty = self.penalty + PENALTY_TOKENCHANGE[query.nodes[i].btype]
|
penalty = base_penalty + PENALTY_TOKENCHANGE[query.nodes[i].btype]
|
||||||
log().comment(f'split last word = name ({i - last.start})')
|
log().comment(f'split last word = name ({i - last.start})')
|
||||||
yield dataclasses.replace(base, name=name, penalty=penalty,
|
yield dataclasses.replace(base, name=name, penalty=penalty,
|
||||||
address=base.address[:-1] + [addr])
|
address=base.address[:-1] + [addr])
|
||||||
|
|||||||
Reference in New Issue
Block a user