mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Remove a constant parameter (A105)
Change-Id: I8a09fa2f0649880c943364699a07652e47dede22
This commit is contained in:
parent
b7d7c5a369
commit
1a69ad5a10
@ -38,7 +38,7 @@ BigramDictionary::~BigramDictionary() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequency,
|
bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequency,
|
||||||
const int maxBigrams, int *bigramFreq, unsigned short *bigramChars) const {
|
int *bigramFreq, unsigned short *bigramChars) const {
|
||||||
word[length] = 0;
|
word[length] = 0;
|
||||||
if (DEBUG_DICT) {
|
if (DEBUG_DICT) {
|
||||||
#ifdef FLAG_DBG
|
#ifdef FLAG_DBG
|
||||||
@ -50,7 +50,7 @@ bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequ
|
|||||||
|
|
||||||
// Find the right insertion point
|
// Find the right insertion point
|
||||||
int insertAt = 0;
|
int insertAt = 0;
|
||||||
while (insertAt < maxBigrams) {
|
while (insertAt < MAX_PREDICTIONS) {
|
||||||
if (frequency > bigramFreq[insertAt] || (bigramFreq[insertAt] == frequency
|
if (frequency > bigramFreq[insertAt] || (bigramFreq[insertAt] == frequency
|
||||||
&& length < Dictionary::wideStrLen(bigramChars + insertAt * MAX_WORD_LENGTH))) {
|
&& length < Dictionary::wideStrLen(bigramChars + insertAt * MAX_WORD_LENGTH))) {
|
||||||
break;
|
break;
|
||||||
@ -58,16 +58,16 @@ bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequ
|
|||||||
insertAt++;
|
insertAt++;
|
||||||
}
|
}
|
||||||
if (DEBUG_DICT) {
|
if (DEBUG_DICT) {
|
||||||
AKLOGI("Bigram: InsertAt -> %d maxBigrams: %d", insertAt, maxBigrams);
|
AKLOGI("Bigram: InsertAt -> %d MAX_PREDICTIONS: %d", insertAt, MAX_PREDICTIONS);
|
||||||
}
|
}
|
||||||
if (insertAt < maxBigrams) {
|
if (insertAt < MAX_PREDICTIONS) {
|
||||||
memmove((char*) bigramFreq + (insertAt + 1) * sizeof(bigramFreq[0]),
|
memmove((char*) bigramFreq + (insertAt + 1) * sizeof(bigramFreq[0]),
|
||||||
(char*) bigramFreq + insertAt * sizeof(bigramFreq[0]),
|
(char*) bigramFreq + insertAt * sizeof(bigramFreq[0]),
|
||||||
(maxBigrams - insertAt - 1) * sizeof(bigramFreq[0]));
|
(MAX_PREDICTIONS - insertAt - 1) * sizeof(bigramFreq[0]));
|
||||||
bigramFreq[insertAt] = frequency;
|
bigramFreq[insertAt] = frequency;
|
||||||
memmove((char*) bigramChars + (insertAt + 1) * MAX_WORD_LENGTH * sizeof(short),
|
memmove((char*) bigramChars + (insertAt + 1) * MAX_WORD_LENGTH * sizeof(short),
|
||||||
(char*) bigramChars + (insertAt ) * MAX_WORD_LENGTH * sizeof(short),
|
(char*) bigramChars + (insertAt ) * MAX_WORD_LENGTH * sizeof(short),
|
||||||
(maxBigrams - insertAt - 1) * sizeof(short) * MAX_WORD_LENGTH);
|
(MAX_PREDICTIONS - insertAt - 1) * sizeof(short) * MAX_WORD_LENGTH);
|
||||||
unsigned short *dest = bigramChars + (insertAt ) * MAX_WORD_LENGTH;
|
unsigned short *dest = bigramChars + (insertAt ) * MAX_WORD_LENGTH;
|
||||||
while (length--) {
|
while (length--) {
|
||||||
*dest++ = *word++;
|
*dest++ = *word++;
|
||||||
@ -137,7 +137,7 @@ int BigramDictionary::getBigrams(const int32_t *prevWord, int prevWordLength, in
|
|||||||
const int frequency =
|
const int frequency =
|
||||||
BinaryFormat::computeFrequencyForBigram(unigramFreq, bigramFreqTemp);
|
BinaryFormat::computeFrequencyForBigram(unigramFreq, bigramFreqTemp);
|
||||||
if (addWordBigram(
|
if (addWordBigram(
|
||||||
bigramBuffer, length, frequency, maxBigrams, bigramFreq, bigramChars)) {
|
bigramBuffer, length, frequency, bigramFreq, bigramChars)) {
|
||||||
++bigramCount;
|
++bigramCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ class BigramDictionary {
|
|||||||
~BigramDictionary();
|
~BigramDictionary();
|
||||||
private:
|
private:
|
||||||
DISALLOW_IMPLICIT_CONSTRUCTORS(BigramDictionary);
|
DISALLOW_IMPLICIT_CONSTRUCTORS(BigramDictionary);
|
||||||
bool addWordBigram(unsigned short *word, int length, int frequency, const int maxBigrams,
|
bool addWordBigram(unsigned short *word, int length, int frequency,
|
||||||
int *bigramFreq, unsigned short *bigramChars) const;
|
int *bigramFreq, unsigned short *bigramChars) const;
|
||||||
int getBigramAddress(int *pos, bool advance);
|
int getBigramAddress(int *pos, bool advance);
|
||||||
int getBigramFreq(int *pos);
|
int getBigramFreq(int *pos);
|
||||||
|
Loading…
Reference in New Issue
Block a user