am 24025135: Merge "Allow force auto commit when the top is long multiword."
* commit '24025135562791d3f569e39509425b4c9624e310': Allow force auto commit when the top is long multiword.main
commit
4ee4486803
|
@ -45,7 +45,7 @@ class Traversal {
|
||||||
const DicNode *const dicNode) const = 0;
|
const DicNode *const dicNode) const = 0;
|
||||||
virtual bool needsToTraverseAllUserInput() const = 0;
|
virtual bool needsToTraverseAllUserInput() const = 0;
|
||||||
virtual float getMaxSpatialDistance() const = 0;
|
virtual float getMaxSpatialDistance() const = 0;
|
||||||
virtual bool allowPartialCommit() const = 0;
|
virtual bool autoCorrectsToMultiWordSuggestionIfTop() const = 0;
|
||||||
virtual int getDefaultExpandDicNodeSize() const = 0;
|
virtual int getDefaultExpandDicNodeSize() const = 0;
|
||||||
virtual int getMaxCacheSize() const = 0;
|
virtual int getMaxCacheSize() const = 0;
|
||||||
virtual bool isPossibleOmissionChildNode(const DicTraverseSession *const traverseSession,
|
virtual bool isPossibleOmissionChildNode(const DicTraverseSession *const traverseSession,
|
||||||
|
|
|
@ -85,9 +85,9 @@ void Suggest::initializeSearch(DicTraverseSession *traverseSession, int commitPo
|
||||||
if (!traverseSession->getProximityInfoState(0)->isUsed()) {
|
if (!traverseSession->getProximityInfoState(0)->isUsed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (TRAVERSAL->allowPartialCommit()) {
|
|
||||||
|
// Never auto partial commit for now.
|
||||||
commitPoint = 0;
|
commitPoint = 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (traverseSession->getInputSize() > MIN_CONTINUOUS_SUGGESTION_INPUT_SIZE
|
if (traverseSession->getInputSize() > MIN_CONTINUOUS_SUGGESTION_INPUT_SIZE
|
||||||
&& traverseSession->isContinuousSuggestionPossible()) {
|
&& traverseSession->isContinuousSuggestionPossible()) {
|
||||||
|
@ -151,6 +151,17 @@ int Suggest::outputSuggestions(DicTraverseSession *traverseSession, int *frequen
|
||||||
int maxScore = S_INT_MIN;
|
int maxScore = S_INT_MIN;
|
||||||
int bestExactMatchedNodeTerminalIndex = -1;
|
int bestExactMatchedNodeTerminalIndex = -1;
|
||||||
int bestExactMatchedNodeOutputWordIndex = -1;
|
int bestExactMatchedNodeOutputWordIndex = -1;
|
||||||
|
// Force autocorrection for obvious long multi-word suggestions when the top suggestion is
|
||||||
|
// a long multiple words suggestion.
|
||||||
|
// TODO: Implement a smarter auto-commit method for handling multi-word suggestions.
|
||||||
|
// traverseSession->isPartiallyCommited() always returns false because we never auto partial
|
||||||
|
// commit for now.
|
||||||
|
const bool forceCommitMultiWords = (terminalSize > 0) ?
|
||||||
|
TRAVERSAL->autoCorrectsToMultiWordSuggestionIfTop()
|
||||||
|
&& (traverseSession->isPartiallyCommited()
|
||||||
|
|| (traverseSession->getInputSize()
|
||||||
|
>= MIN_LEN_FOR_MULTI_WORD_AUTOCORRECT
|
||||||
|
&& terminals[0].hasMultipleWords())) : false;
|
||||||
// Output suggestion results here
|
// Output suggestion results here
|
||||||
for (int terminalIndex = 0; terminalIndex < terminalSize && outputWordIndex < MAX_RESULTS;
|
for (int terminalIndex = 0; terminalIndex < terminalSize && outputWordIndex < MAX_RESULTS;
|
||||||
++terminalIndex) {
|
++terminalIndex) {
|
||||||
|
@ -180,23 +191,17 @@ int Suggest::outputSuggestions(DicTraverseSession *traverseSession, int *frequen
|
||||||
|
|
||||||
// Increase output score of top typing suggestion to ensure autocorrection.
|
// Increase output score of top typing suggestion to ensure autocorrection.
|
||||||
// TODO: Better integration with java side autocorrection logic.
|
// TODO: Better integration with java side autocorrection logic.
|
||||||
// Force autocorrection for obvious long multi-word suggestions.
|
|
||||||
const bool isForceCommitMultiWords = TRAVERSAL->allowPartialCommit()
|
|
||||||
&& (traverseSession->isPartiallyCommited()
|
|
||||||
|| (traverseSession->getInputSize() >= MIN_LEN_FOR_MULTI_WORD_AUTOCORRECT
|
|
||||||
&& terminalDicNode->hasMultipleWords()));
|
|
||||||
|
|
||||||
const int finalScore = SCORING->calculateFinalScore(
|
const int finalScore = SCORING->calculateFinalScore(
|
||||||
compoundDistance, traverseSession->getInputSize(),
|
compoundDistance, traverseSession->getInputSize(),
|
||||||
isForceCommitMultiWords || (isValidWord && SCORING->doesAutoCorrectValidWord()));
|
(forceCommitMultiWords && terminalDicNode->hasMultipleWords())
|
||||||
|
|| (isValidWord && SCORING->doesAutoCorrectValidWord()));
|
||||||
maxScore = max(maxScore, finalScore);
|
maxScore = max(maxScore, finalScore);
|
||||||
|
|
||||||
if (TRAVERSAL->allowPartialCommit()) {
|
// TODO: Implement a smarter auto-commit method for handling multi-word suggestions.
|
||||||
// Index for top typing suggestion should be 0.
|
// Index for top typing suggestion should be 0.
|
||||||
if (isValidWord && outputWordIndex == 0) {
|
if (isValidWord && outputWordIndex == 0) {
|
||||||
terminalDicNode->outputSpacePositionsResult(spaceIndices);
|
terminalDicNode->outputSpacePositionsResult(spaceIndices);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Don't output invalid words. However, we still need to submit their shortcuts if any.
|
// Don't output invalid words. However, we still need to submit their shortcuts if any.
|
||||||
if (isValidWord) {
|
if (isValidWord) {
|
||||||
|
|
|
@ -137,7 +137,7 @@ class TypingTraversal : public Traversal {
|
||||||
return ScoringParams::MAX_SPATIAL_DISTANCE;
|
return ScoringParams::MAX_SPATIAL_DISTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
AK_FORCE_INLINE bool allowPartialCommit() const {
|
AK_FORCE_INLINE bool autoCorrectsToMultiWordSuggestionIfTop() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue