Clean up int types in the Dictionary class
Change-Id: I49821c00186ce2a282bb23f369eb140b47d6c455main
parent
1d516fb1b0
commit
aa5a3e84ad
|
@ -146,8 +146,8 @@ int BigramDictionary::getBigrams(const int *prevWord, int prevWordLength, int *i
|
||||||
|
|
||||||
// Returns a pointer to the start of the bigram list.
|
// Returns a pointer to the start of the bigram list.
|
||||||
// If the word is not found or has no bigrams, this function returns 0.
|
// If the word is not found or has no bigrams, this function returns 0.
|
||||||
int BigramDictionary::getBigramListPositionForWord(const int32_t *prevWord,
|
int BigramDictionary::getBigramListPositionForWord(const int *prevWord, const int prevWordLength,
|
||||||
const int prevWordLength, const bool forceLowerCaseSearch) const {
|
const bool forceLowerCaseSearch) const {
|
||||||
if (0 >= prevWordLength) return 0;
|
if (0 >= prevWordLength) return 0;
|
||||||
const uint8_t *const root = DICT;
|
const uint8_t *const root = DICT;
|
||||||
int pos = BinaryFormat::getTerminalPosition(root, prevWord, prevWordLength,
|
int pos = BinaryFormat::getTerminalPosition(root, prevWord, prevWordLength,
|
||||||
|
@ -167,7 +167,7 @@ int BigramDictionary::getBigramListPositionForWord(const int32_t *prevWord,
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BigramDictionary::fillBigramAddressToFrequencyMapAndFilter(const int32_t *prevWord,
|
void BigramDictionary::fillBigramAddressToFrequencyMapAndFilter(const int *prevWord,
|
||||||
const int prevWordLength, std::map<int, int> *map, uint8_t *filter) const {
|
const int prevWordLength, std::map<int, int> *map, uint8_t *filter) const {
|
||||||
memset(filter, 0, BIGRAM_FILTER_BYTE_SIZE);
|
memset(filter, 0, BIGRAM_FILTER_BYTE_SIZE);
|
||||||
const uint8_t *const root = DICT;
|
const uint8_t *const root = DICT;
|
||||||
|
@ -207,7 +207,7 @@ bool BigramDictionary::checkFirstCharacter(int *word, int *inputCodes) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BigramDictionary::isValidBigram(const int32_t *word1, int length1, const int32_t *word2,
|
bool BigramDictionary::isValidBigram(const int *word1, int length1, const int *word2,
|
||||||
int length2) const {
|
int length2) const {
|
||||||
const uint8_t *const root = DICT;
|
const uint8_t *const root = DICT;
|
||||||
int pos = getBigramListPositionForWord(word1, length1, false /* forceLowerCaseSearch */);
|
int pos = getBigramListPositionForWord(word1, length1, false /* forceLowerCaseSearch */);
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
// TODO: Change the type of all keyCodes to uint32_t
|
|
||||||
Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, int maxWordLength,
|
Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, int maxWordLength,
|
||||||
int maxWords, int maxPredictions)
|
int maxWords, int maxPredictions)
|
||||||
: mDict(static_cast<unsigned char *>(dict)),
|
: mDict(static_cast<unsigned char *>(dict)),
|
||||||
|
@ -81,19 +80,18 @@ int Dictionary::getSuggestions(ProximityInfo *proximityInfo, void *traverseSessi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Dictionary::getBigrams(const int32_t *word, int length, int *codes, int codesSize,
|
int Dictionary::getBigrams(const int *word, int length, int *codes, int codesSize,
|
||||||
int *outWords, int *frequencies, int *outputTypes) const {
|
int *outWords, int *frequencies, int *outputTypes) const {
|
||||||
if (length <= 0) return 0;
|
if (length <= 0) return 0;
|
||||||
return mBigramDictionary->getBigrams(word, length, codes, codesSize, outWords, frequencies,
|
return mBigramDictionary->getBigrams(word, length, codes, codesSize, outWords, frequencies,
|
||||||
outputTypes);
|
outputTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Dictionary::getFrequency(const int32_t *word, int length) const {
|
int Dictionary::getFrequency(const int *word, int length) const {
|
||||||
return mUnigramDictionary->getFrequency(word, length);
|
return mUnigramDictionary->getFrequency(word, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Dictionary::isValidBigram(const int32_t *word1, int length1, const int32_t *word2,
|
bool Dictionary::isValidBigram(const int *word1, int length1, const int *word2, int length2) const {
|
||||||
int length2) const {
|
|
||||||
return mBigramDictionary->isValidBigram(word1, length1, word2, length2);
|
return mBigramDictionary->isValidBigram(word1, length1, word2, length2);
|
||||||
}
|
}
|
||||||
} // namespace latinime
|
} // namespace latinime
|
||||||
|
|
|
@ -50,11 +50,11 @@ class Dictionary {
|
||||||
bool useFullEditDistance, int *outWords, int *frequencies, int *spaceIndices,
|
bool useFullEditDistance, int *outWords, int *frequencies, int *spaceIndices,
|
||||||
int *outputTypes) const;
|
int *outputTypes) const;
|
||||||
|
|
||||||
int getBigrams(const int32_t *word, int length, int *codes, int codesSize, int *outWords,
|
int getBigrams(const int *word, int length, int *codes, int codesSize, int *outWords,
|
||||||
int *frequencies, int *outputTypes) const;
|
int *frequencies, int *outputTypes) const;
|
||||||
|
|
||||||
int getFrequency(const int32_t *word, int length) const;
|
int getFrequency(const int *word, int length) const;
|
||||||
bool isValidBigram(const int32_t *word1, int length1, const int32_t *word2, int length2) const;
|
bool isValidBigram(const int *word1, int length1, const int *word2, int length2) const;
|
||||||
const uint8_t *getDict() const { // required to release dictionary buffer
|
const uint8_t *getDict() const { // required to release dictionary buffer
|
||||||
return mDict;
|
return mDict;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue