Support multi words input for gesture.

Bug: 8591918

Change-Id: I344f936907a385cc6c3c8a2215a6603938483401
main
Keisuke Kuroynagi 2013-06-17 19:04:29 +09:00
parent 14718ab898
commit 6bfeeb8694
4 changed files with 17 additions and 10 deletions

View File

@ -128,7 +128,7 @@ class DicNode {
void initAsRootWithPreviousWord(DicNode *dicNode, const int pos, const int childrenPos,
const int childrenCount) {
mIsUsed = true;
mIsCachedForNextSuggestion = false;
mIsCachedForNextSuggestion = dicNode->mIsCachedForNextSuggestion;
mDicNodeProperties.init(
pos, 0, childrenPos, 0, 0, 0, childrenCount, 0, 0, false, false, true, 0, 0);
// TODO: Move to dicNodeState?
@ -479,6 +479,11 @@ class DicNode {
return mDicNodeProperties.getDepth();
}
// "Length" includes spaces.
inline uint16_t getTotalLength() const {
return getDepth() + mDicNodeState.mDicNodeStatePrevWord.getPrevWordLength();
}
AK_FORCE_INLINE void dump(const char *tag) const {
#if DEBUG_DICT
DUMP_WORD_AND_SCORE(tag);

View File

@ -106,7 +106,7 @@ static inline void profile(const CorrectionType correctionType, DicNode *const n
// only used for typing
return weighting->getSubstitutionCost();
case CT_NEW_WORD_SPACE_OMITTION:
return weighting->getNewWordCost(traverseSession, dicNode);
return weighting->getNewWordSpatialCost(traverseSession, dicNode, inputStateG);
case CT_MATCH:
return weighting->getMatchedCost(traverseSession, dicNode, inputStateG);
case CT_COMPLETION:
@ -134,7 +134,8 @@ static inline void profile(const CorrectionType correctionType, DicNode *const n
case CT_SUBSTITUTION:
return 0.0f;
case CT_NEW_WORD_SPACE_OMITTION:
return weighting->getNewWordBigramCost(traverseSession, parentDicNode, multiBigramMap);
return weighting->getNewWordBigramLanguageCost(
traverseSession, parentDicNode, multiBigramMap);
case CT_MATCH:
return 0.0f;
case CT_COMPLETION:
@ -146,7 +147,8 @@ static inline void profile(const CorrectionType correctionType, DicNode *const n
return weighting->getTerminalLanguageCost(traverseSession, dicNode, languageImprobability);
}
case CT_NEW_WORD_SPACE_SUBSTITUTION:
return weighting->getNewWordBigramCost(traverseSession, parentDicNode, multiBigramMap);
return weighting->getNewWordBigramLanguageCost(
traverseSession, parentDicNode, multiBigramMap);
case CT_INSERTION:
return 0.0f;
case CT_TRANSPOSITION:

View File

@ -56,10 +56,10 @@ class Weighting {
const DicTraverseSession *const traverseSession,
const DicNode *const parentDicNode, const DicNode *const dicNode) const = 0;
virtual float getNewWordCost(const DicTraverseSession *const traverseSession,
const DicNode *const dicNode) const = 0;
virtual float getNewWordSpatialCost(const DicTraverseSession *const traverseSession,
const DicNode *const dicNode, DicNode_InputStateG *const inputStateG) const = 0;
virtual float getNewWordBigramCost(
virtual float getNewWordBigramLanguageCost(
const DicTraverseSession *const traverseSession, const DicNode *const dicNode,
MultiBigramMap *const multiBigramMap) const = 0;

View File

@ -138,12 +138,12 @@ class TypingWeighting : public Weighting {
return cost + weightedDistance;
}
float getNewWordCost(const DicTraverseSession *const traverseSession,
const DicNode *const dicNode) const {
float getNewWordSpatialCost(const DicTraverseSession *const traverseSession,
const DicNode *const dicNode, DicNode_InputStateG *inputStateG) const {
return ScoringParams::COST_NEW_WORD * traverseSession->getMultiWordCostMultiplier();
}
float getNewWordBigramCost(const DicTraverseSession *const traverseSession,
float getNewWordBigramLanguageCost(const DicTraverseSession *const traverseSession,
const DicNode *const dicNode,
MultiBigramMap *const multiBigramMap) const {
return DicNodeUtils::getBigramNodeImprobability(traverseSession->getBinaryDictionaryInfo(),