From: Sarah Hoffmann Date: Sat, 12 Aug 2023 13:33:50 +0000 (+0200) Subject: take token_assignment penalty into account X-Git-Tag: v4.3.0~32 X-Git-Url: https://git.openstreetmap.org/nominatim.git/commitdiff_plain/95d104878957b8efe2edf5b7971ee6d522b60c6d?hp=38b2b8a1439412be964112b5982a196eaee39663 take token_assignment penalty into account Also computes the expected count differently when addresses are involved. Address token counts do not bare a direct relation to real counts. --- diff --git a/nominatim/api/search/db_search_builder.py b/nominatim/api/search/db_search_builder.py index 8dd435d0..3ed66a42 100644 --- a/nominatim/api/search/db_search_builder.py +++ b/nominatim/api/search/db_search_builder.py @@ -111,9 +111,11 @@ class SearchBuilder: penalty = min(categories.penalties) categories.penalties = [p - penalty for p in categories.penalties] for search in builder: - yield dbs.NearSearch(penalty, categories, search) + yield dbs.NearSearch(penalty + assignment.penalty, categories, search) else: - yield from builder + for search in builder: + search.penalty += assignment.penalty + yield search def build_poi_search(self, sdata: dbf.SearchData) -> Iterator[dbs.AbstractSearch]: @@ -210,8 +212,7 @@ class SearchBuilder: yield penalty, exp_count, dbf.lookup_by_names(name_tokens, addr_tokens) return - exp_count = min(exp_count, min(t.count for t in addr_partials)) \ - if addr_partials else exp_count + exp_count = exp_count / (2**len(addr_partials)) if addr_partials else exp_count # Partial term to frequent. Try looking up by rare full names first. name_fulls = self.query.get_tokens(name, TokenType.WORD)