am 0acb1326: am fee0ac60: Cleanup and fix method visibility.
* commit '0acb13266988c1c582f1ce2ba26252e76702b607': Cleanup and fix method visibility.main
commit
39a2cee68d
|
@ -230,7 +230,7 @@ int Correction::goDownTree(
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove
|
// TODO: remove
|
||||||
int Correction::getInputIndex() {
|
int Correction::getInputIndex() const {
|
||||||
return mInputIndex;
|
return mInputIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,63 +38,8 @@ class Correction {
|
||||||
NOT_ON_TERMINAL
|
NOT_ON_TERMINAL
|
||||||
} CorrectionType;
|
} CorrectionType;
|
||||||
|
|
||||||
/////////////////////////
|
|
||||||
// static inline utils //
|
|
||||||
/////////////////////////
|
|
||||||
|
|
||||||
static const int TWO_31ST_DIV_255 = S_INT_MAX / 255;
|
|
||||||
static inline int capped255MultForFullMatchAccentsOrCapitalizationDifference(const int num) {
|
|
||||||
return (num < TWO_31ST_DIV_255 ? 255 * num : S_INT_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const int TWO_31ST_DIV_2 = S_INT_MAX / 2;
|
|
||||||
inline static void multiplyIntCapped(const int multiplier, int *base) {
|
|
||||||
const int temp = *base;
|
|
||||||
if (temp != S_INT_MAX) {
|
|
||||||
// Branch if multiplier == 2 for the optimization
|
|
||||||
if (multiplier < 0) {
|
|
||||||
if (DEBUG_DICT) {
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
AKLOGI("--- Invalid multiplier: %d", multiplier);
|
|
||||||
} else if (multiplier == 0) {
|
|
||||||
*base = 0;
|
|
||||||
} else if (multiplier == 2) {
|
|
||||||
*base = TWO_31ST_DIV_2 >= temp ? temp << 1 : S_INT_MAX;
|
|
||||||
} else {
|
|
||||||
// TODO: This overflow check gives a wrong answer when, for example,
|
|
||||||
// temp = 2^16 + 1 and multiplier = 2^17 + 1.
|
|
||||||
// Fix this behavior.
|
|
||||||
const int tempRetval = temp * multiplier;
|
|
||||||
*base = tempRetval >= temp ? tempRetval : S_INT_MAX;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline static int powerIntCapped(const int base, const int n) {
|
|
||||||
if (n <= 0) return 1;
|
|
||||||
if (base == 2) {
|
|
||||||
return n < 31 ? 1 << n : S_INT_MAX;
|
|
||||||
} else {
|
|
||||||
int ret = base;
|
|
||||||
for (int i = 1; i < n; ++i) multiplyIntCapped(base, &ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline static void multiplyRate(const int rate, int *freq) {
|
|
||||||
if (*freq != S_INT_MAX) {
|
|
||||||
if (*freq > 1000000) {
|
|
||||||
*freq /= 100;
|
|
||||||
multiplyIntCapped(rate, freq);
|
|
||||||
} else {
|
|
||||||
multiplyIntCapped(rate, freq);
|
|
||||||
*freq /= 100;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Correction() {};
|
Correction() {};
|
||||||
|
virtual ~Correction();
|
||||||
void resetCorrection();
|
void resetCorrection();
|
||||||
void initCorrection(
|
void initCorrection(
|
||||||
const ProximityInfo *pi, const int inputLength, const int maxWordLength);
|
const ProximityInfo *pi, const int inputLength, const int maxWordLength);
|
||||||
|
@ -108,27 +53,7 @@ class Correction {
|
||||||
bool sameAsTyped();
|
bool sameAsTyped();
|
||||||
bool initProcessState(const int index);
|
bool initProcessState(const int index);
|
||||||
|
|
||||||
int getInputIndex();
|
int getInputIndex() const;
|
||||||
|
|
||||||
virtual ~Correction();
|
|
||||||
int getSpaceProximityPos() const {
|
|
||||||
return mSpaceProximityPos;
|
|
||||||
}
|
|
||||||
int getMissingSpacePos() const {
|
|
||||||
return mMissingSpacePos;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getSkipPos() const {
|
|
||||||
return mSkipPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getExcessivePos() const {
|
|
||||||
return mExcessivePos;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getTransposedPos() const {
|
|
||||||
return mTransposedPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool needsToPrune() const;
|
bool needsToPrune() const;
|
||||||
|
|
||||||
|
@ -195,6 +120,81 @@ class Correction {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(Correction);
|
DISALLOW_COPY_AND_ASSIGN(Correction);
|
||||||
|
|
||||||
|
/////////////////////////
|
||||||
|
// static inline utils //
|
||||||
|
/////////////////////////
|
||||||
|
static const int TWO_31ST_DIV_255 = S_INT_MAX / 255;
|
||||||
|
static inline int capped255MultForFullMatchAccentsOrCapitalizationDifference(const int num) {
|
||||||
|
return (num < TWO_31ST_DIV_255 ? 255 * num : S_INT_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const int TWO_31ST_DIV_2 = S_INT_MAX / 2;
|
||||||
|
inline static void multiplyIntCapped(const int multiplier, int *base) {
|
||||||
|
const int temp = *base;
|
||||||
|
if (temp != S_INT_MAX) {
|
||||||
|
// Branch if multiplier == 2 for the optimization
|
||||||
|
if (multiplier < 0) {
|
||||||
|
if (DEBUG_DICT) {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
AKLOGI("--- Invalid multiplier: %d", multiplier);
|
||||||
|
} else if (multiplier == 0) {
|
||||||
|
*base = 0;
|
||||||
|
} else if (multiplier == 2) {
|
||||||
|
*base = TWO_31ST_DIV_2 >= temp ? temp << 1 : S_INT_MAX;
|
||||||
|
} else {
|
||||||
|
// TODO: This overflow check gives a wrong answer when, for example,
|
||||||
|
// temp = 2^16 + 1 and multiplier = 2^17 + 1.
|
||||||
|
// Fix this behavior.
|
||||||
|
const int tempRetval = temp * multiplier;
|
||||||
|
*base = tempRetval >= temp ? tempRetval : S_INT_MAX;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static int powerIntCapped(const int base, const int n) {
|
||||||
|
if (n <= 0) return 1;
|
||||||
|
if (base == 2) {
|
||||||
|
return n < 31 ? 1 << n : S_INT_MAX;
|
||||||
|
} else {
|
||||||
|
int ret = base;
|
||||||
|
for (int i = 1; i < n; ++i) multiplyIntCapped(base, &ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static void multiplyRate(const int rate, int *freq) {
|
||||||
|
if (*freq != S_INT_MAX) {
|
||||||
|
if (*freq > 1000000) {
|
||||||
|
*freq /= 100;
|
||||||
|
multiplyIntCapped(rate, freq);
|
||||||
|
} else {
|
||||||
|
multiplyIntCapped(rate, freq);
|
||||||
|
*freq /= 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int getSpaceProximityPos() const {
|
||||||
|
return mSpaceProximityPos;
|
||||||
|
}
|
||||||
|
inline int getMissingSpacePos() const {
|
||||||
|
return mMissingSpacePos;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int getSkipPos() const {
|
||||||
|
return mSkipPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int getExcessivePos() const {
|
||||||
|
return mExcessivePos;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int getTransposedPos() const {
|
||||||
|
return mTransposedPos;
|
||||||
|
}
|
||||||
|
|
||||||
inline void incrementInputIndex();
|
inline void incrementInputIndex();
|
||||||
inline void incrementOutputIndex();
|
inline void incrementOutputIndex();
|
||||||
inline void startToTraverseAllNodes();
|
inline void startToTraverseAllNodes();
|
||||||
|
|
|
@ -41,21 +41,12 @@ class ProximityInfo {
|
||||||
float getNormalizedSquaredDistanceFromCenterFloat(
|
float getNormalizedSquaredDistanceFromCenterFloat(
|
||||||
const int keyId, const int x, const int y) const;
|
const int keyId, const int x, const int y) const;
|
||||||
bool sameAsTyped(const unsigned short *word, int length) const;
|
bool sameAsTyped(const unsigned short *word, int length) const;
|
||||||
int squaredDistanceToEdge(const int keyId, const int x, const int y) const;
|
|
||||||
bool isOnKey(const int keyId, const int x, const int y) const {
|
|
||||||
if (keyId < 0) return true; // NOT_A_ID is -1, but return whenever < 0 just in case
|
|
||||||
const int left = mKeyXCoordinates[keyId];
|
|
||||||
const int top = mKeyYCoordinates[keyId];
|
|
||||||
const int right = left + mKeyWidths[keyId] + 1;
|
|
||||||
const int bottom = top + mKeyHeights[keyId];
|
|
||||||
return left < right && top < bottom && x >= left && x < right && y >= top && y < bottom;
|
|
||||||
}
|
|
||||||
int getKeyIndex(const int c) const;
|
int getKeyIndex(const int c) const;
|
||||||
int getKeyCode(const int keyIndex) const;
|
int getKeyCode(const int keyIndex) const;
|
||||||
bool hasSweetSpotData(const int keyIndex) const {
|
bool hasSweetSpotData(const int keyIndex) const {
|
||||||
// When there are no calibration data for a key,
|
// When there are no calibration data for a key,
|
||||||
// the radius of the key is assigned to zero.
|
// the radius of the key is assigned to zero.
|
||||||
return mSweetSpotRadii[keyIndex] > 0.0;
|
return mSweetSpotRadii[keyIndex] > 0.0f;
|
||||||
}
|
}
|
||||||
float getSweetSpotRadiiAt(int keyIndex) const {
|
float getSweetSpotRadiiAt(int keyIndex) const {
|
||||||
return mSweetSpotRadii[keyIndex];
|
return mSweetSpotRadii[keyIndex];
|
||||||
|
@ -111,10 +102,6 @@ class ProximityInfo {
|
||||||
float getKeyCenterYOfIdG(int keyId) const;
|
float getKeyCenterYOfIdG(int keyId) const;
|
||||||
int getKeyKeyDistanceG(int key0, int key1) const;
|
int getKeyKeyDistanceG(int key0, int key1) const;
|
||||||
|
|
||||||
// Returns the keyboard key-center information.
|
|
||||||
void getCenters(int *centersX, int *centersY, int *codeToKeyIndex, int *keyToCodeIndex,
|
|
||||||
int *keyCount, int *keyWidth) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_IMPLICIT_CONSTRUCTORS(ProximityInfo);
|
DISALLOW_IMPLICIT_CONSTRUCTORS(ProximityInfo);
|
||||||
// The max number of the keys in one keyboard layout
|
// The max number of the keys in one keyboard layout
|
||||||
|
@ -131,6 +118,15 @@ class ProximityInfo {
|
||||||
float calculateSquaredDistanceFromSweetSpotCenter(
|
float calculateSquaredDistanceFromSweetSpotCenter(
|
||||||
const int keyIndex, const int inputIndex) const;
|
const int keyIndex, const int inputIndex) const;
|
||||||
bool hasInputCoordinates() const;
|
bool hasInputCoordinates() const;
|
||||||
|
int squaredDistanceToEdge(const int keyId, const int x, const int y) const;
|
||||||
|
bool isOnKey(const int keyId, const int x, const int y) const {
|
||||||
|
if (keyId < 0) return true; // NOT_A_ID is -1, but return whenever < 0 just in case
|
||||||
|
const int left = mKeyXCoordinates[keyId];
|
||||||
|
const int top = mKeyYCoordinates[keyId];
|
||||||
|
const int right = left + mKeyWidths[keyId] + 1;
|
||||||
|
const int bottom = top + mKeyHeights[keyId];
|
||||||
|
return left < right && top < bottom && x >= left && x < right && y >= top && y < bottom;
|
||||||
|
}
|
||||||
|
|
||||||
const int MAX_PROXIMITY_CHARS_SIZE;
|
const int MAX_PROXIMITY_CHARS_SIZE;
|
||||||
const int KEYBOARD_WIDTH;
|
const int KEYBOARD_WIDTH;
|
||||||
|
|
|
@ -48,9 +48,6 @@ class ProximityInfoState {
|
||||||
// Defined here //
|
// Defined here //
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
ProximityInfoState() {};
|
ProximityInfoState() {};
|
||||||
inline const int *getProximityCharsAt(const int index) const {
|
|
||||||
return mInputCodes + (index * MAX_PROXIMITY_CHARS_SIZE_INTERNAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline unsigned short getPrimaryCharAt(const int index) const {
|
inline unsigned short getPrimaryCharAt(const int index) const {
|
||||||
return getProximityCharsAt(index)[0];
|
return getProximityCharsAt(index)[0];
|
||||||
|
@ -194,6 +191,10 @@ class ProximityInfoState {
|
||||||
return mInputXCoordinates && mInputYCoordinates;
|
return mInputXCoordinates && mInputYCoordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const int *getProximityCharsAt(const int index) const {
|
||||||
|
return mInputCodes + (index * MAX_PROXIMITY_CHARS_SIZE_INTERNAL);
|
||||||
|
}
|
||||||
|
|
||||||
// const
|
// const
|
||||||
const ProximityInfo *mProximityInfo;
|
const ProximityInfo *mProximityInfo;
|
||||||
bool mHasTouchPositionCorrectionData;
|
bool mHasTouchPositionCorrectionData;
|
||||||
|
|
Loading…
Reference in New Issue