minimum counts for tokens should always be 1

to avoid accidental devision by 0.
This commit is contained in:
Sarah Hoffmann 2024-04-01 14:25:51 +02:00
parent e53eb79923
commit 78c19bc006
2 changed files with 3 additions and 3 deletions

View 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))

View 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(),