am 0028ed36: Use "float" instead of "double"

* commit '0028ed3627ff4f37a62a80f3b2c857e373cd5090':
  Use "float" instead of "double"
main
satok 2012-05-16 05:04:46 -07:00 committed by Android Git Automerger
commit ac067f2db7
12 changed files with 49 additions and 48 deletions

View File

@ -18,6 +18,7 @@ package com.android.inputmethod.keyboard;
import android.graphics.Rect; import android.graphics.Rect;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.FloatMath;
import com.android.inputmethod.keyboard.Keyboard.Params.TouchPositionCorrection; import com.android.inputmethod.keyboard.Keyboard.Params.TouchPositionCorrection;
import com.android.inputmethod.latin.JniUtils; import com.android.inputmethod.latin.JniUtils;
@ -147,7 +148,7 @@ public class ProximityInfo {
final float radius = touchPositionCorrection.mRadii[row]; final float radius = touchPositionCorrection.mRadii[row];
sweetSpotCenterXs[i] = hitBoxCenterX + x * hitBoxWidth; sweetSpotCenterXs[i] = hitBoxCenterX + x * hitBoxWidth;
sweetSpotCenterYs[i] = hitBoxCenterY + y * hitBoxHeight; sweetSpotCenterYs[i] = hitBoxCenterY + y * hitBoxHeight;
sweetSpotRadii[i] = radius * (float) Math.sqrt( sweetSpotRadii[i] = radius * FloatMath.sqrt(
hitBoxWidth * hitBoxWidth + hitBoxHeight * hitBoxHeight); hitBoxWidth * hitBoxWidth + hitBoxHeight * hitBoxHeight);
} }
} }

View File

@ -35,7 +35,7 @@ public class AutoCorrection {
public static CharSequence computeAutoCorrectionWord( public static CharSequence computeAutoCorrectionWord(
HashMap<String, Dictionary> dictionaries, HashMap<String, Dictionary> dictionaries,
WordComposer wordComposer, ArrayList<SuggestedWordInfo> suggestions, WordComposer wordComposer, ArrayList<SuggestedWordInfo> suggestions,
CharSequence consideredWord, double autoCorrectionThreshold, CharSequence consideredWord, float autoCorrectionThreshold,
CharSequence whitelistedWord) { CharSequence whitelistedWord) {
if (hasAutoCorrectionForWhitelistedWord(whitelistedWord)) { if (hasAutoCorrectionForWhitelistedWord(whitelistedWord)) {
return whitelistedWord; return whitelistedWord;
@ -100,14 +100,14 @@ public class AutoCorrection {
private static boolean hasAutoCorrectionForBinaryDictionary(WordComposer wordComposer, private static boolean hasAutoCorrectionForBinaryDictionary(WordComposer wordComposer,
ArrayList<SuggestedWordInfo> suggestions, ArrayList<SuggestedWordInfo> suggestions,
CharSequence consideredWord, double autoCorrectionThreshold) { CharSequence consideredWord, float autoCorrectionThreshold) {
if (wordComposer.size() > 1 && suggestions.size() > 0) { if (wordComposer.size() > 1 && suggestions.size() > 0) {
final SuggestedWordInfo autoCorrectionSuggestion = suggestions.get(0); final SuggestedWordInfo autoCorrectionSuggestion = suggestions.get(0);
//final int autoCorrectionSuggestionScore = sortedScores[0]; //final int autoCorrectionSuggestionScore = sortedScores[0];
final int autoCorrectionSuggestionScore = autoCorrectionSuggestion.mScore; final int autoCorrectionSuggestionScore = autoCorrectionSuggestion.mScore;
// TODO: when the normalized score of the first suggestion is nearly equals to // TODO: when the normalized score of the first suggestion is nearly equals to
// the normalized score of the second suggestion, behave less aggressive. // the normalized score of the second suggestion, behave less aggressive.
final double normalizedScore = BinaryDictionary.calcNormalizedScore( final float normalizedScore = BinaryDictionary.calcNormalizedScore(
consideredWord.toString(), autoCorrectionSuggestion.mWord.toString(), consideredWord.toString(), autoCorrectionSuggestion.mWord.toString(),
autoCorrectionSuggestionScore); autoCorrectionSuggestionScore);
if (DBG) { if (DBG) {

View File

@ -92,7 +92,7 @@ public class BinaryDictionary extends Dictionary {
private native int getBigramsNative(long dict, int[] prevWord, int prevWordLength, private native int getBigramsNative(long dict, int[] prevWord, int prevWordLength,
int[] inputCodes, int inputCodesLength, char[] outputChars, int[] scores, int[] inputCodes, int inputCodesLength, char[] outputChars, int[] scores,
int maxWordLength, int maxBigrams); int maxWordLength, int maxBigrams);
private static native double calcNormalizedScoreNative( private static native float calcNormalizedScoreNative(
char[] before, int beforeLength, char[] after, int afterLength, int score); char[] before, int beforeLength, char[] after, int afterLength, int score);
private static native int editDistanceNative( private static native int editDistanceNative(
char[] before, int beforeLength, char[] after, int afterLength); char[] before, int beforeLength, char[] after, int afterLength);
@ -189,7 +189,7 @@ public class BinaryDictionary extends Dictionary {
prevWordCodePointArray, mUseFullEditDistance, outputChars, scores); prevWordCodePointArray, mUseFullEditDistance, outputChars, scores);
} }
public static double calcNormalizedScore(String before, String after, int score) { public static float calcNormalizedScore(String before, String after, int score) {
return calcNormalizedScoreNative(before.toCharArray(), before.length(), return calcNormalizedScoreNative(before.toCharArray(), before.length(),
after.toCharArray(), after.length(), score); after.toCharArray(), after.length(), score);
} }

View File

@ -77,7 +77,7 @@ public class SettingsValues {
public final float mFxVolume; public final float mFxVolume;
public final int mKeyPreviewPopupDismissDelay; public final int mKeyPreviewPopupDismissDelay;
public final boolean mAutoCorrectEnabled; public final boolean mAutoCorrectEnabled;
public final double mAutoCorrectionThreshold; public final float mAutoCorrectionThreshold;
private final boolean mVoiceKeyEnabled; private final boolean mVoiceKeyEnabled;
private final boolean mVoiceKeyOnMain; private final boolean mVoiceKeyOnMain;
@ -255,21 +255,21 @@ public class SettingsValues {
R.bool.config_default_next_word_prediction)); R.bool.config_default_next_word_prediction));
} }
private static double getAutoCorrectionThreshold(final Resources resources, private static float getAutoCorrectionThreshold(final Resources resources,
final String currentAutoCorrectionSetting) { final String currentAutoCorrectionSetting) {
final String[] autoCorrectionThresholdValues = resources.getStringArray( final String[] autoCorrectionThresholdValues = resources.getStringArray(
R.array.auto_correction_threshold_values); R.array.auto_correction_threshold_values);
// When autoCorrectionThreshold is greater than 1.0, it's like auto correction is off. // When autoCorrectionThreshold is greater than 1.0, it's like auto correction is off.
double autoCorrectionThreshold = Double.MAX_VALUE; float autoCorrectionThreshold = Float.MAX_VALUE;
try { try {
final int arrayIndex = Integer.valueOf(currentAutoCorrectionSetting); final int arrayIndex = Integer.valueOf(currentAutoCorrectionSetting);
if (arrayIndex >= 0 && arrayIndex < autoCorrectionThresholdValues.length) { if (arrayIndex >= 0 && arrayIndex < autoCorrectionThresholdValues.length) {
autoCorrectionThreshold = Double.parseDouble( autoCorrectionThreshold = Float.parseFloat(
autoCorrectionThresholdValues[arrayIndex]); autoCorrectionThresholdValues[arrayIndex]);
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
// Whenever the threshold settings are correct, never come here. // Whenever the threshold settings are correct, never come here.
autoCorrectionThreshold = Double.MAX_VALUE; autoCorrectionThreshold = Float.MAX_VALUE;
Log.w(TAG, "Cannot load auto correction threshold setting." Log.w(TAG, "Cannot load auto correction threshold setting."
+ " currentAutoCorrectionSetting: " + currentAutoCorrectionSetting + " currentAutoCorrectionSetting: " + currentAutoCorrectionSetting
+ ", autoCorrectionThresholdValues: " + ", autoCorrectionThresholdValues: "

View File

@ -77,7 +77,7 @@ public class Suggest implements Dictionary.WordCallback {
private static final int PREF_MAX_BIGRAMS = 60; private static final int PREF_MAX_BIGRAMS = 60;
private double mAutoCorrectionThreshold; private float mAutoCorrectionThreshold;
private ArrayList<SuggestedWordInfo> mSuggestions = new ArrayList<SuggestedWordInfo>(); private ArrayList<SuggestedWordInfo> mSuggestions = new ArrayList<SuggestedWordInfo>();
private ArrayList<SuggestedWordInfo> mBigramSuggestions = new ArrayList<SuggestedWordInfo>(); private ArrayList<SuggestedWordInfo> mBigramSuggestions = new ArrayList<SuggestedWordInfo>();
@ -185,7 +185,7 @@ public class Suggest implements Dictionary.WordCallback {
userHistoryDictionary); userHistoryDictionary);
} }
public void setAutoCorrectionThreshold(double threshold) { public void setAutoCorrectionThreshold(float threshold) {
mAutoCorrectionThreshold = threshold; mAutoCorrectionThreshold = threshold;
} }
@ -416,7 +416,7 @@ public class Suggest implements Dictionary.WordCallback {
// than i because we added the typed word to mSuggestions without touching mScores. // than i because we added the typed word to mSuggestions without touching mScores.
for (int i = 0; i < suggestionsSize - 1; ++i) { for (int i = 0; i < suggestionsSize - 1; ++i) {
final SuggestedWordInfo cur = suggestions.get(i + 1); final SuggestedWordInfo cur = suggestions.get(i + 1);
final double normalizedScore = BinaryDictionary.calcNormalizedScore( final float normalizedScore = BinaryDictionary.calcNormalizedScore(
typedWord, cur.toString(), cur.mScore); typedWord, cur.toString(), cur.mScore);
final String scoreInfoString; final String scoreInfoString;
if (normalizedScore > 0) { if (normalizedScore > 0) {

View File

@ -79,9 +79,9 @@ public class AndroidSpellCheckerService extends SpellCheckerService
private Dictionary mContactsDictionary; private Dictionary mContactsDictionary;
// The threshold for a candidate to be offered as a suggestion. // The threshold for a candidate to be offered as a suggestion.
private double mSuggestionThreshold; private float mSuggestionThreshold;
// The threshold for a suggestion to be considered "recommended". // The threshold for a suggestion to be considered "recommended".
private double mRecommendedThreshold; private float mRecommendedThreshold;
// Whether to use the contacts dictionary // Whether to use the contacts dictionary
private boolean mUseContactsDictionary; private boolean mUseContactsDictionary;
private final Object mUseContactsLock = new Object(); private final Object mUseContactsLock = new Object();
@ -113,9 +113,9 @@ public class AndroidSpellCheckerService extends SpellCheckerService
@Override public void onCreate() { @Override public void onCreate() {
super.onCreate(); super.onCreate();
mSuggestionThreshold = mSuggestionThreshold =
Double.parseDouble(getString(R.string.spellchecker_suggestion_threshold_value)); Float.parseFloat(getString(R.string.spellchecker_suggestion_threshold_value));
mRecommendedThreshold = mRecommendedThreshold =
Double.parseDouble(getString(R.string.spellchecker_recommended_threshold_value)); Float.parseFloat(getString(R.string.spellchecker_recommended_threshold_value));
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.registerOnSharedPreferenceChangeListener(this); prefs.registerOnSharedPreferenceChangeListener(this);
onSharedPreferenceChanged(prefs, PREF_USE_CONTACTS_KEY); onSharedPreferenceChanged(prefs, PREF_USE_CONTACTS_KEY);
@ -207,8 +207,8 @@ public class AndroidSpellCheckerService extends SpellCheckerService
private final ArrayList<CharSequence> mSuggestions; private final ArrayList<CharSequence> mSuggestions;
private final int[] mScores; private final int[] mScores;
private final String mOriginalText; private final String mOriginalText;
private final double mSuggestionThreshold; private final float mSuggestionThreshold;
private final double mRecommendedThreshold; private final float mRecommendedThreshold;
private final int mMaxLength; private final int mMaxLength;
private int mLength = 0; private int mLength = 0;
@ -217,8 +217,8 @@ public class AndroidSpellCheckerService extends SpellCheckerService
private String mBestSuggestion = null; private String mBestSuggestion = null;
private int mBestScore = Integer.MIN_VALUE; // As small as possible private int mBestScore = Integer.MIN_VALUE; // As small as possible
SuggestionsGatherer(final String originalText, final double suggestionThreshold, SuggestionsGatherer(final String originalText, final float suggestionThreshold,
final double recommendedThreshold, final int maxLength) { final float recommendedThreshold, final int maxLength) {
mOriginalText = originalText; mOriginalText = originalText;
mSuggestionThreshold = suggestionThreshold; mSuggestionThreshold = suggestionThreshold;
mRecommendedThreshold = recommendedThreshold; mRecommendedThreshold = recommendedThreshold;
@ -261,7 +261,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService
// Compute the normalized score and skip this word if it's normalized score does not // Compute the normalized score and skip this word if it's normalized score does not
// make the threshold. // make the threshold.
final String wordString = new String(word, wordOffset, wordLength); final String wordString = new String(word, wordOffset, wordLength);
final double normalizedScore = final float normalizedScore =
BinaryDictionary.calcNormalizedScore(mOriginalText, wordString, score); BinaryDictionary.calcNormalizedScore(mOriginalText, wordString, score);
if (normalizedScore < mSuggestionThreshold) { if (normalizedScore < mSuggestionThreshold) {
if (DBG) Log.i(TAG, wordString + " does not make the score threshold"); if (DBG) Log.i(TAG, wordString + " does not make the score threshold");
@ -295,7 +295,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService
hasRecommendedSuggestions = false; hasRecommendedSuggestions = false;
} else { } else {
gatheredSuggestions = EMPTY_STRING_ARRAY; gatheredSuggestions = EMPTY_STRING_ARRAY;
final double normalizedScore = BinaryDictionary.calcNormalizedScore( final float normalizedScore = BinaryDictionary.calcNormalizedScore(
mOriginalText, mBestSuggestion, mBestScore); mOriginalText, mBestSuggestion, mBestScore);
hasRecommendedSuggestions = (normalizedScore > mRecommendedThreshold); hasRecommendedSuggestions = (normalizedScore > mRecommendedThreshold);
} }
@ -329,7 +329,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService
final int bestScore = mScores[mLength - 1]; final int bestScore = mScores[mLength - 1];
final CharSequence bestSuggestion = mSuggestions.get(0); final CharSequence bestSuggestion = mSuggestions.get(0);
final double normalizedScore = final float normalizedScore =
BinaryDictionary.calcNormalizedScore( BinaryDictionary.calcNormalizedScore(
mOriginalText, bestSuggestion.toString(), bestScore); mOriginalText, bestSuggestion.toString(), bestScore);
hasRecommendedSuggestions = (normalizedScore > mRecommendedThreshold); hasRecommendedSuggestions = (normalizedScore > mRecommendedThreshold);

View File

@ -196,11 +196,11 @@ static jboolean latinime_BinaryDictionary_isValidBigram(JNIEnv *env, jobject obj
return result; return result;
} }
static jdouble latinime_BinaryDictionary_calcNormalizedScore(JNIEnv *env, jobject object, static jfloat latinime_BinaryDictionary_calcNormalizedScore(JNIEnv *env, jobject object,
jcharArray before, jint beforeLength, jcharArray after, jint afterLength, jint score) { jcharArray before, jint beforeLength, jcharArray after, jint afterLength, jint score) {
jchar *beforeChars = env->GetCharArrayElements(before, 0); jchar *beforeChars = env->GetCharArrayElements(before, 0);
jchar *afterChars = env->GetCharArrayElements(after, 0); jchar *afterChars = env->GetCharArrayElements(after, 0);
jdouble result = Correction::RankingAlgorithm::calcNormalizedScore((unsigned short*)beforeChars, jfloat result = Correction::RankingAlgorithm::calcNormalizedScore((unsigned short*)beforeChars,
beforeLength, (unsigned short*)afterChars, afterLength, score); beforeLength, (unsigned short*)afterChars, afterLength, score);
env->ReleaseCharArrayElements(after, afterChars, JNI_ABORT); env->ReleaseCharArrayElements(after, afterChars, JNI_ABORT);
env->ReleaseCharArrayElements(before, beforeChars, JNI_ABORT); env->ReleaseCharArrayElements(before, beforeChars, JNI_ABORT);
@ -255,7 +255,7 @@ static JNINativeMethod sMethods[] = {
{"isValidWordNative", "(J[II)Z", (void*)latinime_BinaryDictionary_isValidWord}, {"isValidWordNative", "(J[II)Z", (void*)latinime_BinaryDictionary_isValidWord},
{"isValidBigramNative", "(J[I[I)Z", (void*)latinime_BinaryDictionary_isValidBigram}, {"isValidBigramNative", "(J[I[I)Z", (void*)latinime_BinaryDictionary_isValidBigram},
{"getBigramsNative", "(J[II[II[C[III)I", (void*)latinime_BinaryDictionary_getBigrams}, {"getBigramsNative", "(J[II[II[C[III)I", (void*)latinime_BinaryDictionary_getBigrams},
{"calcNormalizedScoreNative", "([CI[CII)D", {"calcNormalizedScoreNative", "([CI[CII)F",
(void*)latinime_BinaryDictionary_calcNormalizedScore}, (void*)latinime_BinaryDictionary_calcNormalizedScore},
{"editDistanceNative", "([CI[CI)I", (void*)latinime_BinaryDictionary_editDistance} {"editDistanceNative", "([CI[CI)I", (void*)latinime_BinaryDictionary_editDistance}
}; };

View File

@ -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. // So, we can normalize original score by dividing pow(2, min(b.l(),a.l())) * 255 * 2.
/* static */ /* 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 beforeLength, const unsigned short* after, const int afterLength,
const int score) { const int score) {
if (0 == beforeLength || 0 == afterLength) { if (0 == beforeLength || 0 == afterLength) {
@ -1131,14 +1131,14 @@ double Correction::RankingAlgorithm::calcNormalizedScore(const unsigned short* b
return 0; return 0;
} }
const double maxScore = score >= S_INT_MAX ? S_INT_MAX : MAX_INITIAL_SCORE const float maxScore = score >= S_INT_MAX ? S_INT_MAX : MAX_INITIAL_SCORE
* pow((double)TYPED_LETTER_MULTIPLIER, * pow((float)TYPED_LETTER_MULTIPLIER,
(double)min(beforeLength, afterLength - spaceCount)) * FULL_WORD_MULTIPLIER; (float)min(beforeLength, afterLength - spaceCount)) * FULL_WORD_MULTIPLIER;
// add a weight based on edit distance. // add a weight based on edit distance.
// distance <= max(afterLength, beforeLength) == afterLength, // distance <= max(afterLength, beforeLength) == afterLength,
// so, 0 <= distance / afterLength <= 1 // 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; return (score / maxScore) * weight;
} }

View File

@ -162,7 +162,7 @@ class Correction {
static int calcFreqForSplitMultipleWords(const int *freqArray, const int *wordLengthArray, static int calcFreqForSplitMultipleWords(const int *freqArray, const int *wordLengthArray,
const int wordCount, const Correction* correction, const bool isSpaceProximity, const int wordCount, const Correction* correction, const bool isSpaceProximity,
const unsigned short *word); 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); const unsigned short* after, const int afterLength, const int score);
static int editDistance(const unsigned short* before, static int editDistance(const unsigned short* before,
const int beforeLength, const unsigned short* after, const int afterLength); const int beforeLength, const unsigned short* after, const int afterLength);

View File

@ -46,8 +46,8 @@ static inline void dumpWord(const unsigned short* word, const int length) {
#include <time.h> #include <time.h>
#define PROF_BUF_SIZE 100 #define PROF_BUF_SIZE 100
static double profile_buf[PROF_BUF_SIZE]; static float profile_buf[PROF_BUF_SIZE];
static double profile_old[PROF_BUF_SIZE]; static float profile_old[PROF_BUF_SIZE];
static unsigned int profile_counter[PROF_BUF_SIZE]; static unsigned int profile_counter[PROF_BUF_SIZE];
#define PROF_RESET prof_reset() #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("Error: You must call PROF_OPEN before PROF_CLOSE.");
} }
AKLOGI("Total time is %6.3f ms.", AKLOGI("Total time is %6.3f ms.",
profile_buf[PROF_BUF_SIZE - 1] * 1000 / (double)CLOCKS_PER_SEC); profile_buf[PROF_BUF_SIZE - 1] * 1000 / (float)CLOCKS_PER_SEC);
double all = 0; float all = 0;
for (int i = 0; i < PROF_BUF_SIZE - 1; ++i) { for (int i = 0; i < PROF_BUF_SIZE - 1; ++i) {
all += profile_buf[i]; all += profile_buf[i];
} }
@ -84,7 +84,7 @@ static inline void prof_out(void) {
if (profile_buf[i] != 0) { if (profile_buf[i] != 0) {
AKLOGI("(%d): Used %4.2f%%, %8.4f ms. Called %d times.", AKLOGI("(%d): Used %4.2f%%, %8.4f ms. Called %d times.",
i, (profile_buf[i] * 100 / all), 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]);
} }
} }
} }

View File

@ -202,7 +202,7 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo,
PROF_START(20); PROF_START(20);
if (DEBUG_DICT) { if (DEBUG_DICT) {
double ns = queuePool->getMasterQueue()->getHighestNormalizedScore( float ns = queuePool->getMasterQueue()->getHighestNormalizedScore(
proximityInfo->getPrimaryInputWord(), codesSize, 0, 0, 0); proximityInfo->getPrimaryInputWord(), codesSize, 0, 0, 0);
ns += 0; ns += 0;
AKLOGI("Max normalized score = %f", ns); AKLOGI("Max normalized score = %f", ns);
@ -212,7 +212,7 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo,
proximityInfo->getPrimaryInputWord(), codesSize, frequencies, outWords); proximityInfo->getPrimaryInputWord(), codesSize, frequencies, outWords);
if (DEBUG_DICT) { if (DEBUG_DICT) {
double ns = queuePool->getMasterQueue()->getHighestNormalizedScore( float ns = queuePool->getMasterQueue()->getHighestNormalizedScore(
proximityInfo->getPrimaryInputWord(), codesSize, 0, 0, 0); proximityInfo->getPrimaryInputWord(), codesSize, 0, 0, 0);
ns += 0; ns += 0;
AKLOGI("Returning %d words", suggestedWordsCount); AKLOGI("Returning %d words", suggestedWordsCount);
@ -255,7 +255,7 @@ void UnigramDictionary::getWordSuggestions(ProximityInfo *proximityInfo,
bool hasAutoCorrectionCandidate = false; bool hasAutoCorrectionCandidate = false;
WordsPriorityQueue* masterQueue = queuePool->getMasterQueue(); WordsPriorityQueue* masterQueue = queuePool->getMasterQueue();
if (masterQueue->size() > 0) { if (masterQueue->size() > 0) {
double nsForMaster = masterQueue->getHighestNormalizedScore( float nsForMaster = masterQueue->getHighestNormalizedScore(
proximityInfo->getPrimaryInputWord(), inputLength, 0, 0, 0); proximityInfo->getPrimaryInputWord(), inputLength, 0, 0, 0);
hasAutoCorrectionCandidate = (nsForMaster > START_TWO_WORDS_CORRECTION_THRESHOLD); hasAutoCorrectionCandidate = (nsForMaster > START_TWO_WORDS_CORRECTION_THRESHOLD);
} }
@ -284,7 +284,7 @@ void UnigramDictionary::getWordSuggestions(ProximityInfo *proximityInfo,
const int score = sw->mScore; const int score = sw->mScore;
const unsigned short* word = sw->mWord; const unsigned short* word = sw->mWord;
const int wordLength = sw->mWordLength; const int wordLength = sw->mWordLength;
double ns = Correction::RankingAlgorithm::calcNormalizedScore( float ns = Correction::RankingAlgorithm::calcNormalizedScore(
proximityInfo->getPrimaryInputWord(), i, word, wordLength, score); proximityInfo->getPrimaryInputWord(), i, word, wordLength, score);
ns += 0; ns += 0;
AKLOGI("--- TOP SUB WORDS for %d --- %d %f [%d]", i, score, ns, AKLOGI("--- TOP SUB WORDS for %d --- %d %f [%d]", i, score, ns,
@ -452,7 +452,7 @@ bool UnigramDictionary::getSubStringSuggestion(
return false; return false;
} }
int score = 0; int score = 0;
const double ns = queue->getHighestNormalizedScore( const float ns = queue->getHighestNormalizedScore(
proximityInfo->getPrimaryInputWord(), inputWordLength, proximityInfo->getPrimaryInputWord(), inputWordLength,
&tempOutputWord, &score, &nextWordLength); &tempOutputWord, &score, &nextWordLength);
if (DEBUG_DICT) { if (DEBUG_DICT) {

View File

@ -112,13 +112,13 @@ class WordsPriorityQueue {
if (size >= 2) { if (size >= 2) {
SuggestedWord* nsMaxSw = 0; SuggestedWord* nsMaxSw = 0;
unsigned int maxIndex = 0; unsigned int maxIndex = 0;
double maxNs = 0; float maxNs = 0;
for (unsigned int i = 0; i < size; ++i) { for (unsigned int i = 0; i < size; ++i) {
SuggestedWord* tempSw = swBuffer[i]; SuggestedWord* tempSw = swBuffer[i];
if (!tempSw) { if (!tempSw) {
continue; continue;
} }
const double tempNs = getNormalizedScore(tempSw, before, beforeLength, 0, 0, 0); const float tempNs = getNormalizedScore(tempSw, before, beforeLength, 0, 0, 0);
if (tempNs >= maxNs) { if (tempNs >= maxNs) {
maxNs = tempNs; maxNs = tempNs;
maxIndex = i; maxIndex = i;
@ -172,7 +172,7 @@ class WordsPriorityQueue {
DUMP_WORD(mHighestSuggestedWord->mWord, mHighestSuggestedWord->mWordLength); 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) { unsigned short** outWord, int *outScore, int *outLength) {
if (!mHighestSuggestedWord) { if (!mHighestSuggestedWord) {
return 0.0; return 0.0;
@ -199,7 +199,7 @@ class WordsPriorityQueue {
return 0; 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 beforeLength, unsigned short** outWord, int *outScore, int *outLength) {
const int score = sw->mScore; const int score = sw->mScore;
unsigned short* word = sw->mWord; unsigned short* word = sw->mWord;