Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 830ba674 authored by Satoshi Kataoka's avatar Satoshi Kataoka
Browse files

refactor MAX_POINT_TO_KEY_LENGTH

Change-Id: I3b44068bce784531516f3cdfe67b3b46b1f1b805
parent d8708911
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
    }

+3 −2
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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
+2 −2
Original line number Diff line number Diff line
@@ -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
+3 −3
Original line number Diff line number Diff line
@@ -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) {
Loading