am 830ba674: refactor MAX_POINT_TO_KEY_LENGTH

* commit '830ba67498c6da53b38212dd9ac5ba318a00de11':
  refactor MAX_POINT_TO_KEY_LENGTH
main
Satoshi Kataoka 2013-03-05 06:22:53 +00:00 committed by Android Git Automerger
commit ff745e9a8a
6 changed files with 11 additions and 10 deletions

View File

@ -119,7 +119,7 @@ class Correction {
// proximity info state
void initInputParams(const ProximityInfo *proximityInfo, const int *inputCodes,
const int inputSize, const int *xCoordinates, const int *yCoordinates) {
mProximityInfoState.initInputParams(0, MAX_POINT_TO_KEY_LENGTH,
mProximityInfoState.initInputParams(0, static_cast<float>(MAX_VALUE_FOR_WEIGHTING),
proximityInfo, inputCodes, inputSize, xCoordinates, yCoordinates, 0, 0, false);
}

View File

@ -341,8 +341,9 @@ static inline void prof_out(void) {
#define MAX_DEPTH_MULTIPLIER 3
#define FIRST_WORD_INDEX 0
// Max Distance between point to key
#define MAX_POINT_TO_KEY_LENGTH 10000000
// Max value for length, distance and probability which are used in weighting
// TODO: Remove
#define MAX_VALUE_FOR_WEIGHTING 10000000
// The max number of the keys in one keyboard layout
#define MAX_KEY_COUNT_IN_A_KEYBOARD 64

View File

@ -204,6 +204,6 @@ int ProximityInfo::getKeyKeyDistanceG(const int keyId0, const int keyId1) const
if (keyId0 >= 0 && keyId1 >= 0) {
return mKeyKeyDistancesG[keyId0][keyId1];
}
return MAX_POINT_TO_KEY_LENGTH;
return MAX_VALUE_FOR_WEIGHTING;
}
} // namespace latinime

View File

@ -170,7 +170,7 @@ float ProximityInfoState::getPointToKeyLength(
return 0.0f;
}
// If the char is not a key on the keyboard then return the max length.
return MAX_POINT_TO_KEY_LENGTH;
return static_cast<float>(MAX_VALUE_FOR_WEIGHTING);
}
float ProximityInfoState::getPointToKeyLength_G(const int inputIndex, const int codePoint) const {
@ -314,6 +314,6 @@ float ProximityInfoState::getProbability(const int index, const int keyIndex) co
if (it != mCharProbabilities[index].end()) {
return it->second;
}
return static_cast<float>(MAX_POINT_TO_KEY_LENGTH);
return static_cast<float>(MAX_VALUE_FOR_WEIGHTING);
}
} // namespace latinime

View File

@ -645,7 +645,7 @@ namespace latinime {
return min((*SampledDistanceCache_G)[index] * scale, maxPointToKeyLength);
}
// If the char is not a key on the keyboard then return the max length.
return static_cast<float>(MAX_POINT_TO_KEY_LENGTH);
return static_cast<float>(MAX_VALUE_FOR_WEIGHTING);
}
/* static */ float ProximityInfoStateUtils::getPointToKeyByIdLength(const float maxPointToKeyLength,
@ -678,7 +678,7 @@ namespace latinime {
const float currentAngle = getPointAngle(sampledInputXs, sampledInputYs, i);
const float speedRate = (*sampledSpeedRates)[i];
float nearestKeyDistance = static_cast<float>(MAX_POINT_TO_KEY_LENGTH);
float nearestKeyDistance = static_cast<float>(MAX_VALUE_FOR_WEIGHTING);
for (int j = 0; j < keyCount; ++j) {
if ((*SampledNearKeySets)[i].test(j)) {
const float distance = getPointToKeyByIdLength(
@ -1016,7 +1016,7 @@ namespace latinime {
float sumLogProbability = 0.0f;
// TODO: Current implementation is greedy algorithm. DP would be efficient for many cases.
for (int i = 0; i < sampledInputSize && index < MAX_WORD_LENGTH - 1; ++i) {
float minLogProbability = static_cast<float>(MAX_POINT_TO_KEY_LENGTH);
float minLogProbability = static_cast<float>(MAX_VALUE_FOR_WEIGHTING);
int character = NOT_AN_INDEX;
for (hash_map_compat<int, float>::const_iterator it = (*charProbabilities)[i].begin();
it != (*charProbabilities)[i].end(); ++it) {

View File

@ -226,7 +226,7 @@ class ProximityInfoUtils {
const int *const keyYCoordinates, const int *const keyWidths, const int *keyHeights,
const int keyId, const int x, const int y) {
// NOT_A_ID is -1, but return whenever < 0 just in case
if (keyId < 0) return MAX_POINT_TO_KEY_LENGTH;
if (keyId < 0) return MAX_VALUE_FOR_WEIGHTING;
const int left = keyXCoordinates[keyId];
const int top = keyYCoordinates[keyId];
const int right = left + keyWidths[keyId];