s/hash_map_compat/unordered_map/
Change-Id: Icce5f9a12b04bdd7540c52750d303a585d71f28a
This commit is contained in:
parent
977d052f8c
commit
8ca9be17db
13 changed files with 41 additions and 66 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include "suggest/core/dictionary/multi_bigram_map.h"
|
#include "suggest/core/dictionary/multi_bigram_map.h"
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@ const int MultiBigramMap::BigramMap::DEFAULT_HASH_MAP_SIZE_FOR_EACH_BIGRAM_MAP =
|
||||||
int MultiBigramMap::getBigramProbability(
|
int MultiBigramMap::getBigramProbability(
|
||||||
const DictionaryStructureWithBufferPolicy *const structurePolicy,
|
const DictionaryStructureWithBufferPolicy *const structurePolicy,
|
||||||
const int wordPosition, const int nextWordPosition, const int unigramProbability) {
|
const int wordPosition, const int nextWordPosition, const int unigramProbability) {
|
||||||
hash_map_compat<int, BigramMap>::const_iterator mapPosition =
|
std::unordered_map<int, BigramMap>::const_iterator mapPosition =
|
||||||
mBigramMaps.find(wordPosition);
|
mBigramMaps.find(wordPosition);
|
||||||
if (mapPosition != mBigramMaps.end()) {
|
if (mapPosition != mBigramMaps.end()) {
|
||||||
return mapPosition->second.getBigramProbability(structurePolicy, nextWordPosition,
|
return mapPosition->second.getBigramProbability(structurePolicy, nextWordPosition,
|
||||||
|
@ -70,7 +71,7 @@ int MultiBigramMap::BigramMap::getBigramProbability(
|
||||||
const int nextWordPosition, const int unigramProbability) const {
|
const int nextWordPosition, const int unigramProbability) const {
|
||||||
int bigramProbability = NOT_A_PROBABILITY;
|
int bigramProbability = NOT_A_PROBABILITY;
|
||||||
if (mBloomFilter.isInFilter(nextWordPosition)) {
|
if (mBloomFilter.isInFilter(nextWordPosition)) {
|
||||||
const hash_map_compat<int, int>::const_iterator bigramProbabilityIt =
|
const std::unordered_map<int, int>::const_iterator bigramProbabilityIt =
|
||||||
mBigramMap.find(nextWordPosition);
|
mBigramMap.find(nextWordPosition);
|
||||||
if (bigramProbabilityIt != mBigramMap.end()) {
|
if (bigramProbabilityIt != mBigramMap.end()) {
|
||||||
bigramProbability = bigramProbabilityIt->second;
|
bigramProbability = bigramProbabilityIt->second;
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
#define LATINIME_MULTI_BIGRAM_MAP_H
|
#define LATINIME_MULTI_BIGRAM_MAP_H
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "suggest/core/dictionary/binary_dictionary_bigrams_iterator.h"
|
#include "suggest/core/dictionary/binary_dictionary_bigrams_iterator.h"
|
||||||
#include "suggest/core/dictionary/bloom_filter.h"
|
#include "suggest/core/dictionary/bloom_filter.h"
|
||||||
#include "suggest/core/policy/dictionary_structure_with_buffer_policy.h"
|
#include "suggest/core/policy/dictionary_structure_with_buffer_policy.h"
|
||||||
#include "utils/hash_map_compat.h"
|
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class MultiBigramMap {
|
||||||
// NOTE: The BigramMap class doesn't use DISALLOW_COPY_AND_ASSIGN() because its default
|
// NOTE: The BigramMap class doesn't use DISALLOW_COPY_AND_ASSIGN() because its default
|
||||||
// copy constructor is needed for use in hash_map.
|
// copy constructor is needed for use in hash_map.
|
||||||
static const int DEFAULT_HASH_MAP_SIZE_FOR_EACH_BIGRAM_MAP;
|
static const int DEFAULT_HASH_MAP_SIZE_FOR_EACH_BIGRAM_MAP;
|
||||||
hash_map_compat<int, int> mBigramMap;
|
std::unordered_map<int, int> mBigramMap;
|
||||||
BloomFilter mBloomFilter;
|
BloomFilter mBloomFilter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ class MultiBigramMap {
|
||||||
const int nextWordPosition, const int unigramProbability);
|
const int nextWordPosition, const int unigramProbability);
|
||||||
|
|
||||||
static const size_t MAX_CACHED_PREV_WORDS_IN_BIGRAM_MAP;
|
static const size_t MAX_CACHED_PREV_WORDS_IN_BIGRAM_MAP;
|
||||||
hash_map_compat<int, BigramMap> mBigramMaps;
|
std::unordered_map<int, BigramMap> mBigramMaps;
|
||||||
};
|
};
|
||||||
} // namespace latinime
|
} // namespace latinime
|
||||||
#endif // LATINIME_MULTI_BIGRAM_MAP_H
|
#endif // LATINIME_MULTI_BIGRAM_MAP_H
|
||||||
|
|
|
@ -17,10 +17,11 @@
|
||||||
#ifndef LATINIME_PROXIMITY_INFO_H
|
#ifndef LATINIME_PROXIMITY_INFO_H
|
||||||
#define LATINIME_PROXIMITY_INFO_H
|
#define LATINIME_PROXIMITY_INFO_H
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
#include "suggest/core/layout/proximity_info_utils.h"
|
#include "suggest/core/layout/proximity_info_utils.h"
|
||||||
#include "utils/hash_map_compat.h"
|
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
|
@ -114,7 +115,7 @@ class ProximityInfo {
|
||||||
// Sweet spots for geometric input. Note that we have extra sweet spots only for Y coordinates.
|
// Sweet spots for geometric input. Note that we have extra sweet spots only for Y coordinates.
|
||||||
float mSweetSpotCenterYsG[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
float mSweetSpotCenterYsG[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
||||||
float mSweetSpotRadii[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
float mSweetSpotRadii[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
||||||
hash_map_compat<int, int> mLowerCodePointToKeyMap;
|
std::unordered_map<int, int> mLowerCodePointToKeyMap;
|
||||||
int mKeyIndexToOriginalCodePoint[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
int mKeyIndexToOriginalCodePoint[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
||||||
int mKeyIndexToLowerCodePointG[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
int mKeyIndexToLowerCodePointG[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
||||||
int mCenterXsG[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
int mCenterXsG[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring> // for memset() and memmove()
|
#include <cstring> // for memset() and memmove()
|
||||||
#include <sstream> // for debug prints
|
#include <sstream> // for debug prints
|
||||||
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
@ -296,7 +297,7 @@ bool ProximityInfoState::hasSpaceProximity(const int index) const {
|
||||||
// Returns a probability of mapping index to keyIndex.
|
// Returns a probability of mapping index to keyIndex.
|
||||||
float ProximityInfoState::getProbability(const int index, const int keyIndex) const {
|
float ProximityInfoState::getProbability(const int index, const int keyIndex) const {
|
||||||
ASSERT(0 <= index && index < mSampledInputSize);
|
ASSERT(0 <= index && index < mSampledInputSize);
|
||||||
hash_map_compat<int, float>::const_iterator it = mCharProbabilities[index].find(keyIndex);
|
std::unordered_map<int, float>::const_iterator it = mCharProbabilities[index].find(keyIndex);
|
||||||
if (it != mCharProbabilities[index].end()) {
|
if (it != mCharProbabilities[index].end()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
#define LATINIME_PROXIMITY_INFO_STATE_H
|
#define LATINIME_PROXIMITY_INFO_STATE_H
|
||||||
|
|
||||||
#include <cstring> // for memset()
|
#include <cstring> // for memset()
|
||||||
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "suggest/core/layout/proximity_info_params.h"
|
#include "suggest/core/layout/proximity_info_params.h"
|
||||||
#include "suggest/core/layout/proximity_info_state_utils.h"
|
#include "suggest/core/layout/proximity_info_state_utils.h"
|
||||||
#include "utils/hash_map_compat.h"
|
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ class ProximityInfoState {
|
||||||
std::vector<float> mSpeedRates;
|
std::vector<float> mSpeedRates;
|
||||||
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<std::unordered_map<int, float> > mCharProbabilities;
|
||||||
// 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
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring> // for memset()
|
#include <cstring> // for memset()
|
||||||
#include <sstream> // for debug prints
|
#include <sstream> // for debug prints
|
||||||
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
@ -620,7 +621,7 @@ namespace latinime {
|
||||||
const std::vector<int> *const sampledLengthCache,
|
const std::vector<int> *const sampledLengthCache,
|
||||||
const std::vector<float> *const sampledNormalizedSquaredLengthCache,
|
const std::vector<float> *const sampledNormalizedSquaredLengthCache,
|
||||||
const ProximityInfo *const proximityInfo,
|
const ProximityInfo *const proximityInfo,
|
||||||
std::vector<hash_map_compat<int, float> > *charProbabilities) {
|
std::vector<std::unordered_map<int, float> > *charProbabilities) {
|
||||||
charProbabilities->resize(sampledInputSize);
|
charProbabilities->resize(sampledInputSize);
|
||||||
// Calculates probabilities of using a point as a correlated point with the character
|
// Calculates probabilities of using a point as a correlated point with the character
|
||||||
// for each point.
|
// for each point.
|
||||||
|
@ -762,7 +763,7 @@ namespace latinime {
|
||||||
sstream << "Speed: "<< (*sampledSpeedRates)[i] << ", ";
|
sstream << "Speed: "<< (*sampledSpeedRates)[i] << ", ";
|
||||||
sstream << "Angle: "<< getPointAngle(sampledInputXs, sampledInputYs, i) << ", \n";
|
sstream << "Angle: "<< getPointAngle(sampledInputXs, sampledInputYs, i) << ", \n";
|
||||||
|
|
||||||
for (hash_map_compat<int, float>::iterator it = (*charProbabilities)[i].begin();
|
for (std::unordered_map<int, float>::iterator it = (*charProbabilities)[i].begin();
|
||||||
it != (*charProbabilities)[i].end(); ++it) {
|
it != (*charProbabilities)[i].end(); ++it) {
|
||||||
if (it->first == NOT_AN_INDEX) {
|
if (it->first == NOT_AN_INDEX) {
|
||||||
sstream << it->first
|
sstream << it->first
|
||||||
|
@ -804,7 +805,7 @@ namespace latinime {
|
||||||
// Converting from raw probabilities to log probabilities to calculate spatial distance.
|
// Converting from raw probabilities to log probabilities to calculate spatial distance.
|
||||||
for (int i = start; i < sampledInputSize; ++i) {
|
for (int i = start; i < sampledInputSize; ++i) {
|
||||||
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);
|
std::unordered_map<int, float>::iterator it = (*charProbabilities)[i].find(j);
|
||||||
if (it == (*charProbabilities)[i].end()){
|
if (it == (*charProbabilities)[i].end()){
|
||||||
continue;
|
continue;
|
||||||
} else if(it->second < ProximityInfoParams::MIN_PROBABILITY) {
|
} else if(it->second < ProximityInfoParams::MIN_PROBABILITY) {
|
||||||
|
@ -821,7 +822,7 @@ 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 std::vector<int> *const sampledLengthCache,
|
const int lastSavedInputSize, const std::vector<int> *const sampledLengthCache,
|
||||||
const std::vector<hash_map_compat<int, float> > *const charProbabilities,
|
const std::vector<std::unordered_map<int, float> > *const charProbabilities,
|
||||||
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);
|
||||||
|
@ -867,7 +868,7 @@ namespace latinime {
|
||||||
/* static */ bool ProximityInfoStateUtils::suppressCharProbabilities(const int mostCommonKeyWidth,
|
/* static */ bool ProximityInfoStateUtils::suppressCharProbabilities(const int mostCommonKeyWidth,
|
||||||
const int sampledInputSize, const std::vector<int> *const lengthCache,
|
const int sampledInputSize, const std::vector<int> *const lengthCache,
|
||||||
const int index0, const int index1,
|
const int index0, const int index1,
|
||||||
std::vector<hash_map_compat<int, float> > *charProbabilities) {
|
std::vector<std::unordered_map<int, float> > *charProbabilities) {
|
||||||
ASSERT(0 <= index0 && index0 < sampledInputSize);
|
ASSERT(0 <= index0 && index0 < sampledInputSize);
|
||||||
ASSERT(0 <= index1 && index1 < sampledInputSize);
|
ASSERT(0 <= index1 && index1 < sampledInputSize);
|
||||||
const float keyWidthFloat = static_cast<float>(mostCommonKeyWidth);
|
const float keyWidthFloat = static_cast<float>(mostCommonKeyWidth);
|
||||||
|
@ -878,9 +879,9 @@ namespace latinime {
|
||||||
const float suppressionRate = ProximityInfoParams::MIN_SUPPRESSION_RATE
|
const float suppressionRate = ProximityInfoParams::MIN_SUPPRESSION_RATE
|
||||||
+ diff / keyWidthFloat / ProximityInfoParams::SUPPRESSION_LENGTH_WEIGHT
|
+ diff / keyWidthFloat / ProximityInfoParams::SUPPRESSION_LENGTH_WEIGHT
|
||||||
* ProximityInfoParams::SUPPRESSION_WEIGHT;
|
* ProximityInfoParams::SUPPRESSION_WEIGHT;
|
||||||
for (hash_map_compat<int, float>::iterator it = (*charProbabilities)[index0].begin();
|
for (std::unordered_map<int, float>::iterator it = (*charProbabilities)[index0].begin();
|
||||||
it != (*charProbabilities)[index0].end(); ++it) {
|
it != (*charProbabilities)[index0].end(); ++it) {
|
||||||
hash_map_compat<int, float>::iterator it2 = (*charProbabilities)[index1].find(it->first);
|
std::unordered_map<int, float>::iterator it2 = (*charProbabilities)[index1].find(it->first);
|
||||||
if (it2 != (*charProbabilities)[index1].end() && it->second < it2->second) {
|
if (it2 != (*charProbabilities)[index1].end() && it->second < it2->second) {
|
||||||
const float newProbability = it->second * suppressionRate;
|
const float newProbability = it->second * suppressionRate;
|
||||||
const float suppression = it->second - newProbability;
|
const float suppression = it->second - newProbability;
|
||||||
|
@ -932,7 +933,7 @@ namespace latinime {
|
||||||
// returns probability of generating the word.
|
// returns probability of generating the word.
|
||||||
/* static */ float ProximityInfoStateUtils::getMostProbableString(
|
/* static */ float ProximityInfoStateUtils::getMostProbableString(
|
||||||
const ProximityInfo *const proximityInfo, const int sampledInputSize,
|
const ProximityInfo *const proximityInfo, const int sampledInputSize,
|
||||||
const std::vector<hash_map_compat<int, float> > *const charProbabilities,
|
const std::vector<std::unordered_map<int, float> > *const charProbabilities,
|
||||||
int *const codePointBuf) {
|
int *const codePointBuf) {
|
||||||
ASSERT(sampledInputSize >= 0);
|
ASSERT(sampledInputSize >= 0);
|
||||||
memset(codePointBuf, 0, sizeof(codePointBuf[0]) * MAX_WORD_LENGTH);
|
memset(codePointBuf, 0, sizeof(codePointBuf[0]) * MAX_WORD_LENGTH);
|
||||||
|
@ -942,7 +943,7 @@ namespace latinime {
|
||||||
for (int i = 0; i < sampledInputSize && index < MAX_WORD_LENGTH - 1; ++i) {
|
for (int i = 0; i < sampledInputSize && index < MAX_WORD_LENGTH - 1; ++i) {
|
||||||
float minLogProbability = static_cast<float>(MAX_VALUE_FOR_WEIGHTING);
|
float minLogProbability = static_cast<float>(MAX_VALUE_FOR_WEIGHTING);
|
||||||
int character = NOT_AN_INDEX;
|
int character = NOT_AN_INDEX;
|
||||||
for (hash_map_compat<int, float>::const_iterator it = (*charProbabilities)[i].begin();
|
for (std::unordered_map<int, float>::const_iterator it = (*charProbabilities)[i].begin();
|
||||||
it != (*charProbabilities)[i].end(); ++it) {
|
it != (*charProbabilities)[i].end(); ++it) {
|
||||||
const float logProbability = (it->first != NOT_AN_INDEX)
|
const float logProbability = (it->first != NOT_AN_INDEX)
|
||||||
? it->second + ProximityInfoParams::DEMOTION_LOG_PROBABILITY : it->second;
|
? it->second + ProximityInfoParams::DEMOTION_LOG_PROBABILITY : it->second;
|
||||||
|
|
|
@ -18,10 +18,10 @@
|
||||||
#define LATINIME_PROXIMITY_INFO_STATE_UTILS_H
|
#define LATINIME_PROXIMITY_INFO_STATE_UTILS_H
|
||||||
|
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "utils/hash_map_compat.h"
|
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
class ProximityInfo;
|
class ProximityInfo;
|
||||||
|
@ -29,7 +29,7 @@ class ProximityInfoParams;
|
||||||
|
|
||||||
class ProximityInfoStateUtils {
|
class ProximityInfoStateUtils {
|
||||||
public:
|
public:
|
||||||
typedef hash_map_compat<int, float> NearKeysDistanceMap;
|
typedef std::unordered_map<int, float> NearKeysDistanceMap;
|
||||||
typedef std::bitset<MAX_KEY_COUNT_IN_A_KEYBOARD> NearKeycodesSet;
|
typedef std::bitset<MAX_KEY_COUNT_IN_A_KEYBOARD> NearKeycodesSet;
|
||||||
|
|
||||||
static int trimLastTwoTouchPoints(std::vector<int> *sampledInputXs,
|
static int trimLastTwoTouchPoints(std::vector<int> *sampledInputXs,
|
||||||
|
@ -72,11 +72,11 @@ class ProximityInfoStateUtils {
|
||||||
const std::vector<int> *const sampledLengthCache,
|
const std::vector<int> *const sampledLengthCache,
|
||||||
const std::vector<float> *const sampledNormalizedSquaredLengthCache,
|
const std::vector<float> *const sampledNormalizedSquaredLengthCache,
|
||||||
const ProximityInfo *const proximityInfo,
|
const ProximityInfo *const proximityInfo,
|
||||||
std::vector<hash_map_compat<int, float> > *charProbabilities);
|
std::vector<std::unordered_map<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<hash_map_compat<int, float> > *const charProbabilities,
|
const std::vector<std::unordered_map<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,
|
||||||
|
@ -105,7 +105,7 @@ class ProximityInfoStateUtils {
|
||||||
// TODO: Move to most_probable_string_utils.h
|
// TODO: Move to most_probable_string_utils.h
|
||||||
static float getMostProbableString(const ProximityInfo *const proximityInfo,
|
static float getMostProbableString(const ProximityInfo *const proximityInfo,
|
||||||
const int sampledInputSize,
|
const int sampledInputSize,
|
||||||
const std::vector<hash_map_compat<int, float> > *const charProbabilities,
|
const std::vector<std::unordered_map<int, float> > *const charProbabilities,
|
||||||
int *const codePointBuf);
|
int *const codePointBuf);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -147,7 +147,7 @@ class ProximityInfoStateUtils {
|
||||||
const int index2);
|
const int index2);
|
||||||
static bool suppressCharProbabilities(const int mostCommonKeyWidth,
|
static bool suppressCharProbabilities(const int mostCommonKeyWidth,
|
||||||
const int sampledInputSize, const std::vector<int> *const lengthCache, const int index0,
|
const int sampledInputSize, const std::vector<int> *const lengthCache, const int index0,
|
||||||
const int index1, std::vector<hash_map_compat<int, float> > *charProbabilities);
|
const int index1, std::vector<std::unordered_map<int, float> > *charProbabilities);
|
||||||
static float calculateSquaredDistanceFromSweetSpotCenter(
|
static float calculateSquaredDistanceFromSweetSpotCenter(
|
||||||
const ProximityInfo *const proximityInfo, const std::vector<int> *const sampledInputXs,
|
const ProximityInfo *const proximityInfo, const std::vector<int> *const sampledInputXs,
|
||||||
const std::vector<int> *const sampledInputYs, const int keyIndex,
|
const std::vector<int> *const sampledInputYs, const int keyIndex,
|
||||||
|
|
|
@ -18,18 +18,18 @@
|
||||||
#define LATINIME_PROXIMITY_INFO_UTILS_H
|
#define LATINIME_PROXIMITY_INFO_UTILS_H
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "suggest/core/layout/additional_proximity_chars.h"
|
#include "suggest/core/layout/additional_proximity_chars.h"
|
||||||
#include "suggest/core/layout/geometry_utils.h"
|
#include "suggest/core/layout/geometry_utils.h"
|
||||||
#include "utils/char_utils.h"
|
#include "utils/char_utils.h"
|
||||||
#include "utils/hash_map_compat.h"
|
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
class ProximityInfoUtils {
|
class ProximityInfoUtils {
|
||||||
public:
|
public:
|
||||||
static AK_FORCE_INLINE int getKeyIndexOf(const int keyCount, const int c,
|
static AK_FORCE_INLINE int getKeyIndexOf(const int keyCount, const int c,
|
||||||
const hash_map_compat<int, int> *const codeToKeyMap) {
|
const std::unordered_map<int, int> *const codeToKeyMap) {
|
||||||
if (keyCount == 0) {
|
if (keyCount == 0) {
|
||||||
// We do not have the coordinate data
|
// We do not have the coordinate data
|
||||||
return NOT_AN_INDEX;
|
return NOT_AN_INDEX;
|
||||||
|
@ -38,7 +38,7 @@ class ProximityInfoUtils {
|
||||||
return NOT_AN_INDEX;
|
return NOT_AN_INDEX;
|
||||||
}
|
}
|
||||||
const int lowerCode = CharUtils::toLowerCase(c);
|
const int lowerCode = CharUtils::toLowerCase(c);
|
||||||
hash_map_compat<int, int>::const_iterator mapPos = codeToKeyMap->find(lowerCode);
|
std::unordered_map<int, int>::const_iterator mapPos = codeToKeyMap->find(lowerCode);
|
||||||
if (mapPos != codeToKeyMap->end()) {
|
if (mapPos != codeToKeyMap->end()) {
|
||||||
return mapPos->second;
|
return mapPos->second;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ class ProximityInfoUtils {
|
||||||
const int *const proximityCharsArray, const int cellHeight, const int cellWidth,
|
const int *const proximityCharsArray, const int cellHeight, const int cellWidth,
|
||||||
const int gridWidth, const int mostCommonKeyWidth, const int keyCount,
|
const int gridWidth, const int mostCommonKeyWidth, const int keyCount,
|
||||||
const char *const localeStr,
|
const char *const localeStr,
|
||||||
const hash_map_compat<int, int> *const codeToKeyMap, int *inputProximities) {
|
const std::unordered_map<int, int> *const codeToKeyMap, int *inputProximities) {
|
||||||
// Initialize
|
// Initialize
|
||||||
// - mInputCodes
|
// - mInputCodes
|
||||||
// - mNormalizedSquaredDistances
|
// - mNormalizedSquaredDistances
|
||||||
|
@ -144,7 +144,7 @@ class ProximityInfoUtils {
|
||||||
const int *const proximityCharsArray, const int cellHeight, const int cellWidth,
|
const int *const proximityCharsArray, const int cellHeight, const int cellWidth,
|
||||||
const int gridWidth, const int mostCommonKeyWidth, const int keyCount,
|
const int gridWidth, const int mostCommonKeyWidth, const int keyCount,
|
||||||
const int x, const int y, const int primaryKey, const char *const localeStr,
|
const int x, const int y, const int primaryKey, const char *const localeStr,
|
||||||
const hash_map_compat<int, int> *const codeToKeyMap, int *proximities) {
|
const std::unordered_map<int, int> *const codeToKeyMap, int *proximities) {
|
||||||
const int mostCommonKeyWidthSquare = mostCommonKeyWidth * mostCommonKeyWidth;
|
const int mostCommonKeyWidthSquare = mostCommonKeyWidth * mostCommonKeyWidth;
|
||||||
int insertPos = 0;
|
int insertPos = 0;
|
||||||
proximities[insertPos++] = primaryKey;
|
proximities[insertPos++] = primaryKey;
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_reading_helper.h"
|
#include "suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_reading_helper.h"
|
||||||
#include "suggest/policyimpl/dictionary/structure/pt_common/pt_node_writer.h"
|
#include "suggest/policyimpl/dictionary/structure/pt_common/pt_node_writer.h"
|
||||||
#include "suggest/policyimpl/dictionary/utils/buffer_with_extendable_buffer.h"
|
#include "suggest/policyimpl/dictionary/utils/buffer_with_extendable_buffer.h"
|
||||||
#include "utils/hash_map_compat.h"
|
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "suggest/policyimpl/dictionary/structure/pt_common/pt_node_params.h"
|
#include "suggest/policyimpl/dictionary/structure/pt_common/pt_node_params.h"
|
||||||
#include "utils/hash_map_compat.h"
|
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
|
|
|
@ -17,18 +17,18 @@
|
||||||
#ifndef LATINIME_PT_NODE_WRITER_H
|
#ifndef LATINIME_PT_NODE_WRITER_H
|
||||||
#define LATINIME_PT_NODE_WRITER_H
|
#define LATINIME_PT_NODE_WRITER_H
|
||||||
|
|
||||||
#include "defines.h"
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "defines.h"
|
||||||
#include "suggest/policyimpl/dictionary/structure/pt_common/pt_node_params.h"
|
#include "suggest/policyimpl/dictionary/structure/pt_common/pt_node_params.h"
|
||||||
#include "utils/hash_map_compat.h"
|
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
// Interface class used to write PtNode information.
|
// Interface class used to write PtNode information.
|
||||||
class PtNodeWriter {
|
class PtNodeWriter {
|
||||||
public:
|
public:
|
||||||
typedef hash_map_compat<int, int> PtNodeArrayPositionRelocationMap;
|
typedef std::unordered_map<int, int> PtNodeArrayPositionRelocationMap;
|
||||||
typedef hash_map_compat<int, int> PtNodePositionRelocationMap;
|
typedef std::unordered_map<int, int> PtNodePositionRelocationMap;
|
||||||
struct DictPositionRelocationMap {
|
struct DictPositionRelocationMap {
|
||||||
public:
|
public:
|
||||||
DictPositionRelocationMap()
|
DictPositionRelocationMap()
|
||||||
|
|
|
@ -17,16 +17,17 @@
|
||||||
#ifndef LATINIME_TERMINAL_POSITION_LOOKUP_TABLE_H
|
#ifndef LATINIME_TERMINAL_POSITION_LOOKUP_TABLE_H
|
||||||
#define LATINIME_TERMINAL_POSITION_LOOKUP_TABLE_H
|
#define LATINIME_TERMINAL_POSITION_LOOKUP_TABLE_H
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "suggest/policyimpl/dictionary/structure/v4/content/single_dict_content.h"
|
#include "suggest/policyimpl/dictionary/structure/v4/content/single_dict_content.h"
|
||||||
#include "suggest/policyimpl/dictionary/structure/v4/ver4_dict_constants.h"
|
#include "suggest/policyimpl/dictionary/structure/v4/ver4_dict_constants.h"
|
||||||
#include "utils/hash_map_compat.h"
|
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
class TerminalPositionLookupTable : public SingleDictContent {
|
class TerminalPositionLookupTable : public SingleDictContent {
|
||||||
public:
|
public:
|
||||||
typedef hash_map_compat<int, int> TerminalIdMap;
|
typedef std::unordered_map<int, int> TerminalIdMap;
|
||||||
|
|
||||||
TerminalPositionLookupTable(const char *const dictPath, const bool isUpdatable)
|
TerminalPositionLookupTable(const char *const dictPath, const bool isUpdatable)
|
||||||
: SingleDictContent(dictPath,
|
: SingleDictContent(dictPath,
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2012 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef LATINIME_HASH_MAP_COMPAT_H
|
|
||||||
#define LATINIME_HASH_MAP_COMPAT_H
|
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#define hash_map_compat std::unordered_map
|
|
||||||
|
|
||||||
#if 0 // TODO: Use this instead of the above macro.
|
|
||||||
template <typename TKey, typename TValue> using hash_map_compat = std::unordered_map<TKey, TValue>;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // LATINIME_HASH_MAP_COMPAT_H
|
|
Loading…
Reference in a new issue