am 588d2a52: Merge "Handle the last char correctly in excessive char correction algortihm." into honeycomb

* commit '588d2a525c444c0126f88791fcb097deba5d4644':
  Handle the last char correctly in excessive char correction algortihm.
main
satok 2011-01-26 23:51:53 -08:00 committed by Android Git Automerger
commit dae444d0fd
1 changed files with 6 additions and 3 deletions

View File

@ -461,8 +461,9 @@ inline bool UnigramDictionary::processCurrentNode(const int pos, const int depth
int childPosition; int childPosition;
bool terminal; bool terminal;
int freq; int freq;
bool isSameAsUserTypedLength = false;
if (excessivePos == depth) ++inputIndex; if (excessivePos == depth && inputIndex < mInputLength - 1) ++inputIndex;
*nextSiblingPosition = Dictionary::setDictionaryValues(DICT, IS_LATEST_DICT_VERSION, pos, &c, *nextSiblingPosition = Dictionary::setDictionaryValues(DICT, IS_LATEST_DICT_VERSION, pos, &c,
&childPosition, &terminal, &freq); &childPosition, &terminal, &freq);
@ -496,7 +497,8 @@ inline bool UnigramDictionary::processCurrentNode(const int pos, const int depth
// If inputIndex is greater than mInputLength, that means there is no // If inputIndex is greater than mInputLength, that means there is no
// proximity chars. So, we don't need to check proximity. // proximity chars. So, we don't need to check proximity.
const int addedWeight = matchedProximityCharId == 0 ? TYPED_LETTER_MULTIPLIER : 1; const int addedWeight = matchedProximityCharId == 0 ? TYPED_LETTER_MULTIPLIER : 1;
const bool isSameAsUserTypedLength = mInputLength == inputIndex + 1; bool isSameAsUserTypedLength = mInputLength == inputIndex + 1
|| (excessivePos == mInputLength - 1 && inputIndex == mInputLength - 2);
if (isSameAsUserTypedLength && terminal) { if (isSameAsUserTypedLength && terminal) {
onTerminalWhenUserTypedLengthIsSameAsInputLength(mWord, inputIndex, depth, snr, onTerminalWhenUserTypedLengthIsSameAsInputLength(mWord, inputIndex, depth, snr,
skipPos, excessivePos, transposedPos, freq, addedWeight); skipPos, excessivePos, transposedPos, freq, addedWeight);
@ -514,7 +516,8 @@ inline bool UnigramDictionary::processCurrentNode(const int pos, const int depth
} }
// If inputIndex is greater than mInputLength, that means there are no proximity chars. // If inputIndex is greater than mInputLength, that means there are no proximity chars.
if (mInputLength <= *newInputIndex) { // TODO: Check if this can be isSameAsUserTypedLength only.
if (isSameAsUserTypedLength || mInputLength <= *newInputIndex) {
*newTraverseAllNodes = true; *newTraverseAllNodes = true;
} }
// get the count of nodes and increment childAddress. // get the count of nodes and increment childAddress.