diff options
Diffstat (limited to 'native/jni/src')
-rw-r--r-- | native/jni/src/correction.cpp | 10 | ||||
-rw-r--r-- | native/jni/src/correction.h | 2 | ||||
-rw-r--r-- | native/jni/src/defines.h | 10 | ||||
-rw-r--r-- | native/jni/src/unigram_dictionary.cpp | 10 | ||||
-rw-r--r-- | native/jni/src/words_priority_queue.h | 8 |
5 files changed, 20 insertions, 20 deletions
diff --git a/native/jni/src/correction.cpp b/native/jni/src/correction.cpp index a1f812909..5ae34cd02 100644 --- a/native/jni/src/correction.cpp +++ b/native/jni/src/correction.cpp @@ -1113,7 +1113,7 @@ int Correction::RankingAlgorithm::editDistance(const unsigned short* before, // So, we can normalize original score by dividing pow(2, min(b.l(),a.l())) * 255 * 2. /* static */ -double Correction::RankingAlgorithm::calcNormalizedScore(const unsigned short* before, +float Correction::RankingAlgorithm::calcNormalizedScore(const unsigned short* before, const int beforeLength, const unsigned short* after, const int afterLength, const int score) { if (0 == beforeLength || 0 == afterLength) { @@ -1131,14 +1131,14 @@ double Correction::RankingAlgorithm::calcNormalizedScore(const unsigned short* b return 0; } - const double maxScore = score >= S_INT_MAX ? S_INT_MAX : MAX_INITIAL_SCORE - * pow((double)TYPED_LETTER_MULTIPLIER, - (double)min(beforeLength, afterLength - spaceCount)) * FULL_WORD_MULTIPLIER; + const float maxScore = score >= S_INT_MAX ? S_INT_MAX : MAX_INITIAL_SCORE + * pow((float)TYPED_LETTER_MULTIPLIER, + (float)min(beforeLength, afterLength - spaceCount)) * FULL_WORD_MULTIPLIER; // add a weight based on edit distance. // distance <= max(afterLength, beforeLength) == afterLength, // so, 0 <= distance / afterLength <= 1 - const double weight = 1.0 - (double) distance / afterLength; + const float weight = 1.0 - (float) distance / afterLength; return (score / maxScore) * weight; } diff --git a/native/jni/src/correction.h b/native/jni/src/correction.h index 1b4e4bf4e..1ac4b8782 100644 --- a/native/jni/src/correction.h +++ b/native/jni/src/correction.h @@ -162,7 +162,7 @@ class Correction { static int calcFreqForSplitMultipleWords(const int *freqArray, const int *wordLengthArray, const int wordCount, const Correction* correction, const bool isSpaceProximity, const unsigned short *word); - static double calcNormalizedScore(const unsigned short* before, const int beforeLength, + static float calcNormalizedScore(const unsigned short* before, const int beforeLength, const unsigned short* after, const int afterLength, const int score); static int editDistance(const unsigned short* before, const int beforeLength, const unsigned short* after, const int afterLength); diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h index cb3dbb115..c6ad66abe 100644 --- a/native/jni/src/defines.h +++ b/native/jni/src/defines.h @@ -46,8 +46,8 @@ static inline void dumpWord(const unsigned short* word, const int length) { #include <time.h> #define PROF_BUF_SIZE 100 -static double profile_buf[PROF_BUF_SIZE]; -static double profile_old[PROF_BUF_SIZE]; +static float profile_buf[PROF_BUF_SIZE]; +static float profile_old[PROF_BUF_SIZE]; static unsigned int profile_counter[PROF_BUF_SIZE]; #define PROF_RESET prof_reset() @@ -74,8 +74,8 @@ static inline void prof_out(void) { AKLOGI("Error: You must call PROF_OPEN before PROF_CLOSE."); } AKLOGI("Total time is %6.3f ms.", - profile_buf[PROF_BUF_SIZE - 1] * 1000 / (double)CLOCKS_PER_SEC); - double all = 0; + profile_buf[PROF_BUF_SIZE - 1] * 1000 / (float)CLOCKS_PER_SEC); + float all = 0; for (int i = 0; i < PROF_BUF_SIZE - 1; ++i) { all += profile_buf[i]; } @@ -84,7 +84,7 @@ static inline void prof_out(void) { if (profile_buf[i] != 0) { AKLOGI("(%d): Used %4.2f%%, %8.4f ms. Called %d times.", i, (profile_buf[i] * 100 / all), - profile_buf[i] * 1000 / (double)CLOCKS_PER_SEC, profile_counter[i]); + profile_buf[i] * 1000 / (float)CLOCKS_PER_SEC, profile_counter[i]); } } } diff --git a/native/jni/src/unigram_dictionary.cpp b/native/jni/src/unigram_dictionary.cpp index 43fe892be..ee8c49703 100644 --- a/native/jni/src/unigram_dictionary.cpp +++ b/native/jni/src/unigram_dictionary.cpp @@ -202,7 +202,7 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo, PROF_START(20); if (DEBUG_DICT) { - double ns = queuePool->getMasterQueue()->getHighestNormalizedScore( + float ns = queuePool->getMasterQueue()->getHighestNormalizedScore( proximityInfo->getPrimaryInputWord(), codesSize, 0, 0, 0); ns += 0; AKLOGI("Max normalized score = %f", ns); @@ -212,7 +212,7 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo, proximityInfo->getPrimaryInputWord(), codesSize, frequencies, outWords); if (DEBUG_DICT) { - double ns = queuePool->getMasterQueue()->getHighestNormalizedScore( + float ns = queuePool->getMasterQueue()->getHighestNormalizedScore( proximityInfo->getPrimaryInputWord(), codesSize, 0, 0, 0); ns += 0; AKLOGI("Returning %d words", suggestedWordsCount); @@ -255,7 +255,7 @@ void UnigramDictionary::getWordSuggestions(ProximityInfo *proximityInfo, bool hasAutoCorrectionCandidate = false; WordsPriorityQueue* masterQueue = queuePool->getMasterQueue(); if (masterQueue->size() > 0) { - double nsForMaster = masterQueue->getHighestNormalizedScore( + float nsForMaster = masterQueue->getHighestNormalizedScore( proximityInfo->getPrimaryInputWord(), inputLength, 0, 0, 0); hasAutoCorrectionCandidate = (nsForMaster > START_TWO_WORDS_CORRECTION_THRESHOLD); } @@ -284,7 +284,7 @@ void UnigramDictionary::getWordSuggestions(ProximityInfo *proximityInfo, const int score = sw->mScore; const unsigned short* word = sw->mWord; const int wordLength = sw->mWordLength; - double ns = Correction::RankingAlgorithm::calcNormalizedScore( + float ns = Correction::RankingAlgorithm::calcNormalizedScore( proximityInfo->getPrimaryInputWord(), i, word, wordLength, score); ns += 0; AKLOGI("--- TOP SUB WORDS for %d --- %d %f [%d]", i, score, ns, @@ -452,7 +452,7 @@ bool UnigramDictionary::getSubStringSuggestion( return false; } int score = 0; - const double ns = queue->getHighestNormalizedScore( + const float ns = queue->getHighestNormalizedScore( proximityInfo->getPrimaryInputWord(), inputWordLength, &tempOutputWord, &score, &nextWordLength); if (DEBUG_DICT) { diff --git a/native/jni/src/words_priority_queue.h b/native/jni/src/words_priority_queue.h index 1387267a0..7629251d6 100644 --- a/native/jni/src/words_priority_queue.h +++ b/native/jni/src/words_priority_queue.h @@ -112,13 +112,13 @@ class WordsPriorityQueue { if (size >= 2) { SuggestedWord* nsMaxSw = 0; unsigned int maxIndex = 0; - double maxNs = 0; + float maxNs = 0; for (unsigned int i = 0; i < size; ++i) { SuggestedWord* tempSw = swBuffer[i]; if (!tempSw) { continue; } - const double tempNs = getNormalizedScore(tempSw, before, beforeLength, 0, 0, 0); + const float tempNs = getNormalizedScore(tempSw, before, beforeLength, 0, 0, 0); if (tempNs >= maxNs) { maxNs = tempNs; maxIndex = i; @@ -172,7 +172,7 @@ class WordsPriorityQueue { DUMP_WORD(mHighestSuggestedWord->mWord, mHighestSuggestedWord->mWordLength); } - double getHighestNormalizedScore(const unsigned short* before, const int beforeLength, + float getHighestNormalizedScore(const unsigned short* before, const int beforeLength, unsigned short** outWord, int *outScore, int *outLength) { if (!mHighestSuggestedWord) { return 0.0; @@ -199,7 +199,7 @@ class WordsPriorityQueue { return 0; } - static double getNormalizedScore(SuggestedWord* sw, const unsigned short* before, + static float getNormalizedScore(SuggestedWord* sw, const unsigned short* before, const int beforeLength, unsigned short** outWord, int *outScore, int *outLength) { const int score = sw->mScore; unsigned short* word = sw->mWord; |