dongyuwei / hallelujahIM

hallelujahIM(哈利路亚 英文输入法) is an intelligent English input method with auto-suggestions and spell check features.
GNU General Public License v3.0
2.22k stars 118 forks source link

fix: frequency value overflow #141

Closed xianfeng-zhu closed 1 year ago

xianfeng-zhu commented 1 year ago

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 with in*. While comparing the word 'in' with other words which have much lower frequency, the result might be a greater value than the capacity of int n, because the frequency of the word 'in' is 8469404971, 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.

dongyuwei commented 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?

dongyuwei commented 1 year ago

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.

xianfeng-zhu commented 1 year ago

test added, please review it

dongyuwei commented 1 year ago

Thanks for your contribution! A 9 years bug fixed now.

dongyuwei commented 1 year ago

Ci also fixed now.