Improve the double letter word promotion logic.
The old logic only checks the top 3 suggestions before the final adjustment. It leads to instability in scores. Bug: 10700674 Change-Id: I986aed2aefd66c1fba6196a8f100fcb5bc838a38
This commit is contained in:
parent
c2e2b3949b
commit
21e2380234
3 changed files with 6 additions and 22 deletions
|
@ -58,12 +58,6 @@ const int SuggestionsOutputUtils::MIN_LEN_FOR_MULTI_WORD_AUTOCORRECT = 16;
|
|||
++outputWordIndex;
|
||||
}
|
||||
|
||||
// Initial value of the loop index for terminal nodes (words)
|
||||
int doubleLetterTerminalIndex = -1;
|
||||
DoubleLetterLevel doubleLetterLevel = NOT_A_DOUBLE_LETTER;
|
||||
scoringPolicy->searchWordWithDoubleLetter(terminals, terminalSize,
|
||||
&doubleLetterTerminalIndex, &doubleLetterLevel);
|
||||
|
||||
int maxScore = S_INT_MIN;
|
||||
// Force autocorrection for obvious long multi-word suggestions when the top suggestion is
|
||||
// a long multiple words suggestion.
|
||||
|
@ -92,8 +86,8 @@ const int SuggestionsOutputUtils::MIN_LEN_FOR_MULTI_WORD_AUTOCORRECT = 16;
|
|||
if (DEBUG_GEO_FULL) {
|
||||
terminalDicNode->dump("OUT:");
|
||||
}
|
||||
const float doubleLetterCost = scoringPolicy->getDoubleLetterDemotionDistanceCost(
|
||||
terminalIndex, doubleLetterTerminalIndex, doubleLetterLevel);
|
||||
const float doubleLetterCost =
|
||||
scoringPolicy->getDoubleLetterDemotionDistanceCost(terminalDicNode);
|
||||
const float compoundDistance = terminalDicNode->getCompoundDistance(languageWeight)
|
||||
+ doubleLetterCost;
|
||||
const bool isPossiblyOffensiveWord =
|
||||
|
|
|
@ -34,14 +34,10 @@ class Scoring {
|
|||
int *const type, int *const freq) const = 0;
|
||||
virtual void safetyNetForMostProbableString(const int terminalSize,
|
||||
const int maxScore, int *const outputCodePoints, int *const frequencies) const = 0;
|
||||
// TODO: Make more generic
|
||||
virtual void searchWordWithDoubleLetter(DicNode *terminals, const int terminalSize,
|
||||
int *doubleLetterTerminalIndex, DoubleLetterLevel *doubleLetterLevel) const = 0;
|
||||
virtual float getAdjustedLanguageWeight(DicTraverseSession *const traverseSession,
|
||||
DicNode *const terminals, const int size) const = 0;
|
||||
virtual float getDoubleLetterDemotionDistanceCost(const int terminalIndex,
|
||||
const int doubleLetterTerminalIndex,
|
||||
const DoubleLetterLevel doubleLetterLevel) const = 0;
|
||||
virtual float getDoubleLetterDemotionDistanceCost(
|
||||
const DicNode *const terminalDicNode) const = 0;
|
||||
virtual bool doesAutoCorrectValidWord() const = 0;
|
||||
virtual bool autoCorrectsToMultiWordSuggestionIfTop() const = 0;
|
||||
virtual bool sameAsTyped(const DicTraverseSession *const traverseSession,
|
||||
|
|
|
@ -43,11 +43,6 @@ class TypingScoring : public Scoring {
|
|||
const int maxScore, int *const outputCodePoints, int *const frequencies) const {
|
||||
}
|
||||
|
||||
AK_FORCE_INLINE void searchWordWithDoubleLetter(DicNode *terminals,
|
||||
const int terminalSize, int *doubleLetterTerminalIndex,
|
||||
DoubleLetterLevel *doubleLetterLevel) const {
|
||||
}
|
||||
|
||||
AK_FORCE_INLINE float getAdjustedLanguageWeight(DicTraverseSession *const traverseSession,
|
||||
DicNode *const terminals, const int size) const {
|
||||
return 1.0f;
|
||||
|
@ -77,9 +72,8 @@ class TypingScoring : public Scoring {
|
|||
return static_cast<int>(score * SUGGEST_INTERFACE_OUTPUT_SCALE);
|
||||
}
|
||||
|
||||
AK_FORCE_INLINE float getDoubleLetterDemotionDistanceCost(const int terminalIndex,
|
||||
const int doubleLetterTerminalIndex,
|
||||
const DoubleLetterLevel doubleLetterLevel) const {
|
||||
AK_FORCE_INLINE float getDoubleLetterDemotionDistanceCost(
|
||||
const DicNode *const terminalDicNode) const {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue