Merge "Quit limiting gesture search space by distance."
This commit is contained in:
commit
627fcc6c92
6 changed files with 34 additions and 59 deletions
|
@ -24,9 +24,6 @@ const float ProximityInfoParams::VERTICAL_SWEET_SPOT_SCALE = 1.0f;
|
||||||
const float ProximityInfoParams::VERTICAL_SWEET_SPOT_SCALE_G = 0.5f;
|
const float ProximityInfoParams::VERTICAL_SWEET_SPOT_SCALE_G = 0.5f;
|
||||||
|
|
||||||
/* Per method constants */
|
/* Per method constants */
|
||||||
// Used by ProximityInfoStateUtils::initGeometricDistanceInfos()
|
|
||||||
const float ProximityInfoParams::NEAR_KEY_NORMALIZED_SQUARED_THRESHOLD = 4.0f;
|
|
||||||
|
|
||||||
// Used by ProximityInfoStateUtils::updateNearKeysDistances()
|
// Used by ProximityInfoStateUtils::updateNearKeysDistances()
|
||||||
const float ProximityInfoParams::NEAR_KEY_THRESHOLD_FOR_DISTANCE = 2.0f;
|
const float ProximityInfoParams::NEAR_KEY_THRESHOLD_FOR_DISTANCE = 2.0f;
|
||||||
|
|
||||||
|
@ -50,7 +47,7 @@ const int ProximityInfoParams::NUM_POINTS_FOR_SPEED_CALCULATION = 2;
|
||||||
const int ProximityInfoParams::LAST_POINT_SKIP_DISTANCE_SCALE = 4;
|
const int ProximityInfoParams::LAST_POINT_SKIP_DISTANCE_SCALE = 4;
|
||||||
|
|
||||||
// Used by ProximityInfoStateUtils::updateAlignPointProbabilities()
|
// Used by ProximityInfoStateUtils::updateAlignPointProbabilities()
|
||||||
const float ProximityInfoParams::MIN_PROBABILITY = 0.000001f;
|
const float ProximityInfoParams::MIN_PROBABILITY = 0.000005f;
|
||||||
const float ProximityInfoParams::MAX_SKIP_PROBABILITY = 0.95f;
|
const float ProximityInfoParams::MAX_SKIP_PROBABILITY = 0.95f;
|
||||||
const float ProximityInfoParams::SKIP_FIRST_POINT_PROBABILITY = 0.01f;
|
const float ProximityInfoParams::SKIP_FIRST_POINT_PROBABILITY = 0.01f;
|
||||||
const float ProximityInfoParams::SKIP_LAST_POINT_PROBABILITY = 0.1f;
|
const float ProximityInfoParams::SKIP_LAST_POINT_PROBABILITY = 0.1f;
|
||||||
|
|
|
@ -28,9 +28,6 @@ class ProximityInfoParams {
|
||||||
static const float VERTICAL_SWEET_SPOT_SCALE;
|
static const float VERTICAL_SWEET_SPOT_SCALE;
|
||||||
static const float VERTICAL_SWEET_SPOT_SCALE_G;
|
static const float VERTICAL_SWEET_SPOT_SCALE_G;
|
||||||
|
|
||||||
// Used by ProximityInfoStateUtils::initGeometricDistanceInfos()
|
|
||||||
static const float NEAR_KEY_NORMALIZED_SQUARED_THRESHOLD;
|
|
||||||
|
|
||||||
// Used by ProximityInfoStateUtils::updateNearKeysDistances()
|
// Used by ProximityInfoStateUtils::updateNearKeysDistances()
|
||||||
static const float NEAR_KEY_THRESHOLD_FOR_DISTANCE;
|
static const float NEAR_KEY_THRESHOLD_FOR_DISTANCE;
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,6 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
|
||||||
mSampledInputIndice.clear();
|
mSampledInputIndice.clear();
|
||||||
mSampledLengthCache.clear();
|
mSampledLengthCache.clear();
|
||||||
mSampledNormalizedSquaredLengthCache.clear();
|
mSampledNormalizedSquaredLengthCache.clear();
|
||||||
mSampledNearKeySets.clear();
|
|
||||||
mSampledSearchKeySets.clear();
|
mSampledSearchKeySets.clear();
|
||||||
mSpeedRates.clear();
|
mSpeedRates.clear();
|
||||||
mBeelineSpeedPercentiles.clear();
|
mBeelineSpeedPercentiles.clear();
|
||||||
|
@ -126,18 +125,17 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
|
||||||
if (mSampledInputSize > 0) {
|
if (mSampledInputSize > 0) {
|
||||||
ProximityInfoStateUtils::initGeometricDistanceInfos(mProximityInfo, mSampledInputSize,
|
ProximityInfoStateUtils::initGeometricDistanceInfos(mProximityInfo, mSampledInputSize,
|
||||||
lastSavedInputSize, isGeometric, &mSampledInputXs, &mSampledInputYs,
|
lastSavedInputSize, isGeometric, &mSampledInputXs, &mSampledInputYs,
|
||||||
&mSampledNearKeySets, &mSampledNormalizedSquaredLengthCache);
|
&mSampledNormalizedSquaredLengthCache);
|
||||||
if (isGeometric) {
|
if (isGeometric) {
|
||||||
// updates probabilities of skipping or mapping each key for all points.
|
// updates probabilities of skipping or mapping each key for all points.
|
||||||
ProximityInfoStateUtils::updateAlignPointProbabilities(
|
ProximityInfoStateUtils::updateAlignPointProbabilities(
|
||||||
mMaxPointToKeyLength, mProximityInfo->getMostCommonKeyWidth(),
|
mMaxPointToKeyLength, mProximityInfo->getMostCommonKeyWidth(),
|
||||||
mProximityInfo->getKeyCount(), lastSavedInputSize, mSampledInputSize,
|
mProximityInfo->getKeyCount(), lastSavedInputSize, mSampledInputSize,
|
||||||
&mSampledInputXs, &mSampledInputYs, &mSpeedRates, &mSampledLengthCache,
|
&mSampledInputXs, &mSampledInputYs, &mSpeedRates, &mSampledLengthCache,
|
||||||
&mSampledNormalizedSquaredLengthCache, &mSampledNearKeySets,
|
&mSampledNormalizedSquaredLengthCache, mProximityInfo, &mCharProbabilities);
|
||||||
mProximityInfo, &mCharProbabilities);
|
|
||||||
ProximityInfoStateUtils::updateSampledSearchKeySets(mProximityInfo,
|
ProximityInfoStateUtils::updateSampledSearchKeySets(mProximityInfo,
|
||||||
mSampledInputSize, lastSavedInputSize, &mSampledLengthCache,
|
mSampledInputSize, lastSavedInputSize, &mSampledLengthCache,
|
||||||
&mSampledNearKeySets, &mSampledSearchKeySets,
|
&mCharProbabilities, &mSampledSearchKeySets,
|
||||||
&mSampledSearchKeyVectors);
|
&mSampledSearchKeyVectors);
|
||||||
mMostProbableStringProbability = ProximityInfoStateUtils::getMostProbableString(
|
mMostProbableStringProbability = ProximityInfoStateUtils::getMostProbableString(
|
||||||
mProximityInfo, mSampledInputSize, &mCharProbabilities, mMostProbableString);
|
mProximityInfo, mSampledInputSize, &mCharProbabilities, mMostProbableString);
|
||||||
|
|
|
@ -50,9 +50,9 @@ class ProximityInfoState {
|
||||||
mSampledInputXs(), mSampledInputYs(), mSampledTimes(), mSampledInputIndice(),
|
mSampledInputXs(), mSampledInputYs(), mSampledTimes(), mSampledInputIndice(),
|
||||||
mSampledLengthCache(), mBeelineSpeedPercentiles(),
|
mSampledLengthCache(), mBeelineSpeedPercentiles(),
|
||||||
mSampledNormalizedSquaredLengthCache(), mSpeedRates(), mDirections(),
|
mSampledNormalizedSquaredLengthCache(), mSpeedRates(), mDirections(),
|
||||||
mCharProbabilities(), mSampledNearKeySets(), mSampledSearchKeySets(),
|
mCharProbabilities(), mSampledSearchKeySets(), mSampledSearchKeyVectors(),
|
||||||
mSampledSearchKeyVectors(), mTouchPositionCorrectionEnabled(false),
|
mTouchPositionCorrectionEnabled(false), mSampledInputSize(0),
|
||||||
mSampledInputSize(0), mMostProbableStringProbability(0.0f) {
|
mMostProbableStringProbability(0.0f) {
|
||||||
memset(mInputProximities, 0, sizeof(mInputProximities));
|
memset(mInputProximities, 0, sizeof(mInputProximities));
|
||||||
memset(mPrimaryInputWord, 0, sizeof(mPrimaryInputWord));
|
memset(mPrimaryInputWord, 0, sizeof(mPrimaryInputWord));
|
||||||
memset(mMostProbableString, 0, sizeof(mMostProbableString));
|
memset(mMostProbableString, 0, sizeof(mMostProbableString));
|
||||||
|
@ -216,10 +216,6 @@ class ProximityInfoState {
|
||||||
std::vector<float> mDirections;
|
std::vector<float> mDirections;
|
||||||
// probabilities of skipping or mapping to a key for each point.
|
// probabilities of skipping or mapping to a key for each point.
|
||||||
std::vector<hash_map_compat<int, float> > mCharProbabilities;
|
std::vector<hash_map_compat<int, float> > mCharProbabilities;
|
||||||
// The vector for the key code set which holds nearby keys for each sampled input point
|
|
||||||
// 1. Used to calculate the probability of the key
|
|
||||||
// 2. Used to calculate mSampledSearchKeySets
|
|
||||||
std::vector<ProximityInfoStateUtils::NearKeycodesSet> mSampledNearKeySets;
|
|
||||||
// The vector for the key code set which holds nearby keys of some trailing sampled input points
|
// The vector for the key code set which holds nearby keys of some trailing sampled input points
|
||||||
// for each sampled input point. These nearby keys contain the next characters which can be in
|
// for each sampled input point. These nearby keys contain the next characters which can be in
|
||||||
// the dictionary. Specifically, currently we are looking for keys nearby trailing sampled
|
// the dictionary. Specifically, currently we are looking for keys nearby trailing sampled
|
||||||
|
|
|
@ -188,13 +188,10 @@ namespace latinime {
|
||||||
const int lastSavedInputSize, const bool isGeometric,
|
const int lastSavedInputSize, const bool isGeometric,
|
||||||
const std::vector<int> *const sampledInputXs,
|
const std::vector<int> *const sampledInputXs,
|
||||||
const std::vector<int> *const sampledInputYs,
|
const std::vector<int> *const sampledInputYs,
|
||||||
std::vector<NearKeycodesSet> *sampledNearKeySets,
|
|
||||||
std::vector<float> *sampledNormalizedSquaredLengthCache) {
|
std::vector<float> *sampledNormalizedSquaredLengthCache) {
|
||||||
sampledNearKeySets->resize(sampledInputSize);
|
|
||||||
const int keyCount = proximityInfo->getKeyCount();
|
const int keyCount = proximityInfo->getKeyCount();
|
||||||
sampledNormalizedSquaredLengthCache->resize(sampledInputSize * keyCount);
|
sampledNormalizedSquaredLengthCache->resize(sampledInputSize * keyCount);
|
||||||
for (int i = lastSavedInputSize; i < sampledInputSize; ++i) {
|
for (int i = lastSavedInputSize; i < sampledInputSize; ++i) {
|
||||||
(*sampledNearKeySets)[i].reset();
|
|
||||||
for (int k = 0; k < keyCount; ++k) {
|
for (int k = 0; k < keyCount; ++k) {
|
||||||
const int index = i * keyCount + k;
|
const int index = i * keyCount + k;
|
||||||
const int x = (*sampledInputXs)[i];
|
const int x = (*sampledInputXs)[i];
|
||||||
|
@ -203,10 +200,6 @@ namespace latinime {
|
||||||
proximityInfo->getNormalizedSquaredDistanceFromCenterFloatG(
|
proximityInfo->getNormalizedSquaredDistanceFromCenterFloatG(
|
||||||
k, x, y, isGeometric);
|
k, x, y, isGeometric);
|
||||||
(*sampledNormalizedSquaredLengthCache)[index] = normalizedSquaredDistance;
|
(*sampledNormalizedSquaredLengthCache)[index] = normalizedSquaredDistance;
|
||||||
if (normalizedSquaredDistance
|
|
||||||
< ProximityInfoParams::NEAR_KEY_NORMALIZED_SQUARED_THRESHOLD) {
|
|
||||||
(*sampledNearKeySets)[i][k] = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -626,7 +619,6 @@ namespace latinime {
|
||||||
const std::vector<float> *const sampledSpeedRates,
|
const std::vector<float> *const sampledSpeedRates,
|
||||||
const std::vector<int> *const sampledLengthCache,
|
const std::vector<int> *const sampledLengthCache,
|
||||||
const std::vector<float> *const sampledNormalizedSquaredLengthCache,
|
const std::vector<float> *const sampledNormalizedSquaredLengthCache,
|
||||||
std::vector<NearKeycodesSet> *sampledNearKeySets,
|
|
||||||
const ProximityInfo *const proximityInfo,
|
const ProximityInfo *const proximityInfo,
|
||||||
std::vector<hash_map_compat<int, float> > *charProbabilities) {
|
std::vector<hash_map_compat<int, float> > *charProbabilities) {
|
||||||
charProbabilities->resize(sampledInputSize);
|
charProbabilities->resize(sampledInputSize);
|
||||||
|
@ -643,12 +635,10 @@ namespace latinime {
|
||||||
|
|
||||||
float nearestKeyDistance = static_cast<float>(MAX_VALUE_FOR_WEIGHTING);
|
float nearestKeyDistance = static_cast<float>(MAX_VALUE_FOR_WEIGHTING);
|
||||||
for (int j = 0; j < keyCount; ++j) {
|
for (int j = 0; j < keyCount; ++j) {
|
||||||
if ((*sampledNearKeySets)[i].test(j)) {
|
const float distance = getPointToKeyByIdLength(
|
||||||
const float distance = getPointToKeyByIdLength(
|
maxPointToKeyLength, sampledNormalizedSquaredLengthCache, keyCount, i, j);
|
||||||
maxPointToKeyLength, sampledNormalizedSquaredLengthCache, keyCount, i, j);
|
if (distance < nearestKeyDistance) {
|
||||||
if (distance < nearestKeyDistance) {
|
nearestKeyDistance = distance;
|
||||||
nearestKeyDistance = distance;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -744,27 +734,23 @@ namespace latinime {
|
||||||
// Summing up probability densities of all near keys.
|
// Summing up probability densities of all near keys.
|
||||||
float sumOfProbabilityDensities = 0.0f;
|
float sumOfProbabilityDensities = 0.0f;
|
||||||
for (int j = 0; j < keyCount; ++j) {
|
for (int j = 0; j < keyCount; ++j) {
|
||||||
if ((*sampledNearKeySets)[i].test(j)) {
|
sumOfProbabilityDensities += distribution.getProbabilityDensity(
|
||||||
sumOfProbabilityDensities += distribution.getProbabilityDensity(
|
proximityInfo->getKeyCenterXOfKeyIdG(j,
|
||||||
proximityInfo->getKeyCenterXOfKeyIdG(j,
|
NOT_A_COORDINATE /* referencePointX */, true /* isGeometric */),
|
||||||
NOT_A_COORDINATE /* referencePointX */, true /* isGeometric */),
|
proximityInfo->getKeyCenterYOfKeyIdG(j,
|
||||||
proximityInfo->getKeyCenterYOfKeyIdG(j,
|
NOT_A_COORDINATE /* referencePointY */, true /* isGeometric */));
|
||||||
NOT_A_COORDINATE /* referencePointY */, true /* isGeometric */));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split the probability of an input point to keys that are close to the input point.
|
// Split the probability of an input point to keys that are close to the input point.
|
||||||
for (int j = 0; j < keyCount; ++j) {
|
for (int j = 0; j < keyCount; ++j) {
|
||||||
if ((*sampledNearKeySets)[i].test(j)) {
|
const float probabilityDensity = distribution.getProbabilityDensity(
|
||||||
const float probabilityDensity = distribution.getProbabilityDensity(
|
proximityInfo->getKeyCenterXOfKeyIdG(j,
|
||||||
proximityInfo->getKeyCenterXOfKeyIdG(j,
|
NOT_A_COORDINATE /* referencePointX */, true /* isGeometric */),
|
||||||
NOT_A_COORDINATE /* referencePointX */, true /* isGeometric */),
|
proximityInfo->getKeyCenterYOfKeyIdG(j,
|
||||||
proximityInfo->getKeyCenterYOfKeyIdG(j,
|
NOT_A_COORDINATE /* referencePointY */, true /* isGeometric */));
|
||||||
NOT_A_COORDINATE /* referencePointY */, true /* isGeometric */));
|
const float probability = inputCharProbability * probabilityDensity
|
||||||
const float probability = inputCharProbability * probabilityDensity
|
/ sumOfProbabilityDensities;
|
||||||
/ sumOfProbabilityDensities;
|
(*charProbabilities)[i][j] = probability;
|
||||||
(*charProbabilities)[i][j] = probability;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -820,10 +806,9 @@ namespace latinime {
|
||||||
for (int j = 0; j < keyCount; ++j) {
|
for (int j = 0; j < keyCount; ++j) {
|
||||||
hash_map_compat<int, float>::iterator it = (*charProbabilities)[i].find(j);
|
hash_map_compat<int, float>::iterator it = (*charProbabilities)[i].find(j);
|
||||||
if (it == (*charProbabilities)[i].end()){
|
if (it == (*charProbabilities)[i].end()){
|
||||||
(*sampledNearKeySets)[i].reset(j);
|
continue;
|
||||||
} else if(it->second < ProximityInfoParams::MIN_PROBABILITY) {
|
} else if(it->second < ProximityInfoParams::MIN_PROBABILITY) {
|
||||||
// Erases from near keys vector because it has very low probability.
|
// Erases from near keys vector because it has very low probability.
|
||||||
(*sampledNearKeySets)[i].reset(j);
|
|
||||||
(*charProbabilities)[i].erase(j);
|
(*charProbabilities)[i].erase(j);
|
||||||
} else {
|
} else {
|
||||||
it->second = -logf(it->second);
|
it->second = -logf(it->second);
|
||||||
|
@ -835,9 +820,8 @@ namespace latinime {
|
||||||
|
|
||||||
/* static */ void ProximityInfoStateUtils::updateSampledSearchKeySets(
|
/* static */ void ProximityInfoStateUtils::updateSampledSearchKeySets(
|
||||||
const ProximityInfo *const proximityInfo, const int sampledInputSize,
|
const ProximityInfo *const proximityInfo, const int sampledInputSize,
|
||||||
const int lastSavedInputSize,
|
const int lastSavedInputSize, const std::vector<int> *const sampledLengthCache,
|
||||||
const std::vector<int> *const sampledLengthCache,
|
const std::vector<hash_map_compat<int, float> > *const charProbabilities,
|
||||||
const std::vector<NearKeycodesSet> *const sampledNearKeySets,
|
|
||||||
std::vector<NearKeycodesSet> *sampledSearchKeySets,
|
std::vector<NearKeycodesSet> *sampledSearchKeySets,
|
||||||
std::vector<std::vector<int> > *sampledSearchKeyVectors) {
|
std::vector<std::vector<int> > *sampledSearchKeyVectors) {
|
||||||
sampledSearchKeySets->resize(sampledInputSize);
|
sampledSearchKeySets->resize(sampledInputSize);
|
||||||
|
@ -854,7 +838,12 @@ namespace latinime {
|
||||||
if ((*sampledLengthCache)[j] - (*sampledLengthCache)[i] >= readForwordLength) {
|
if ((*sampledLengthCache)[j] - (*sampledLengthCache)[i] >= readForwordLength) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
(*sampledSearchKeySets)[i] |= (*sampledNearKeySets)[j];
|
for(const auto& charProbability : charProbabilities->at(j)) {
|
||||||
|
if (charProbability.first == NOT_AN_INDEX) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
(*sampledSearchKeySets)[i].set(charProbability.first);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const int keyCount = proximityInfo->getKeyCount();
|
const int keyCount = proximityInfo->getKeyCount();
|
||||||
|
|
|
@ -71,13 +71,12 @@ class ProximityInfoStateUtils {
|
||||||
const std::vector<float> *const sampledSpeedRates,
|
const std::vector<float> *const sampledSpeedRates,
|
||||||
const std::vector<int> *const sampledLengthCache,
|
const std::vector<int> *const sampledLengthCache,
|
||||||
const std::vector<float> *const sampledNormalizedSquaredLengthCache,
|
const std::vector<float> *const sampledNormalizedSquaredLengthCache,
|
||||||
std::vector<NearKeycodesSet> *sampledNearKeySets,
|
|
||||||
const ProximityInfo *const proximityInfo,
|
const ProximityInfo *const proximityInfo,
|
||||||
std::vector<hash_map_compat<int, float> > *charProbabilities);
|
std::vector<hash_map_compat<int, float> > *charProbabilities);
|
||||||
static void updateSampledSearchKeySets(const ProximityInfo *const proximityInfo,
|
static void updateSampledSearchKeySets(const ProximityInfo *const proximityInfo,
|
||||||
const int sampledInputSize, const int lastSavedInputSize,
|
const int sampledInputSize, const int lastSavedInputSize,
|
||||||
const std::vector<int> *const sampledLengthCache,
|
const std::vector<int> *const sampledLengthCache,
|
||||||
const std::vector<NearKeycodesSet> *const sampledNearKeySets,
|
const std::vector<hash_map_compat<int, float> > *const charProbabilities,
|
||||||
std::vector<NearKeycodesSet> *sampledSearchKeySets,
|
std::vector<NearKeycodesSet> *sampledSearchKeySets,
|
||||||
std::vector<std::vector<int> > *sampledSearchKeyVectors);
|
std::vector<std::vector<int> > *sampledSearchKeyVectors);
|
||||||
static float getPointToKeyByIdLength(const float maxPointToKeyLength,
|
static float getPointToKeyByIdLength(const float maxPointToKeyLength,
|
||||||
|
@ -87,7 +86,6 @@ class ProximityInfoStateUtils {
|
||||||
const int sampledInputSize, const int lastSavedInputSize, const bool isGeometric,
|
const int sampledInputSize, const int lastSavedInputSize, const bool isGeometric,
|
||||||
const std::vector<int> *const sampledInputXs,
|
const std::vector<int> *const sampledInputXs,
|
||||||
const std::vector<int> *const sampledInputYs,
|
const std::vector<int> *const sampledInputYs,
|
||||||
std::vector<NearKeycodesSet> *sampledNearKeySets,
|
|
||||||
std::vector<float> *sampledNormalizedSquaredLengthCache);
|
std::vector<float> *sampledNormalizedSquaredLengthCache);
|
||||||
static void initPrimaryInputWord(const int inputSize, const int *const inputProximities,
|
static void initPrimaryInputWord(const int inputSize, const int *const inputProximities,
|
||||||
int *primaryInputWord);
|
int *primaryInputWord);
|
||||||
|
|
Loading…
Reference in a new issue