]> git.openstreetmap.org Git - nominatim.git/commitdiff
minimum counts for tokens should always be 1
authorSarah Hoffmann <lonvia@denofr.de>
Mon, 1 Apr 2024 12:25:51 +0000 (14:25 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 1 Apr 2024 12:25:51 +0000 (14:25 +0200)
to avoid accidental devision by 0.

nominatim/api/search/icu_tokenizer.py
nominatim/api/search/legacy_tokenizer.py

index 05ec7690c8ac0a34d8436fd08e641f4cb19bd680..eb90c122eb43277a18b2d71bf48eb9ab99a375ac 100644 (file)
@@ -122,10 +122,10 @@ class ICUToken(qmod.Token):
         else:
             lookup_word = row.word_token
 
-        return ICUToken(penalty=penalty, token=row.word_id, count=count,
+        return ICUToken(penalty=penalty, token=row.word_id, count=max(1, count),
                         lookup_word=lookup_word, is_indexed=True,
                         word_token=row.word_token, info=row.info,
-                        addr_count=addr_count)
+                        addr_count=max(1, addr_count))
 
 
 
index bd17706e5dff7c3fc5fd5f1d37eafe234fd809f1..031f2456c455d108c21e1ea14a048b9f6d396df2 100644 (file)
@@ -209,7 +209,7 @@ class LegacyQueryAnalyzer(AbstractQueryAnalyzer):
                 is_indexed = False
 
         return LegacyToken(penalty=penalty, token=row.word_id,
-                           count=row.search_name_count or 1,
+                           count=max(1, row.search_name_count or 1),
                            addr_count=1, # not supported
                            lookup_word=lookup_word,
                            word_token=row.word_token.strip(),