aboutsummaryrefslogtreecommitdiffstats
path: root/native/jni/src/correction.cpp
diff options
context:
space:
mode:
authorKen Wakasa <kwakasa@google.com>2012-09-03 22:26:42 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-03 22:26:42 -0700
commitd34dd5bb6bb01666171a37e9cefe46bb20d04e93 (patch)
tree622095ad7f31220916d09deee472c1a6246a7970 /native/jni/src/correction.cpp
parent2c0c1cc677b947521384c5b9bc2b7b0469929581 (diff)
parentf2789819bd005b5b0581e8439601b5501306327d (diff)
downloadlatinime-d34dd5bb6bb01666171a37e9cefe46bb20d04e93.tar.gz
latinime-d34dd5bb6bb01666171a37e9cefe46bb20d04e93.tar.xz
latinime-d34dd5bb6bb01666171a37e9cefe46bb20d04e93.zip
Merge "Cosmetic fixes and a bug fix in UnigramDictionary::testCharGroupForContinuedLikeness()." into jb-mr1-dev
Diffstat (limited to 'native/jni/src/correction.cpp')
-rw-r--r--native/jni/src/correction.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/native/jni/src/correction.cpp b/native/jni/src/correction.cpp
index 9ad65b09d..92cfd1a49 100644
--- a/native/jni/src/correction.cpp
+++ b/native/jni/src/correction.cpp
@@ -362,7 +362,8 @@ Correction::CorrectionType Correction::processCharAndCalcState(
if (mSkipPos >= 0) {
if (mSkippedCount == 0 && mSkipPos < mOutputIndex) {
if (DEBUG_DICT) {
- assert(mSkipPos == mOutputIndex - 1);
+ // TODO: Enable this assertion.
+ //assert(mSkipPos == mOutputIndex - 1);
}
mSkipPos = mOutputIndex;
}
@@ -630,7 +631,7 @@ Correction::CorrectionType Correction::processCharAndCalcState(
inline static int getQuoteCount(const unsigned short *word, const int length) {
int quoteCount = 0;
for (int i = 0; i < length; ++i) {
- if(word[i] == '\'') {
+ if (word[i] == '\'') {
++quoteCount;
}
}
@@ -936,7 +937,7 @@ int Correction::RankingAlgorithm::calcFreqForSplitMultipleWords(
int totalLength = 0;
int totalFreq = 0;
- for (int i = 0; i < wordCount; ++i){
+ for (int i = 0; i < wordCount; ++i) {
const int wordLength = wordLengthArray[i];
if (wordLength <= 0) {
return 0;
@@ -1126,15 +1127,16 @@ float Correction::RankingAlgorithm::calcNormalizedScore(const unsigned short *be
return 0;
}
- const float maxScore = score >= S_INT_MAX ? S_INT_MAX : MAX_INITIAL_SCORE
- * powf(static_cast<float>(TYPED_LETTER_MULTIPLIER),
- static_cast<float>(min(beforeLength, afterLength - spaceCount)))
- * FULL_WORD_MULTIPLIER;
+ const float maxScore = score >= S_INT_MAX ? static_cast<float>(S_INT_MAX)
+ : static_cast<float>(MAX_INITIAL_SCORE)
+ * powf(static_cast<float>(TYPED_LETTER_MULTIPLIER),
+ static_cast<float>(min(beforeLength, afterLength - spaceCount)))
+ * static_cast<float>(FULL_WORD_MULTIPLIER);
// 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);
- return (score / maxScore) * weight;
+ return (static_cast<float>(score) / maxScore) * weight;
}
} // namespace latinime