Small cleanups

Change-Id: I29b4dee15d66f8f1372035738658234395001d41
main
Ken Wakasa 2012-12-11 23:38:32 +09:00
parent dd8d2a89c5
commit 692cd00ea3
5 changed files with 5 additions and 14 deletions

View File

@ -14,11 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#define LOG_TAG "LatinIME: correction.cpp" #define LOG_TAG "LatinIME: correction.cpp"
#include "char_utils.h" #include "char_utils.h"
@ -1002,7 +997,7 @@ int Correction::RankingAlgorithm::editDistance(const int *before, const int befo
float Correction::RankingAlgorithm::calcNormalizedScore(const int *before, const int beforeLength, float Correction::RankingAlgorithm::calcNormalizedScore(const int *before, const int beforeLength,
const int *after, const int afterLength, const int score) { const int *after, const int afterLength, const int score) {
if (0 == beforeLength || 0 == afterLength) { if (0 == beforeLength || 0 == afterLength) {
return 0; return 0.0f;
} }
const int distance = editDistance(before, beforeLength, after, afterLength); const int distance = editDistance(before, beforeLength, after, afterLength);
int spaceCount = 0; int spaceCount = 0;
@ -1013,7 +1008,7 @@ float Correction::RankingAlgorithm::calcNormalizedScore(const int *before, const
} }
if (spaceCount == afterLength) { if (spaceCount == afterLength) {
return 0; return 0.0f;
} }
const float maxScore = score >= S_INT_MAX ? static_cast<float>(S_INT_MAX) const float maxScore = score >= S_INT_MAX ? static_cast<float>(S_INT_MAX)

View File

@ -19,7 +19,6 @@
#include <cassert> #include <cassert>
#include <cstring> // for memset() #include <cstring> // for memset()
#include <stdint.h>
#include "correction_state.h" #include "correction_state.h"
#include "defines.h" #include "defines.h"
@ -237,7 +236,7 @@ class Correction {
int mTerminalOutputIndex; int mTerminalOutputIndex;
int mMaxErrors; int mMaxErrors;
uint8_t mTotalTraverseCount; int mTotalTraverseCount;
// The following arrays are state buffer. // The following arrays are state buffer.
int mWord[MAX_WORD_LENGTH_INTERNAL]; int mWord[MAX_WORD_LENGTH_INTERNAL];
@ -352,7 +351,7 @@ AK_FORCE_INLINE static void calcEditDistanceOneStep(int *editDistanceTable, cons
const int prevCO = outputLength >= 2 ? toBaseLowerCase(output[outputLength - 2]) : 0; const int prevCO = outputLength >= 2 ? toBaseLowerCase(output[outputLength - 2]) : 0;
for (int i = 1; i <= inputSize; ++i) { for (int i = 1; i <= inputSize; ++i) {
const int ci = toBaseLowerCase(input[i - 1]); const int ci = toBaseLowerCase(input[i - 1]);
const uint16_t cost = (ci == co) ? 0 : 1; const int cost = (ci == co) ? 0 : 1;
current[i] = min(current[i - 1] + 1, min(prev[i] + 1, prev[i - 1] + cost)); current[i] = min(current[i - 1] + 1, min(prev[i] + 1, prev[i - 1] + cost));
if (i >= 2 && prevprev && ci == prevCO && co == toBaseLowerCase(input[i - 2])) { if (i >= 2 && prevprev && ci == prevCO && co == toBaseLowerCase(input[i - 2])) {
current[i] = min(current[i], prevprev[i - 2] + 1); current[i] = min(current[i], prevprev[i - 2] + 1);

View File

@ -237,9 +237,6 @@ static inline void prof_out(void) {
#endif // FLAG_DBG #endif // FLAG_DBG
#ifndef U_SHORT_MAX
#define U_SHORT_MAX 65535 // ((1 << 16) - 1)
#endif
#ifndef S_INT_MAX #ifndef S_INT_MAX
#define S_INT_MAX 2147483647 // ((1 << 31) - 1) #define S_INT_MAX 2147483647 // ((1 << 31) - 1)
#endif #endif

View File

@ -15,7 +15,6 @@
*/ */
#include <cassert> #include <cassert>
#include <cmath>
#include <cstring> #include <cstring>
#define LOG_TAG "LatinIME: proximity_info.cpp" #define LOG_TAG "LatinIME: proximity_info.cpp"

View File

@ -17,6 +17,7 @@
#ifndef LATINIME_TERMINAL_ATTRIBUTES_H #ifndef LATINIME_TERMINAL_ATTRIBUTES_H
#define LATINIME_TERMINAL_ATTRIBUTES_H #define LATINIME_TERMINAL_ATTRIBUTES_H
#include <stdint.h>
#include "binary_format.h" #include "binary_format.h"
namespace latinime { namespace latinime {