am 9fb6f47a: New LOG lib
* commit '9fb6f47a6a11f62d134d4d6259181ac987fc1ad3': New LOG libmain
commit
53d4dd39e9
|
@ -51,7 +51,7 @@ static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
|
|||
PROF_START(66);
|
||||
const char *sourceDirChars = env->GetStringUTFChars(sourceDir, 0);
|
||||
if (sourceDirChars == 0) {
|
||||
LOGE("DICT: Can't get sourceDir string");
|
||||
AKLOGE("DICT: Can't get sourceDir string");
|
||||
return 0;
|
||||
}
|
||||
int fd = 0;
|
||||
|
@ -61,7 +61,7 @@ static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
|
|||
/* mmap version */
|
||||
fd = open(sourceDirChars, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
LOGE("DICT: Can't open sourceDir. sourceDirChars=%s errno=%d", sourceDirChars, errno);
|
||||
AKLOGE("DICT: Can't open sourceDir. sourceDirChars=%s errno=%d", sourceDirChars, errno);
|
||||
return 0;
|
||||
}
|
||||
int pagesize = getpagesize();
|
||||
|
@ -70,7 +70,7 @@ static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
|
|||
int adjDictSize = dictSize + adjust;
|
||||
dictBuf = mmap(0, sizeof(char) * adjDictSize, PROT_READ, MAP_PRIVATE, fd, adjDictOffset);
|
||||
if (dictBuf == MAP_FAILED) {
|
||||
LOGE("DICT: Can't mmap dictionary. errno=%d", errno);
|
||||
AKLOGE("DICT: Can't mmap dictionary. errno=%d", errno);
|
||||
return 0;
|
||||
}
|
||||
dictBuf = (void *)((char *)dictBuf + adjust);
|
||||
|
@ -79,39 +79,39 @@ static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
|
|||
FILE *file = 0;
|
||||
file = fopen(sourceDirChars, "rb");
|
||||
if (file == 0) {
|
||||
LOGE("DICT: Can't fopen sourceDir. sourceDirChars=%s errno=%d", sourceDirChars, errno);
|
||||
AKLOGE("DICT: Can't fopen sourceDir. sourceDirChars=%s errno=%d", sourceDirChars, errno);
|
||||
return 0;
|
||||
}
|
||||
dictBuf = malloc(sizeof(char) * dictSize);
|
||||
if (!dictBuf) {
|
||||
LOGE("DICT: Can't allocate memory region for dictionary. errno=%d", errno);
|
||||
AKLOGE("DICT: Can't allocate memory region for dictionary. errno=%d", errno);
|
||||
return 0;
|
||||
}
|
||||
int ret = fseek(file, (long)dictOffset, SEEK_SET);
|
||||
if (ret != 0) {
|
||||
LOGE("DICT: Failure in fseek. ret=%d errno=%d", ret, errno);
|
||||
AKLOGE("DICT: Failure in fseek. ret=%d errno=%d", ret, errno);
|
||||
return 0;
|
||||
}
|
||||
ret = fread(dictBuf, sizeof(char) * dictSize, 1, file);
|
||||
if (ret != 1) {
|
||||
LOGE("DICT: Failure in fread. ret=%d errno=%d", ret, errno);
|
||||
AKLOGE("DICT: Failure in fread. ret=%d errno=%d", ret, errno);
|
||||
return 0;
|
||||
}
|
||||
ret = fclose(file);
|
||||
if (ret != 0) {
|
||||
LOGE("DICT: Failure in fclose. ret=%d errno=%d", ret, errno);
|
||||
AKLOGE("DICT: Failure in fclose. ret=%d errno=%d", ret, errno);
|
||||
return 0;
|
||||
}
|
||||
#endif // USE_MMAP_FOR_DICTIONARY
|
||||
env->ReleaseStringUTFChars(sourceDir, sourceDirChars);
|
||||
|
||||
if (!dictBuf) {
|
||||
LOGE("DICT: dictBuf is null");
|
||||
AKLOGE("DICT: dictBuf is null");
|
||||
return 0;
|
||||
}
|
||||
Dictionary *dictionary = 0;
|
||||
if (BinaryFormat::UNKNOWN_FORMAT == BinaryFormat::detectFormat((uint8_t*)dictBuf)) {
|
||||
LOGE("DICT: dictionary format is unknown, bad magic number");
|
||||
AKLOGE("DICT: dictionary format is unknown, bad magic number");
|
||||
#ifdef USE_MMAP_FOR_DICTIONARY
|
||||
releaseDictBuf(((char*)dictBuf) - adjust, adjDictSize, fd);
|
||||
#else // USE_MMAP_FOR_DICTIONARY
|
||||
|
@ -230,11 +230,11 @@ void releaseDictBuf(void* dictBuf, const size_t length, int fd) {
|
|||
#ifdef USE_MMAP_FOR_DICTIONARY
|
||||
int ret = munmap(dictBuf, length);
|
||||
if (ret != 0) {
|
||||
LOGE("DICT: Failure in munmap. ret=%d errno=%d", ret, errno);
|
||||
AKLOGE("DICT: Failure in munmap. ret=%d errno=%d", ret, errno);
|
||||
}
|
||||
ret = close(fd);
|
||||
if (ret != 0) {
|
||||
LOGE("DICT: Failure in close. ret=%d errno=%d", ret, errno);
|
||||
AKLOGE("DICT: Failure in close. ret=%d errno=%d", ret, errno);
|
||||
}
|
||||
#else // USE_MMAP_FOR_DICTIONARY
|
||||
free(dictBuf);
|
||||
|
|
|
@ -36,18 +36,18 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
|||
jint result = -1;
|
||||
|
||||
if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
|
||||
LOGE("ERROR: GetEnv failed");
|
||||
AKLOGE("ERROR: GetEnv failed");
|
||||
goto bail;
|
||||
}
|
||||
assert(env != 0);
|
||||
|
||||
if (!register_BinaryDictionary(env)) {
|
||||
LOGE("ERROR: BinaryDictionary native registration failed");
|
||||
AKLOGE("ERROR: BinaryDictionary native registration failed");
|
||||
goto bail;
|
||||
}
|
||||
|
||||
if (!register_ProximityInfo(env)) {
|
||||
LOGE("ERROR: ProximityInfo native registration failed");
|
||||
AKLOGE("ERROR: ProximityInfo native registration failed");
|
||||
goto bail;
|
||||
}
|
||||
|
||||
|
@ -64,11 +64,11 @@ int registerNativeMethods(JNIEnv* env, const char* className, JNINativeMethod* m
|
|||
int numMethods) {
|
||||
jclass clazz = env->FindClass(className);
|
||||
if (clazz == 0) {
|
||||
LOGE("Native registration unable to find class '%s'", className);
|
||||
AKLOGE("Native registration unable to find class '%s'", className);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
if (env->RegisterNatives(clazz, methods, numMethods) < 0) {
|
||||
LOGE("RegisterNatives failed for '%s'", className);
|
||||
AKLOGE("RegisterNatives failed for '%s'", className);
|
||||
env->DeleteLocalRef(clazz);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ BigramDictionary::BigramDictionary(const unsigned char *dict, int maxWordLength,
|
|||
MAX_ALTERNATIVES(maxAlternatives), IS_LATEST_DICT_VERSION(isLatestDictVersion),
|
||||
HAS_BIGRAM(hasBigram), mParentDictionary(parentDictionary) {
|
||||
if (DEBUG_DICT) {
|
||||
LOGI("BigramDictionary - constructor");
|
||||
LOGI("Has Bigram : %d", hasBigram);
|
||||
AKLOGI("BigramDictionary - constructor");
|
||||
AKLOGI("Has Bigram : %d", hasBigram);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequ
|
|||
#ifdef FLAG_DBG
|
||||
char s[length + 1];
|
||||
for (int i = 0; i <= length; i++) s[i] = word[i];
|
||||
LOGI("Bigram: Found word = %s, freq = %d :", s, frequency);
|
||||
AKLOGI("Bigram: Found word = %s, freq = %d :", s, frequency);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequ
|
|||
insertAt++;
|
||||
}
|
||||
if (DEBUG_DICT) {
|
||||
LOGI("Bigram: InsertAt -> %d maxBigrams: %d", insertAt, mMaxBigrams);
|
||||
AKLOGI("Bigram: InsertAt -> %d maxBigrams: %d", insertAt, mMaxBigrams);
|
||||
}
|
||||
if (insertAt < mMaxBigrams) {
|
||||
memmove((char*) mBigramFreq + (insertAt + 1) * sizeof(mBigramFreq[0]),
|
||||
|
@ -76,7 +76,7 @@ bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequ
|
|||
}
|
||||
*dest = 0; // NULL terminate
|
||||
if (DEBUG_DICT) {
|
||||
LOGI("Bigram: Added word at %d", insertAt);
|
||||
AKLOGI("Bigram: Added word at %d", insertAt);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ inline static void initEditDistance(int *editDistanceTable) {
|
|||
inline static void dumpEditDistance10ForDebug(int *editDistanceTable, const int inputLength,
|
||||
const int outputLength) {
|
||||
if (DEBUG_DICT) {
|
||||
LOGI("EditDistanceTable");
|
||||
AKLOGI("EditDistanceTable");
|
||||
for (int i = 0; i <= 10; ++i) {
|
||||
int c[11];
|
||||
for (int j = 0; j <= 10; ++j) {
|
||||
|
@ -52,7 +52,7 @@ inline static void dumpEditDistance10ForDebug(int *editDistanceTable, const int
|
|||
c[j] = -1;
|
||||
}
|
||||
}
|
||||
LOGI("[ %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d ]",
|
||||
AKLOGI("[ %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d ]",
|
||||
c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[10]);
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ inline static void calcEditDistanceOneStep(int *editDistanceTable, const unsigne
|
|||
inline static int getCurrentEditDistance(
|
||||
int *editDistanceTable, const int inputLength, const int outputLength) {
|
||||
if (DEBUG_DICT) {
|
||||
LOGI("getCurrentEditDistance %d, %d", inputLength, outputLength);
|
||||
AKLOGI("getCurrentEditDistance %d, %d", inputLength, outputLength);
|
||||
}
|
||||
return editDistanceTable[(inputLength + 1) * (outputLength + 1) - 1];
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ Correction::CorrectionType Correction::processCharAndCalcState(
|
|||
--mTransposedCount;
|
||||
if (DEBUG_CORRECTION) {
|
||||
DUMP_WORD(mWord, mOutputIndex);
|
||||
LOGI("UNRELATED(0): %d, %d, %d, %d, %c", mProximityCount, mSkippedCount,
|
||||
AKLOGI("UNRELATED(0): %d, %d, %d, %d, %c", mProximityCount, mSkippedCount,
|
||||
mTransposedCount, mExcessiveCount, c);
|
||||
}
|
||||
return UNRELATED;
|
||||
|
@ -404,7 +404,7 @@ Correction::CorrectionType Correction::processCharAndCalcState(
|
|||
&& isEquivalentChar(mProximityInfo->getMatchedProximityId(
|
||||
mInputIndex, mWord[mOutputIndex - 1], false))) {
|
||||
if (DEBUG_CORRECTION) {
|
||||
LOGI("CONVERSION p->e %c", mWord[mOutputIndex - 1]);
|
||||
AKLOGI("CONVERSION p->e %c", mWord[mOutputIndex - 1]);
|
||||
}
|
||||
// Conversion p->e
|
||||
// Example:
|
||||
|
@ -481,7 +481,7 @@ Correction::CorrectionType Correction::processCharAndCalcState(
|
|||
} else {
|
||||
if (DEBUG_CORRECTION) {
|
||||
DUMP_WORD(mWord, mOutputIndex);
|
||||
LOGI("UNRELATED(1): %d, %d, %d, %d, %c", mProximityCount, mSkippedCount,
|
||||
AKLOGI("UNRELATED(1): %d, %d, %d, %d, %c", mProximityCount, mSkippedCount,
|
||||
mTransposedCount, mExcessiveCount, c);
|
||||
}
|
||||
return UNRELATED;
|
||||
|
@ -534,7 +534,7 @@ Correction::CorrectionType Correction::processCharAndCalcState(
|
|||
mTerminalOutputIndex = mOutputIndex - 1;
|
||||
if (DEBUG_CORRECTION) {
|
||||
DUMP_WORD(mWord, mOutputIndex);
|
||||
LOGI("ONTERMINAL(1): %d, %d, %d, %d, %c", mProximityCount, mSkippedCount,
|
||||
AKLOGI("ONTERMINAL(1): %d, %d, %d, %d, %c", mProximityCount, mSkippedCount,
|
||||
mTransposedCount, mExcessiveCount, c);
|
||||
}
|
||||
return ON_TERMINAL;
|
||||
|
@ -703,7 +703,7 @@ int Correction::RankingAlgorithm::calculateFinalFreq(const int inputIndex, const
|
|||
/ (10 * inputLength
|
||||
- WORDS_WITH_MISSING_CHARACTER_DEMOTION_START_POS_10X + 10);
|
||||
if (DEBUG_DICT_FULL) {
|
||||
LOGI("Demotion rate for missing character is %d.", demotionRate);
|
||||
AKLOGI("Demotion rate for missing character is %d.", demotionRate);
|
||||
}
|
||||
multiplyRate(demotionRate, &finalFreq);
|
||||
}
|
||||
|
@ -717,7 +717,7 @@ int Correction::RankingAlgorithm::calculateFinalFreq(const int inputIndex, const
|
|||
multiplyRate(WORDS_WITH_EXCESSIVE_CHARACTER_DEMOTION_RATE, &finalFreq);
|
||||
if (!lastCharExceeded && !proximityInfo->existsAdjacentProximityChars(excessivePos)) {
|
||||
if (DEBUG_CORRECTION_FREQ) {
|
||||
LOGI("Double excessive demotion");
|
||||
AKLOGI("Double excessive demotion");
|
||||
}
|
||||
// If an excessive character is not adjacent to the left char or the right char,
|
||||
// we will demote this word.
|
||||
|
@ -767,7 +767,7 @@ int Correction::RankingAlgorithm::calculateFinalFreq(const int inputIndex, const
|
|||
for (int i = 0; i < adjustedProximityMatchedCount; ++i) {
|
||||
// A word with proximity corrections
|
||||
if (DEBUG_DICT_FULL) {
|
||||
LOGI("Found a proximity correction.");
|
||||
AKLOGI("Found a proximity correction.");
|
||||
}
|
||||
multiplyIntCapped(typedLetterMultiplier, &finalFreq);
|
||||
multiplyRate(WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq);
|
||||
|
@ -828,12 +828,12 @@ int Correction::RankingAlgorithm::calculateFinalFreq(const int inputIndex, const
|
|||
}
|
||||
|
||||
if (DEBUG_DICT_FULL) {
|
||||
LOGI("calc: %d, %d", outputIndex, sameLength);
|
||||
AKLOGI("calc: %d, %d", outputIndex, sameLength);
|
||||
}
|
||||
|
||||
if (DEBUG_CORRECTION_FREQ) {
|
||||
DUMP_WORD(correction->mWord, outputIndex + 1);
|
||||
LOGI("FinalFreq: [P%d, S%d, T%d, E%d] %d, %d, %d, %d, %d", proximityMatchedCount,
|
||||
AKLOGI("FinalFreq: [P%d, S%d, T%d, E%d] %d, %d, %d, %d, %d", proximityMatchedCount,
|
||||
skippedCount, transposedCount, excessiveCount, lastCharExceeded, sameLength,
|
||||
quoteDiffCount, ed, finalFreq);
|
||||
}
|
||||
|
@ -874,7 +874,8 @@ int Correction::RankingAlgorithm::calcFreqForSplitTwoWords(
|
|||
firstCapitalizedWordDemotion ^ secondCapitalizedWordDemotion;
|
||||
|
||||
if (DEBUG_DICT_FULL) {
|
||||
LOGI("Two words: %c, %c, %d", word[0], word[firstWordLength + 1], capitalizedWordDemotion);
|
||||
AKLOGI("Two words: %c, %c, %d",
|
||||
word[0], word[firstWordLength + 1], capitalizedWordDemotion);
|
||||
}
|
||||
|
||||
if (firstWordLength == 0 || secondWordLength == 0) {
|
||||
|
@ -919,7 +920,7 @@ int Correction::RankingAlgorithm::calcFreqForSplitTwoWords(
|
|||
if (isSpaceProximity) {
|
||||
// A word pair with one space proximity correction
|
||||
if (DEBUG_DICT) {
|
||||
LOGI("Found a word pair with space proximity correction.");
|
||||
AKLOGI("Found a word pair with space proximity correction.");
|
||||
}
|
||||
multiplyIntCapped(typedLetterMultiplier, &totalFreq);
|
||||
multiplyRate(WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE, &totalFreq);
|
||||
|
@ -965,10 +966,10 @@ inline static int editDistanceInternal(
|
|||
}
|
||||
|
||||
if (DEBUG_EDIT_DISTANCE) {
|
||||
LOGI("IN = %d, OUT = %d", beforeLength, afterLength);
|
||||
AKLOGI("IN = %d, OUT = %d", beforeLength, afterLength);
|
||||
for (int i = 0; i < li; ++i) {
|
||||
for (int j = 0; j < lo; ++j) {
|
||||
LOGI("EDIT[%d][%d], %d", i, j, dp[i * lo + j]);
|
||||
AKLOGI("EDIT[%d][%d], %d", i, j, dp[i * lo + j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ static inline unsigned char* convertToUnibyteStringAndReplaceLastChar(unsigned s
|
|||
static inline void LOGI_S16(unsigned short* string, const unsigned int length) {
|
||||
unsigned char tmp_buffer[length];
|
||||
convertToUnibyteString(string, tmp_buffer, length);
|
||||
LOGI(">> %s", tmp_buffer);
|
||||
AKLOGI(">> %s", tmp_buffer);
|
||||
// The log facility is throwing out log that comes too fast. The following
|
||||
// is a dirty way of slowing down processing so that we can see all log.
|
||||
// TODO : refactor this in a blocking log or something.
|
||||
|
@ -53,7 +53,7 @@ static inline void LOGI_S16_PLUS(unsigned short* string, const unsigned int leng
|
|||
unsigned char c) {
|
||||
unsigned char tmp_buffer[length+1];
|
||||
convertToUnibyteStringAndReplaceLastChar(string, tmp_buffer, length, c);
|
||||
LOGI(">> %s", tmp_buffer);
|
||||
AKLOGI(">> %s", tmp_buffer);
|
||||
// Likewise
|
||||
// usleep(10);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ static inline void printDebug(const char* tag, int* codes, int codesSize, int MA
|
|||
buf[codesSize] = 0;
|
||||
while (--codesSize >= 0)
|
||||
buf[codesSize] = (unsigned char)codes[codesSize * MAX_PROXIMITY_CHARS];
|
||||
LOGI("%s, WORD = %s", tag, buf);
|
||||
AKLOGI("%s, WORD = %s", tag, buf);
|
||||
|
||||
free(buf);
|
||||
}
|
||||
|
|
|
@ -20,15 +20,18 @@
|
|||
|
||||
#if defined(FLAG_DO_PROFILE) || defined(FLAG_DBG)
|
||||
#include <cutils/log.h>
|
||||
#define AKLOGE ALOGE
|
||||
#define AKLOGI ALOGI
|
||||
#else
|
||||
#define LOGE(fmt, ...)
|
||||
#define LOGI(fmt, ...)
|
||||
#define AKLOGE(fmt, ...)
|
||||
#define AKLOGI(fmt, ...)
|
||||
#endif
|
||||
|
||||
#ifdef FLAG_DO_PROFILE
|
||||
// Profiler
|
||||
#include <cutils/log.h>
|
||||
#include <time.h>
|
||||
|
||||
#define PROF_BUF_SIZE 100
|
||||
static double profile_buf[PROF_BUF_SIZE];
|
||||
static double profile_old[PROF_BUF_SIZE];
|
||||
|
@ -42,8 +45,8 @@ static unsigned int profile_counter[PROF_BUF_SIZE];
|
|||
#define PROF_CLOSE do { PROF_END(PROF_BUF_SIZE - 1); PROF_OUTALL; } while(0)
|
||||
#define PROF_END(prof_buf_id) profile_buf[prof_buf_id] += ((clock()) - profile_old[prof_buf_id])
|
||||
#define PROF_CLOCKOUT(prof_buf_id) \
|
||||
LOGI("%s : clock is %f", __FUNCTION__, (clock() - profile_old[prof_buf_id]))
|
||||
#define PROF_OUTALL do { LOGI("--- %s ---", __FUNCTION__); prof_out(); } while(0)
|
||||
AKLOGI("%s : clock is %f", __FUNCTION__, (clock() - profile_old[prof_buf_id]))
|
||||
#define PROF_OUTALL do { AKLOGI("--- %s ---", __FUNCTION__); prof_out(); } while(0)
|
||||
|
||||
static void prof_reset(void) {
|
||||
for (int i = 0; i < PROF_BUF_SIZE; ++i) {
|
||||
|
@ -55,9 +58,9 @@ static void prof_reset(void) {
|
|||
|
||||
static void prof_out(void) {
|
||||
if (profile_counter[PROF_BUF_SIZE - 1] != 1) {
|
||||
LOGI("Error: You must call PROF_OPEN before PROF_CLOSE.");
|
||||
AKLOGI("Error: You must call PROF_OPEN before PROF_CLOSE.");
|
||||
}
|
||||
LOGI("Total time is %6.3f ms.",
|
||||
AKLOGI("Total time is %6.3f ms.",
|
||||
profile_buf[PROF_BUF_SIZE - 1] * 1000 / (double)CLOCKS_PER_SEC);
|
||||
double all = 0;
|
||||
for (int i = 0; i < PROF_BUF_SIZE - 1; ++i) {
|
||||
|
@ -66,7 +69,7 @@ static void prof_out(void) {
|
|||
if (all == 0) all = 1;
|
||||
for (int i = 0; i < PROF_BUF_SIZE - 1; ++i) {
|
||||
if (profile_buf[i] != 0) {
|
||||
LOGI("(%d): Used %4.2f%%, %8.4f ms. Called %d times.",
|
||||
AKLOGI("(%d): Used %4.2f%%, %8.4f ms. Called %d times.",
|
||||
i, (profile_buf[i] * 100 / all),
|
||||
profile_buf[i] * 1000 / (double)CLOCKS_PER_SEC, profile_counter[i]);
|
||||
}
|
||||
|
@ -112,7 +115,7 @@ static void dumpWord(const unsigned short* word, const int length) {
|
|||
charBuf[i] = word[i];
|
||||
}
|
||||
charBuf[length] = 0;
|
||||
LOGI("[ %s ]", charBuf);
|
||||
AKLOGI("[ %s ]", charBuf);
|
||||
}
|
||||
|
||||
#else // FLAG_DBG
|
||||
|
|
|
@ -33,9 +33,9 @@ Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
|
|||
IS_LATEST_DICT_VERSION((((unsigned char*) dict)[0] & 0xFF) >= DICTIONARY_VERSION_MIN) {
|
||||
if (DEBUG_DICT) {
|
||||
if (MAX_WORD_LENGTH_INTERNAL < maxWordLength) {
|
||||
LOGI("Max word length (%d) is greater than %d",
|
||||
AKLOGI("Max word length (%d) is greater than %d",
|
||||
maxWordLength, MAX_WORD_LENGTH_INTERNAL);
|
||||
LOGI("IN NATIVE SUGGEST Version: %d", (mDict[0] & 0xFF));
|
||||
AKLOGI("IN NATIVE SUGGEST Version: %d", (mDict[0] & 0xFF));
|
||||
}
|
||||
}
|
||||
mCorrection = new Correction(typedLetterMultiplier, fullWordMultiplier);
|
||||
|
|
|
@ -52,7 +52,7 @@ ProximityInfo::ProximityInfo(const int maxProximityCharsSize, const int keyboard
|
|||
const int proximityGridLength = GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE;
|
||||
mProximityCharsArray = new uint32_t[proximityGridLength];
|
||||
if (DEBUG_PROXIMITY_INFO) {
|
||||
LOGI("Create proximity info array %d", proximityGridLength);
|
||||
AKLOGI("Create proximity info array %d", proximityGridLength);
|
||||
}
|
||||
memcpy(mProximityCharsArray, proximityCharsArray,
|
||||
proximityGridLength * sizeof(mProximityCharsArray[0]));
|
||||
|
@ -102,7 +102,7 @@ inline int ProximityInfo::getStartIndexFromCoordinates(const int x, const int y)
|
|||
bool ProximityInfo::hasSpaceProximity(const int x, const int y) const {
|
||||
if (x < 0 || y < 0) {
|
||||
if (DEBUG_DICT) {
|
||||
LOGI("HasSpaceProximity: Illegal coordinates (%d, %d)", x, y);
|
||||
AKLOGI("HasSpaceProximity: Illegal coordinates (%d, %d)", x, y);
|
||||
assert(false);
|
||||
}
|
||||
return false;
|
||||
|
@ -110,11 +110,11 @@ bool ProximityInfo::hasSpaceProximity(const int x, const int y) const {
|
|||
|
||||
const int startIndex = getStartIndexFromCoordinates(x, y);
|
||||
if (DEBUG_PROXIMITY_INFO) {
|
||||
LOGI("hasSpaceProximity: index %d, %d, %d", startIndex, x, y);
|
||||
AKLOGI("hasSpaceProximity: index %d, %d, %d", startIndex, x, y);
|
||||
}
|
||||
for (int i = 0; i < MAX_PROXIMITY_CHARS_SIZE; ++i) {
|
||||
if (DEBUG_PROXIMITY_INFO) {
|
||||
LOGI("Index: %d", mProximityCharsArray[startIndex + i]);
|
||||
AKLOGI("Index: %d", mProximityCharsArray[startIndex + i]);
|
||||
}
|
||||
if (mProximityCharsArray[startIndex + i] == KEYCODE_SPACE) {
|
||||
return true;
|
||||
|
|
|
@ -47,7 +47,7 @@ UnigramDictionary::UnigramDictionary(const uint8_t* const streamStart, int typed
|
|||
BYTES_IN_ONE_CHAR(MAX_PROXIMITY_CHARS * sizeof(int)),
|
||||
MAX_UMLAUT_SEARCH_DEPTH(DEFAULT_MAX_UMLAUT_SEARCH_DEPTH) {
|
||||
if (DEBUG_DICT) {
|
||||
LOGI("UnigramDictionary - constructor");
|
||||
AKLOGI("UnigramDictionary - constructor");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,14 +163,14 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo,
|
|||
queuePool->getMasterQueue()->outputSuggestions(frequencies, outWords);
|
||||
|
||||
if (DEBUG_DICT) {
|
||||
LOGI("Returning %d words", suggestedWordsCount);
|
||||
AKLOGI("Returning %d words", suggestedWordsCount);
|
||||
/// Print the returned words
|
||||
for (int j = 0; j < suggestedWordsCount; ++j) {
|
||||
#ifdef FLAG_DBG
|
||||
short unsigned int* w = outWords + j * MAX_WORD_LENGTH;
|
||||
char s[MAX_WORD_LENGTH];
|
||||
for (int i = 0; i <= MAX_WORD_LENGTH; i++) s[i] = w[i];
|
||||
LOGI("%s %i", s, frequencies[j]);
|
||||
AKLOGI("%s %i", s, frequencies[j]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ void UnigramDictionary::getWordSuggestions(ProximityInfo *proximityInfo,
|
|||
&& inputLength >= MIN_USER_TYPED_LENGTH_FOR_MISSING_SPACE_SUGGESTION) {
|
||||
for (int i = 1; i < inputLength; ++i) {
|
||||
if (DEBUG_DICT) {
|
||||
LOGI("--- Suggest missing space characters %d", i);
|
||||
AKLOGI("--- Suggest missing space characters %d", i);
|
||||
}
|
||||
getMissingSpaceWords(proximityInfo, xcoordinates, ycoordinates, codes,
|
||||
useFullEditDistance, inputLength, i, correction, queuePool);
|
||||
|
@ -226,12 +226,12 @@ void UnigramDictionary::getWordSuggestions(ProximityInfo *proximityInfo,
|
|||
// The first and last "mistyped spaces" are taken care of by excessive character handling
|
||||
for (int i = 1; i < inputLength - 1; ++i) {
|
||||
if (DEBUG_DICT) {
|
||||
LOGI("--- Suggest words with proximity space %d", i);
|
||||
AKLOGI("--- Suggest words with proximity space %d", i);
|
||||
}
|
||||
const int x = xcoordinates[i];
|
||||
const int y = ycoordinates[i];
|
||||
if (DEBUG_PROXIMITY_INFO) {
|
||||
LOGI("Input[%d] x = %d, y = %d, has space proximity = %d",
|
||||
AKLOGI("Input[%d] x = %d, y = %d, has space proximity = %d",
|
||||
i, x, y, proximityInfo->hasSpaceProximity(x, y));
|
||||
}
|
||||
if (proximityInfo->hasSpaceProximity(x, y)) {
|
||||
|
@ -247,7 +247,7 @@ void UnigramDictionary::initSuggestions(ProximityInfo *proximityInfo, const int
|
|||
const int *yCoordinates, const int *codes, const int inputLength,
|
||||
WordsPriorityQueue *queue, Correction *correction) {
|
||||
if (DEBUG_DICT) {
|
||||
LOGI("initSuggest");
|
||||
AKLOGI("initSuggest");
|
||||
}
|
||||
proximityInfo->setInputParams(codes, inputLength, xCoordinates, yCoordinates);
|
||||
if (queue) {
|
||||
|
@ -390,7 +390,7 @@ void UnigramDictionary::getSplitTwoWordsSuggestions(ProximityInfo *proximityInfo
|
|||
const int firstFreq = getMostFrequentWordLike(
|
||||
firstWordStartPos, firstWordLength, proximityInfo, mWord);
|
||||
if (DEBUG_DICT) {
|
||||
LOGI("First freq: %d", firstFreq);
|
||||
AKLOGI("First freq: %d", firstFreq);
|
||||
}
|
||||
if (firstFreq <= 0) return;
|
||||
|
||||
|
@ -401,7 +401,7 @@ void UnigramDictionary::getSplitTwoWordsSuggestions(ProximityInfo *proximityInfo
|
|||
const int secondFreq = getMostFrequentWordLike(
|
||||
secondWordStartPos, secondWordLength, proximityInfo, mWord);
|
||||
if (DEBUG_DICT) {
|
||||
LOGI("Second freq: %d", secondFreq);
|
||||
AKLOGI("Second freq: %d", secondFreq);
|
||||
}
|
||||
if (secondFreq <= 0) return;
|
||||
|
||||
|
@ -419,7 +419,7 @@ void UnigramDictionary::getSplitTwoWordsSuggestions(ProximityInfo *proximityInfo
|
|||
useFullEditDistance, false /* doAutoCompletion */, MAX_ERRORS_FOR_TWO_WORDS);
|
||||
const int pairFreq = correction->getFreqForSplitTwoWords(firstFreq, secondFreq, word);
|
||||
if (DEBUG_DICT) {
|
||||
LOGI("Split two words: %d, %d, %d, %d", firstFreq, secondFreq, pairFreq, inputLength);
|
||||
AKLOGI("Split two words: %d, %d, %d, %d", firstFreq, secondFreq, pairFreq, inputLength);
|
||||
}
|
||||
addWord(word, newWordLength, pairFreq, masterQueue);
|
||||
return;
|
||||
|
@ -690,7 +690,7 @@ inline bool UnigramDictionary::processCurrentNode(const int initialPos,
|
|||
*nextSiblingPosition =
|
||||
BinaryFormat::skipChildrenPosAndAttributes(DICT_ROOT, flags, pos);
|
||||
if (DEBUG_DICT_FULL) {
|
||||
LOGI("Traversing was pruned.");
|
||||
AKLOGI("Traversing was pruned.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -71,11 +71,11 @@ class WordsPriorityQueue {
|
|||
sw->setParams(score, word, wordLength);
|
||||
}
|
||||
if (sw == 0) {
|
||||
LOGE("SuggestedWord is accidentally null.");
|
||||
AKLOGE("SuggestedWord is accidentally null.");
|
||||
return;
|
||||
}
|
||||
if (DEBUG_WORDS_PRIORITY_QUEUE) {
|
||||
LOGI("Push word. %d, %d", score, wordLength);
|
||||
AKLOGI("Push word. %d, %d", score, wordLength);
|
||||
DUMP_WORD(word, wordLength);
|
||||
}
|
||||
mSuggestions.push(sw);
|
||||
|
@ -94,7 +94,7 @@ class WordsPriorityQueue {
|
|||
while (!mSuggestions.empty() && index >= 0) {
|
||||
SuggestedWord* sw = mSuggestions.top();
|
||||
if (DEBUG_WORDS_PRIORITY_QUEUE) {
|
||||
LOGI("dump word. %d", sw->mScore);
|
||||
AKLOGI("dump word. %d", sw->mScore);
|
||||
DUMP_WORD(sw->mWord, sw->mWordLength);
|
||||
}
|
||||
const unsigned int wordLength = sw->mWordLength;
|
||||
|
@ -120,7 +120,7 @@ class WordsPriorityQueue {
|
|||
while (!mSuggestions.empty()) {
|
||||
SuggestedWord* sw = mSuggestions.top();
|
||||
if (DEBUG_WORDS_PRIORITY_QUEUE) {
|
||||
LOGI("Clear word. %d", sw->mScore);
|
||||
AKLOGI("Clear word. %d", sw->mScore);
|
||||
DUMP_WORD(sw->mWord, sw->mWordLength);
|
||||
}
|
||||
sw->mUsed = false;
|
||||
|
|
Loading…
Reference in New Issue