Closed xianfeng-zhu closed 1 year ago
Thanks for your PR. What about the unit tests(Currently the CI is not configured properly for PR)? Can you also add a new test case to cover the bug?
Recently I upgraded my Xcode, the build and test are okay locally, but they are broken in Github Actions CI. Need time to fix the CI.
test added, please review it
Thanks for your contribution! A 9 years bug fixed now.
Ci also fixed now.
Description
Most frequent words are ranked at last positions, like
in
,the
, etc.Bug
Int value overflow happened while using
int
to store the value of[dict1[@"frequency"] intValue] - [dict2[@"frequency"] intValue]
.For example, when typing
in
, there are many words (3K and more) starting within*
. While comparing the word 'in' with other words which have much lower frequency, the result might be a greater value than the capacity ofint n
, because the frequency of the word 'in' is8469404971
, which is quite large. This caused the word 'in' be ranked in the tail of the result list. Actually, the word 'in' should be the first one in the list.