]> git.openstreetmap.org Git - nominatim.git/commitdiff
add penalty for single words that look like stop words
authorSarah Hoffmann <lonvia@denofr.de>
Sat, 16 Mar 2024 10:26:00 +0000 (11:26 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 18 Mar 2024 10:25:48 +0000 (11:25 +0100)
nominatim/api/search/db_search_builder.py

index ef7a66b8507387630c6d0aacc5bfb2b67a08b566..f8eabad1497c189f23e8c52d8e68ddacd12c10ef 100644 (file)
@@ -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: