Merge "Improve the double letter word promotion logic."

This commit is contained in:
Keisuke Kuroyanagi 2014-01-28 08:24:54 +00:00 committed by Android (Google) Code Review
commit 437fa64af3
3 changed files with 6 additions and 22 deletions

View file

@ -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 =

View file

@ -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,

View file

@ -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;
}