diff options
author | 2013-08-23 14:32:24 +0900 | |
---|---|---|
committer | 2013-08-23 16:22:02 +0900 | |
commit | 02833d11c3191282b7a05bca4e9f19a7b036980e (patch) | |
tree | 53797f46d965c1e6827d755e49a290e81dd7d853 | |
parent | c02a365485cb777137cbab8ff8f60c4b36fa0f7a (diff) | |
download | latinime-02833d11c3191282b7a05bca4e9f19a7b036980e.tar.gz latinime-02833d11c3191282b7a05bca4e9f19a7b036980e.tar.xz latinime-02833d11c3191282b7a05bca4e9f19a7b036980e.zip |
Fix the autocorrection normalized score calculation
Bug: 10441240
Change-Id: I256021dc55481960d6a605046daa17b1a2d55b95
-rw-r--r-- | native/jni/src/utils/autocorrection_threshold_utils.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/native/jni/src/utils/autocorrection_threshold_utils.cpp b/native/jni/src/utils/autocorrection_threshold_utils.cpp index 3406e0f8e..1f8ee0814 100644 --- a/native/jni/src/utils/autocorrection_threshold_utils.cpp +++ b/native/jni/src/utils/autocorrection_threshold_utils.cpp @@ -83,9 +83,12 @@ const int AutocorrectionThresholdUtils::FULL_WORD_MULTIPLIER = 2; return 0.0f; } + if (score <= 0 || distance >= afterLength) { + // normalizedScore must be 0.0f (the minimum value) if the score is less than or equal to 0, + // or if the edit distance is larger than or equal to afterLength. + return 0.0f; + } // add a weight based on edit distance. - // distance <= max(afterLength, beforeLength) == afterLength, - // so, 0 <= distance / afterLength <= 1 const float weight = 1.0f - static_cast<float>(distance) / static_cast<float>(afterLength); // TODO: Revise the following logic thoroughly by referring to... |