am e775073b: Merge "Fix typing incremental decoder"

* commit 'e775073b727e4348f9dd2d056a2e811d9dfeca73':
  Fix typing incremental decoder
main
Satoshi Kataoka 2012-12-12 03:41:44 -08:00 committed by Android Git Automerger
commit 6687c96318
2 changed files with 23 additions and 5 deletions

View File

@ -668,11 +668,15 @@ int ProximityInfoState::getDuration(const int index) const {
return 0; return 0;
} }
float ProximityInfoState::getPointToKeyLength(const int inputIndex, const int codePoint) const { // TODO: Remove the "scale" parameter
// This function basically converts from a length to an edit distance. Accordingly, it's obviously
// wrong to compare with mMaxPointToKeyLength.
float ProximityInfoState::getPointToKeyLength(
const int inputIndex, const int codePoint, const float scale) const {
const int keyId = mProximityInfo->getKeyIndexOf(codePoint); const int keyId = mProximityInfo->getKeyIndexOf(codePoint);
if (keyId != NOT_AN_INDEX) { if (keyId != NOT_AN_INDEX) {
const int index = inputIndex * mProximityInfo->getKeyCount() + keyId; const int index = inputIndex * mProximityInfo->getKeyCount() + keyId;
return min(mDistanceCache[index], mMaxPointToKeyLength); return min(mDistanceCache[index] * scale, mMaxPointToKeyLength);
} }
if (isSkippableCodePoint(codePoint)) { if (isSkippableCodePoint(codePoint)) {
return 0.0f; return 0.0f;
@ -681,15 +685,27 @@ float ProximityInfoState::getPointToKeyLength(const int inputIndex, const int co
return MAX_POINT_TO_KEY_LENGTH; return MAX_POINT_TO_KEY_LENGTH;
} }
float ProximityInfoState::getPointToKeyByIdLength(const int inputIndex, const int keyId) const { float ProximityInfoState::getPointToKeyLength(const int inputIndex, const int codePoint) const {
return getPointToKeyLength(inputIndex, codePoint, 1.0f);
}
// TODO: Remove the "scale" parameter
// This function basically converts from a length to an edit distance. Accordingly, it's obviously
// wrong to compare with mMaxPointToKeyLength.
float ProximityInfoState::getPointToKeyByIdLength(
const int inputIndex, const int keyId, const float scale) const {
if (keyId != NOT_AN_INDEX) { if (keyId != NOT_AN_INDEX) {
const int index = inputIndex * mProximityInfo->getKeyCount() + keyId; const int index = inputIndex * mProximityInfo->getKeyCount() + keyId;
return min(mDistanceCache[index], mMaxPointToKeyLength); return min(mDistanceCache[index] * scale, mMaxPointToKeyLength);
} }
// If the char is not a key on the keyboard then return the max length. // If the char is not a key on the keyboard then return the max length.
return static_cast<float>(MAX_POINT_TO_KEY_LENGTH); return static_cast<float>(MAX_POINT_TO_KEY_LENGTH);
} }
float ProximityInfoState::getPointToKeyByIdLength(const int inputIndex, const int keyId) const {
return getPointToKeyByIdLength(inputIndex, keyId, 1.0f);
}
// In the following function, c is the current character of the dictionary word currently examined. // In the following function, c is the current character of the dictionary word currently examined.
// currentChars is an array containing the keys close to the character the user actually typed at // currentChars is an array containing the keys close to the character the user actually typed at
// the same position. We want to see if c is in it: if so, then the word contains at that position // the same position. We want to see if c is in it: if so, then the word contains at that position

View File

@ -155,8 +155,10 @@ class ProximityInfoState {
return mIsContinuationPossible; return mIsContinuationPossible;
} }
float getPointToKeyLength(const int inputIndex, const int charCode) const; float getPointToKeyByIdLength(const int inputIndex, const int keyId, const float scale) const;
float getPointToKeyByIdLength(const int inputIndex, const int keyId) const; float getPointToKeyByIdLength(const int inputIndex, const int keyId) const;
float getPointToKeyLength(const int inputIndex, const int codePoint, const float scale) const;
float getPointToKeyLength(const int inputIndex, const int codePoint) const;
ProximityType getMatchedProximityId(const int index, const int c, ProximityType getMatchedProximityId(const int index, const int c,
const bool checkProximityChars, int *proximityIndex = 0) const; const bool checkProximityChars, int *proximityIndex = 0) const;