diff options
author | 2013-08-23 00:56:41 -0700 | |
---|---|---|
committer | 2013-08-23 00:56:41 -0700 | |
commit | 3a08074cb535eecdd70a0f8ad1ff7af78527a9e2 (patch) | |
tree | 630a65dea3e31e7db5871f7e0998a6f2edcbc5e9 | |
parent | 12263f1b24d388d64e24a38aa22f538aca82f660 (diff) | |
parent | 02833d11c3191282b7a05bca4e9f19a7b036980e (diff) | |
download | latinime-3a08074cb535eecdd70a0f8ad1ff7af78527a9e2.tar.gz latinime-3a08074cb535eecdd70a0f8ad1ff7af78527a9e2.tar.xz latinime-3a08074cb535eecdd70a0f8ad1ff7af78527a9e2.zip |
am 02833d11: Fix the autocorrection normalized score calculation
* commit '02833d11c3191282b7a05bca4e9f19a7b036980e':
Fix the autocorrection normalized score calculation
-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... |