diff options
author | 2011-12-19 01:21:28 -0800 | |
---|---|---|
committer | 2011-12-19 01:21:28 -0800 | |
commit | ad87655fa5303f1147af83e40eace36df49857e0 (patch) | |
tree | 223edf7523afb7bd1625c94207a20443443973e6 /native/src/correction.cpp | |
parent | 192e5b15a9c5eacb01b178c5dec72917a555cdc4 (diff) | |
parent | 96ea1720fdf0b03177f62f9b65d47e4667378fa6 (diff) | |
download | latinime-ad87655fa5303f1147af83e40eace36df49857e0.tar.gz latinime-ad87655fa5303f1147af83e40eace36df49857e0.tar.xz latinime-ad87655fa5303f1147af83e40eace36df49857e0.zip |
am 96ea1720: Merge "Prepare for proximity + two word correction No2"
* commit '96ea1720fdf0b03177f62f9b65d47e4667378fa6':
Prepare for proximity + two word correction No2
Diffstat (limited to 'native/src/correction.cpp')
-rw-r--r-- | native/src/correction.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/native/src/correction.cpp b/native/src/correction.cpp index 2da82dc3d..503fb7c53 100644 --- a/native/src/correction.cpp +++ b/native/src/correction.cpp @@ -38,8 +38,28 @@ inline static void initEditDistance(int *editDistanceTable) { } } +inline static void dumpEditDistance10ForDebug(int *editDistanceTable, const int inputLength, + const int outputLength) { + if (DEBUG_DICT) { + LOGI("EditDistanceTable"); + for (int i = 0; i <= 10; ++i) { + int c[11]; + for (int j = 0; j <= 10; ++j) { + if (j < inputLength + 1 && i < outputLength + 1) { + c[j] = (editDistanceTable + i * (inputLength + 1))[j]; + } else { + c[j] = -1; + } + } + LOGI("[ %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]); + } + } +} + inline static void calcEditDistanceOneStep(int *editDistanceTable, const unsigned short *input, const int inputLength, const unsigned short *output, const int outputLength) { + // TODO: Make sure that editDistance[0 ~ MAX_WORD_LENGTH_INTERNAL] is not touched. // Let dp[i][j] be editDistanceTable[i * (inputLength + 1) + j]. // Assuming that dp[0][0] ... dp[outputLength - 1][inputLength] are already calculated, // and calculate dp[ouputLength][0] ... dp[outputLength][inputLength]. @@ -62,6 +82,9 @@ 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); + } return editDistanceTable[(inputLength + 1) * (outputLength + 1) - 1]; } @@ -90,6 +113,9 @@ void Correction::initCorrection(const ProximityInfo *pi, const int inputLength, mInputLength = inputLength; mMaxDepth = maxDepth; mMaxEditDistance = mInputLength < 5 ? 2 : mInputLength / 2; + // TODO: This is not supposed to be required. Check what's going wrong with + // editDistance[0 ~ MAX_WORD_LENGTH_INTERNAL] + initEditDistance(mEditDistanceTable); } void Correction::initCorrectionState( @@ -620,6 +646,9 @@ int Correction::RankingAlgorithm::calculateFinalFreq(const int inputIndex, const // TODO: Calculate edit distance for transposed and excessive int ed = 0; + if (DEBUG_DICT_FULL) { + dumpEditDistance10ForDebug(editDistanceTable, inputLength, outputIndex + 1); + } int adjustedProximityMatchedCount = proximityMatchedCount; int finalFreq = freq; |