Skip to content

Commit

Permalink
minimum counts for tokens should always be 1
Browse files Browse the repository at this point in the history
to avoid accidental devision by 0.
  • Loading branch information
lonvia committed Apr 1, 2024
1 parent e53eb79 commit 78c19bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions nominatim/api/search/icu_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ def from_db_row(row: SaRow) -> 'ICUToken':
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))



Expand Down
2 changes: 1 addition & 1 deletion nominatim/api/search/legacy_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def make_token(self, row: SaRow) -> Tuple[LegacyToken, qmod.TokenType]:
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(),
Expand Down

0 comments on commit 78c19bc

Please sign in to comment.