mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Ensure skipProbability is in range
This commit is contained in:
parent
09a6a30d8b
commit
edbb92114f
@ -634,7 +634,7 @@ namespace latinime {
|
|||||||
for (int j = 0; j < keyCount; ++j) {
|
for (int j = 0; j < keyCount; ++j) {
|
||||||
const float distance = getPointToKeyByIdLength(
|
const float distance = getPointToKeyByIdLength(
|
||||||
maxPointToKeyLength, sampledNormalizedSquaredLengthCache, keyCount, i, j);
|
maxPointToKeyLength, sampledNormalizedSquaredLengthCache, keyCount, i, j);
|
||||||
if (distance < nearestKeyDistance) {
|
if (distance < nearestKeyDistance && distance >= 0.0f) {
|
||||||
nearestKeyDistance = distance;
|
nearestKeyDistance = distance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -688,9 +688,15 @@ namespace latinime {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Figure out why sometimes it's less than 0.0f
|
||||||
// probabilities must be in [0.0, ProximityInfoParams::MAX_SKIP_PROBABILITY];
|
// probabilities must be in [0.0, ProximityInfoParams::MAX_SKIP_PROBABILITY];
|
||||||
ASSERT(skipProbability >= 0.0f);
|
if(skipProbability < 0.0f) {
|
||||||
ASSERT(skipProbability <= ProximityInfoParams::MAX_SKIP_PROBABILITY);
|
skipProbability = 0.0f;
|
||||||
|
} else if(skipProbability > ProximityInfoParams::MAX_SKIP_PROBABILITY) {
|
||||||
|
skipProbability = ProximityInfoParams::MAX_SKIP_PROBABILITY;
|
||||||
|
}
|
||||||
|
//ASSERT(skipProbability >= 0.0f);
|
||||||
|
//ASSERT(skipProbability <= ProximityInfoParams::MAX_SKIP_PROBABILITY);
|
||||||
(*charProbabilities)[i][NOT_AN_INDEX] = skipProbability;
|
(*charProbabilities)[i][NOT_AN_INDEX] = skipProbability;
|
||||||
|
|
||||||
// Second, calculates key probabilities by dividing the rest probability
|
// Second, calculates key probabilities by dividing the rest probability
|
||||||
|
Loading…
Reference in New Issue
Block a user