diff options
author | 2012-09-04 12:49:46 +0900 | |
---|---|---|
committer | 2012-09-04 14:23:37 +0900 | |
commit | f2789819bd005b5b0581e8439601b5501306327d (patch) | |
tree | a293e9aab8c0d097996e681cc86172f84caf37eb /native/jni/src/correction.cpp | |
parent | 1a397ececf88f2daffa103f8411aa9cbaabb50da (diff) | |
download | latinime-f2789819bd005b5b0581e8439601b5501306327d.tar.gz latinime-f2789819bd005b5b0581e8439601b5501306327d.tar.xz latinime-f2789819bd005b5b0581e8439601b5501306327d.zip |
Cosmetic fixes and a bug fix in UnigramDictionary::testCharGroupForContinuedLikeness().
This change has actually been extracted from a change work in progress I4fe423834b8131fb122251892c98228a6e08ba25
Change-Id: I52568fa09da2ea22be7f8bfe9676b7cd73c31fa4
Diffstat (limited to 'native/jni/src/correction.cpp')
-rw-r--r-- | native/jni/src/correction.cpp | 18 |
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 |