From ff3230a7f3fcb314c22ab977fa014465ff274ec8 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sat, 16 Mar 2024 11:26:00 +0100 Subject: [PATCH] add penalty for single words that look like stop words --- nominatim/api/search/db_search_builder.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nominatim/api/search/db_search_builder.py b/nominatim/api/search/db_search_builder.py index ef7a66b8..f8eabad1 100644 --- a/nominatim/api/search/db_search_builder.py +++ b/nominatim/api/search/db_search_builder.py @@ -226,6 +226,8 @@ class SearchBuilder: name_fulls = self.query.get_tokens(name, TokenType.WORD) if name_fulls: fulls_count = sum(t.count for t in name_fulls) + if len(name_partials) == 1: + penalty += min(1, max(0, (exp_count - 50 * fulls_count) / (1000 * fulls_count))) # At this point drop unindexed partials from the address. # This might yield wrong results, nothing we can do about that. if not partials_indexed: -- 2.43.2