Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
a0cb585e
Commit
a0cb585e
authored
10 months ago
by
Aleksandras Kostarevas
Browse files
Options
Downloads
Patches
Plain Diff
Better handle intentional omissions for swipe
parent
db354209
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
native/jni/src/suggest/policyimpl/gesture/swipe_weighting.h
+61
-22
61 additions, 22 deletions
native/jni/src/suggest/policyimpl/gesture/swipe_weighting.h
with
61 additions
and
22 deletions
native/jni/src/suggest/policyimpl/gesture/swipe_weighting.h
+
61
−
22
View file @
a0cb585e
...
...
@@ -168,18 +168,29 @@ public:
float
totalDistance
=
distance
*
distance
;
if
(
parentDicNode
!=
nullptr
)
{
const
int
codePoint0
=
parentDicNode
->
getNodeCodePoint
();
const
int
codePoint1
=
codePoint
;
const
int
lowerLimit
=
dicNode
->
getInputIndex
(
0
);
const
int
upperLimit
=
traverseSession
->
getInputSize
();
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
float
threshold
=
(
distanceThreshold
*
86.0
f
);
const
int
lowerLimit
=
dicNode
->
getInputIndex
(
0
);
const
int
upperLimit
=
traverseSession
->
getInputSize
();
const
float
extraDistance
=
8.0
f
*
util
::
calcLineDeviationPunishment
(
traverseSession
,
codePoint0
,
codePoint1
,
lowerLimit
,
upperLimit
,
threshold
);
const
float
threshold
=
(
distanceThreshold
*
86.0
f
);
totalDistance
+=
extraDistance
;
const
float
extraDistance
=
8.0
f
*
util
::
calcLineDeviationPunishment
(
traverseSession
,
codePoint0
,
codePoint1
,
lowerLimit
,
upperLimit
,
threshold
);
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);
//dicNode->dump("TERMINAL");
...
...
@@ -219,12 +230,30 @@ public:
inputStateG
->
mNeedsToUpdateInputStateG
=
true
;
inputStateG
->
mInputIndex
=
1
;
inputStateG
->
mRawLength
=
distance
;
inputStateG
->
mPrevCodePoint
=
NOT_A_CODE_POINT
;
return
distance
;
}
else
{
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.0
f
;
inputStateG
->
mPrevCodePoint
=
parentDicNode
->
getPrevCodePointG
(
0
);
return
0.0
f
;
}
else
if
(
dicNode
->
isZeroCostOmission
()
||
dicNode
->
canBeIntentionalOmission
())
{
inputStateG
->
mNeedsToUpdateInputStateG
=
true
;
inputStateG
->
mInputIndex
=
dicNode
->
getInputIndex
(
0
);
inputStateG
->
mRawLength
=
0.0
f
;
if
(
parentDicNode
!=
nullptr
)
{
inputStateG
->
mPrevCodePoint
=
parentDicNode
->
getNodeCodePoint
();
}
else
{
inputStateG
->
mPrevCodePoint
=
NOT_A_CODE_POINT
;
}
return
0.0
f
;
}
else
{
// Add middle points
const
int
inputIndex
=
dicNode
->
getInputIndex
(
0
);
...
...
@@ -260,28 +289,38 @@ public:
if
(
found
&&
parentDicNode
!=
nullptr
&&
minEdgeDistance
<
MAX_VALUE_FOR_WEIGHTING
)
{
float
totalDistance
=
24.0
f
*
pow
(
minEdgeDistance
,
1.6
f
);
const
int
codePoint0
=
parentDicNode
->
getNodeCodePoint
();
const
int
codePoint1
=
codePoint
;
int
codePoint0
;
if
(
parentDicNode
->
isZeroCostOmission
()
||
parentDicNode
->
canBeIntentionalOmission
())
{
codePoint0
=
parentDicNode
->
getPrevCodePointG
(
0
);
}
else
{
codePoint0
=
parentDicNode
->
getNodeCodePoint
();
}
const
int
lowerLimit
=
inputIndex
;
const
int
upperLimit
=
minEdgeIndex
;
if
(
codePoint0
!=
NOT_A_CODE_POINT
)
{
const
int
codePoint1
=
codePoint
;
const
float
threshold
=
(
distanceThreshold
*
86.0
f
);
const
int
lowerLimit
=
inputIndex
;
const
int
upperLimit
=
minEdgeIndex
;
const
float
punishment
=
util
::
calcLineDeviationPunishment
(
traverseSession
,
codePoint0
,
codePoint1
,
lowerLimit
,
upperLimit
,
threshold
);
const
float
threshold
=
(
distanceThreshold
*
86.0
f
);
if
(
punishment
>=
MAX_VALUE_FOR_WEIGHTING
)
{
//AKLOGI("Culled due to too large distance (%.2f, %.2f)", totalDistance, punishment);
//dicNode->dump("CULLED");
return
MAX_VALUE_FOR_WEIGHTING
;
}
const
float
punishment
=
util
::
calcLineDeviationPunishment
(
traverseSession
,
codePoint0
,
codePoint1
,
lowerLimit
,
upperLimit
,
threshold
);
totalDistance
+=
punishment
;
if
(
punishment
>=
MAX_VALUE_FOR_WEIGHTING
)
{
//AKLOGI("Culled due to too large distance (%.2f, %.2f)", totalDistance, punishment);
//dicNode->dump("CULLED");
return
MAX_VALUE_FOR_WEIGHTING
;
}
totalDistance
+=
punishment
;
}
inputStateG
->
mNeedsToUpdateInputStateG
=
true
;
inputStateG
->
mInputIndex
=
minEdgeIndex
;
inputStateG
->
mRawLength
=
totalDistance
;
inputStateG
->
mPrevCodePoint
=
codePoint0
;
return
totalDistance
;
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment