am e2a6badf
: Merge "Show results in the native code." into jb-mr1-dev
* commit 'e2a6badf601e7b637a709a11e430bd21bb46f6f9': Show results in the native code.
This commit is contained in:
commit
b808e970f4
2 changed files with 44 additions and 5 deletions
|
@ -25,17 +25,52 @@
|
||||||
#define AKLOGE(fmt, ...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, fmt, ##__VA_ARGS__)
|
#define AKLOGE(fmt, ...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, fmt, ##__VA_ARGS__)
|
||||||
#define AKLOGI(fmt, ...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, fmt, ##__VA_ARGS__)
|
#define AKLOGI(fmt, ...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, fmt, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
#define DUMP_RESULT(words, frequencies, maxWordCount, maxWordLength) do { \
|
||||||
|
dumpResult(words, frequencies, maxWordCount, maxWordLength); } while(0)
|
||||||
#define DUMP_WORD(word, length) do { dumpWord(word, length); } while(0)
|
#define DUMP_WORD(word, length) do { dumpWord(word, length); } while(0)
|
||||||
#define DUMP_WORD_INT(word, length) do { dumpWordInt(word, length); } while(0)
|
#define DUMP_WORD_INT(word, length) do { dumpWordInt(word, length); } while(0)
|
||||||
|
|
||||||
|
static inline void dumpWordInfo(const unsigned short *word, const int length,
|
||||||
|
const int rank, const int frequency) {
|
||||||
|
static char charBuf[50];
|
||||||
|
int i = 0;
|
||||||
|
for (; i < length; ++i) {
|
||||||
|
const unsigned short c = word[i];
|
||||||
|
if (c == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
charBuf[i] = c;
|
||||||
|
}
|
||||||
|
charBuf[i] = 0;
|
||||||
|
if (i > 1) {
|
||||||
|
AKLOGI("%2d [ %s ] (%d)", rank, charBuf, frequency);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dumpResult(
|
||||||
|
const unsigned short *outWords, const int *frequencies, const int maxWordCounts,
|
||||||
|
const int maxWordLength) {
|
||||||
|
AKLOGI("--- DUMP RESULT ---------");
|
||||||
|
for (int i = 0; i < maxWordCounts; ++i) {
|
||||||
|
dumpWordInfo(&outWords[i * maxWordLength], maxWordLength, i, frequencies[i]);
|
||||||
|
}
|
||||||
|
AKLOGI("-------------------------");
|
||||||
|
}
|
||||||
|
|
||||||
static inline void dumpWord(const unsigned short *word, const int length) {
|
static inline void dumpWord(const unsigned short *word, const int length) {
|
||||||
static char charBuf[50];
|
static char charBuf[50];
|
||||||
|
int i = 0;
|
||||||
for (int i = 0; i < length; ++i) {
|
for (; i < length; ++i) {
|
||||||
charBuf[i] = word[i];
|
const unsigned short c = word[i];
|
||||||
|
if (c == 0) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
charBuf[length] = 0;
|
charBuf[i] = c;
|
||||||
|
}
|
||||||
|
charBuf[i] = 0;
|
||||||
|
if (i > 1) {
|
||||||
AKLOGI("[ %s ]", charBuf);
|
AKLOGI("[ %s ]", charBuf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dumpWordInt(const int *word, const int length) {
|
static inline void dumpWordInt(const int *word, const int length) {
|
||||||
|
@ -51,6 +86,7 @@ static inline void dumpWordInt(const int *word, const int length) {
|
||||||
#else
|
#else
|
||||||
#define AKLOGE(fmt, ...)
|
#define AKLOGE(fmt, ...)
|
||||||
#define AKLOGI(fmt, ...)
|
#define AKLOGI(fmt, ...)
|
||||||
|
#define DUMP_RESULT(words, frequencies, maxWordCount, maxWordLength)
|
||||||
#define DUMP_WORD(word, length)
|
#define DUMP_WORD(word, length)
|
||||||
#define DUMP_WORD_INT(word, length)
|
#define DUMP_WORD_INT(word, length)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -67,6 +67,9 @@ int Dictionary::getSuggestions(ProximityInfo *proximityInfo, int *xcoordinates,
|
||||||
result = mGestureDecoder->getSuggestions(proximityInfo, xcoordinates, ycoordinates,
|
result = mGestureDecoder->getSuggestions(proximityInfo, xcoordinates, ycoordinates,
|
||||||
times, pointerIds, codes, codesSize, commitPoint,
|
times, pointerIds, codes, codesSize, commitPoint,
|
||||||
outWords, frequencies, spaceIndices, outputTypes);
|
outWords, frequencies, spaceIndices, outputTypes);
|
||||||
|
if (DEBUG_DICT) {
|
||||||
|
DUMP_RESULT(outWords, frequencies, 18 /* MAX_WORDS */, MAX_WORD_LENGTH_INTERNAL);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
std::map<int, int> bigramMap;
|
std::map<int, int> bigramMap;
|
||||||
|
|
Loading…
Reference in a new issue