mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Better handle intentional omissions for swipe
This commit is contained in:
parent
db3542090d
commit
a0cb585ef6
@ -168,7 +168,15 @@ public:
|
|||||||
float totalDistance = distance * distance;
|
float totalDistance = distance * distance;
|
||||||
|
|
||||||
if(parentDicNode != nullptr) {
|
if(parentDicNode != nullptr) {
|
||||||
const int codePoint0 = parentDicNode->getNodeCodePoint();
|
|
||||||
|
int codePoint0;
|
||||||
|
if(parentDicNode->isZeroCostOmission() || parentDicNode->canBeIntentionalOmission()) {
|
||||||
|
codePoint0 = parentDicNode->getPrevCodePointG(0);
|
||||||
|
} else {
|
||||||
|
codePoint0 = parentDicNode->getNodeCodePoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(codePoint0 != NOT_A_CODE_POINT) {
|
||||||
const int codePoint1 = codePoint;
|
const int codePoint1 = codePoint;
|
||||||
|
|
||||||
const int lowerLimit = dicNode->getInputIndex(0);
|
const int lowerLimit = dicNode->getInputIndex(0);
|
||||||
@ -180,6 +188,9 @@ public:
|
|||||||
traverseSession, codePoint0, codePoint1, lowerLimit, upperLimit, threshold);
|
traverseSession, codePoint0, codePoint1, lowerLimit, upperLimit, threshold);
|
||||||
|
|
||||||
totalDistance += extraDistance;
|
totalDistance += extraDistance;
|
||||||
|
} else {
|
||||||
|
totalDistance += MAX_VALUE_FOR_WEIGHTING;
|
||||||
|
}
|
||||||
|
|
||||||
//AKLOGI("Terminal spatial for %c:%c - %d:%d : extra %.2f %.2f", (char)codePoint0, (char)codePoint1, lowerLimit, upperLimit, distance, extraDistance);
|
//AKLOGI("Terminal spatial for %c:%c - %d:%d : extra %.2f %.2f", (char)codePoint0, (char)codePoint1, lowerLimit, upperLimit, distance, extraDistance);
|
||||||
//dicNode->dump("TERMINAL");
|
//dicNode->dump("TERMINAL");
|
||||||
@ -219,12 +230,30 @@ public:
|
|||||||
inputStateG->mNeedsToUpdateInputStateG = true;
|
inputStateG->mNeedsToUpdateInputStateG = true;
|
||||||
inputStateG->mInputIndex = 1;
|
inputStateG->mInputIndex = 1;
|
||||||
inputStateG->mRawLength = distance;
|
inputStateG->mRawLength = distance;
|
||||||
|
inputStateG->mPrevCodePoint = NOT_A_CODE_POINT;
|
||||||
|
|
||||||
return distance;
|
return distance;
|
||||||
} else {
|
} else {
|
||||||
return MAX_VALUE_FOR_WEIGHTING;
|
return MAX_VALUE_FOR_WEIGHTING;
|
||||||
}
|
}
|
||||||
} else if((parentDicNode != nullptr && parentDicNode->getNodeCodePoint() == codePoint) || dicNode->isZeroCostOmission() || dicNode->canBeIntentionalOmission()) {
|
} else if(parentDicNode != nullptr && parentDicNode->getNodeCodePoint() == codePoint) {
|
||||||
|
inputStateG->mNeedsToUpdateInputStateG = true;
|
||||||
|
inputStateG->mInputIndex = dicNode->getInputIndex(0);
|
||||||
|
inputStateG->mRawLength = 0.0f;
|
||||||
|
inputStateG->mPrevCodePoint = parentDicNode->getPrevCodePointG(0);
|
||||||
|
|
||||||
|
return 0.0f;
|
||||||
|
} else if(dicNode->isZeroCostOmission() || dicNode->canBeIntentionalOmission()) {
|
||||||
|
inputStateG->mNeedsToUpdateInputStateG = true;
|
||||||
|
inputStateG->mInputIndex = dicNode->getInputIndex(0);
|
||||||
|
inputStateG->mRawLength = 0.0f;
|
||||||
|
|
||||||
|
if(parentDicNode != nullptr) {
|
||||||
|
inputStateG->mPrevCodePoint = parentDicNode->getNodeCodePoint();
|
||||||
|
} else {
|
||||||
|
inputStateG->mPrevCodePoint = NOT_A_CODE_POINT;
|
||||||
|
}
|
||||||
|
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
} else { // Add middle points
|
} else { // Add middle points
|
||||||
const int inputIndex = dicNode->getInputIndex(0);
|
const int inputIndex = dicNode->getInputIndex(0);
|
||||||
@ -260,7 +289,14 @@ public:
|
|||||||
if(found && parentDicNode != nullptr && minEdgeDistance < MAX_VALUE_FOR_WEIGHTING) {
|
if(found && parentDicNode != nullptr && minEdgeDistance < MAX_VALUE_FOR_WEIGHTING) {
|
||||||
float totalDistance = 24.0f * pow(minEdgeDistance, 1.6f);
|
float totalDistance = 24.0f * pow(minEdgeDistance, 1.6f);
|
||||||
|
|
||||||
const int codePoint0 = parentDicNode->getNodeCodePoint();
|
int codePoint0;
|
||||||
|
if(parentDicNode->isZeroCostOmission() || parentDicNode->canBeIntentionalOmission()) {
|
||||||
|
codePoint0 = parentDicNode->getPrevCodePointG(0);
|
||||||
|
} else {
|
||||||
|
codePoint0 = parentDicNode->getNodeCodePoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(codePoint0 != NOT_A_CODE_POINT) {
|
||||||
const int codePoint1 = codePoint;
|
const int codePoint1 = codePoint;
|
||||||
|
|
||||||
const int lowerLimit = inputIndex;
|
const int lowerLimit = inputIndex;
|
||||||
@ -269,7 +305,8 @@ public:
|
|||||||
const float threshold = (distanceThreshold * 86.0f);
|
const float threshold = (distanceThreshold * 86.0f);
|
||||||
|
|
||||||
const float punishment = util::calcLineDeviationPunishment(
|
const float punishment = util::calcLineDeviationPunishment(
|
||||||
traverseSession, codePoint0, codePoint1, lowerLimit, upperLimit, threshold);
|
traverseSession, codePoint0, codePoint1, lowerLimit, upperLimit,
|
||||||
|
threshold);
|
||||||
|
|
||||||
if (punishment >= MAX_VALUE_FOR_WEIGHTING) {
|
if (punishment >= MAX_VALUE_FOR_WEIGHTING) {
|
||||||
//AKLOGI("Culled due to too large distance (%.2f, %.2f)", totalDistance, punishment);
|
//AKLOGI("Culled due to too large distance (%.2f, %.2f)", totalDistance, punishment);
|
||||||
@ -278,10 +315,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
totalDistance += punishment;
|
totalDistance += punishment;
|
||||||
|
}
|
||||||
|
|
||||||
inputStateG->mNeedsToUpdateInputStateG = true;
|
inputStateG->mNeedsToUpdateInputStateG = true;
|
||||||
inputStateG->mInputIndex = minEdgeIndex;
|
inputStateG->mInputIndex = minEdgeIndex;
|
||||||
inputStateG->mRawLength = totalDistance;
|
inputStateG->mRawLength = totalDistance;
|
||||||
|
inputStateG->mPrevCodePoint = codePoint0;
|
||||||
|
|
||||||
return totalDistance;
|
return totalDistance;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user