Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1dae936f authored by Ken Wakasa's avatar Ken Wakasa Committed by Android (Google) Code Review
Browse files

Merge "Move char_utils to the dictionary directory"

parents 26f48949 464d3ba4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ LATIN_IME_JNI_SRC_FILES := \

LATIN_IME_CORE_SRC_FILES := \
    bigram_dictionary.cpp \
    char_utils.cpp \
    correction.cpp \
    dic_traverse_wrapper.cpp \
    unigram_dictionary.cpp \
@@ -58,6 +57,7 @@ LATIN_IME_CORE_SRC_FILES := \
        dic_node_utils.cpp \
        dic_nodes_cache.cpp) \
    $(addprefix suggest/core/dictionary/, \
        char_utils.cpp \
        dictionary.cpp \
        digraph_utils.cpp) \
    $(addprefix suggest/core/layout/, \
+4 −4
Original line number Diff line number Diff line
@@ -20,10 +20,10 @@

#include "bigram_dictionary.h"

#include "char_utils.h"
#include "defines.h"
#include "suggest/core/dictionary/binary_format.h"
#include "suggest/core/dictionary/bloom_filter.h"
#include "suggest/core/dictionary/char_utils.h"
#include "suggest/core/dictionary/dictionary.h"

namespace latinime {
@@ -52,7 +52,7 @@ void BigramDictionary::addWordBigram(int *word, int length, int probability, int
    int insertAt = 0;
    while (insertAt < MAX_RESULTS) {
        if (probability > bigramProbability[insertAt] || (bigramProbability[insertAt] == probability
                && length < getCodePointCount(MAX_WORD_LENGTH,
                && length < CharUtils::getCodePointCount(MAX_WORD_LENGTH,
                        bigramCodePoints + insertAt * MAX_WORD_LENGTH))) {
            break;
        }
@@ -196,9 +196,9 @@ bool BigramDictionary::checkFirstCharacter(int *word, int *inputCodePoints) cons
    // what user typed.

    int maxAlt = MAX_ALTERNATIVES;
    const int firstBaseLowerCodePoint = toBaseLowerCase(*word);
    const int firstBaseLowerCodePoint = CharUtils::toBaseLowerCase(*word);
    while (maxAlt > 0) {
        if (toBaseLowerCase(*inputCodePoints) == firstBaseLowerCodePoint) {
        if (CharUtils::toBaseLowerCase(*inputCodePoints) == firstBaseLowerCodePoint) {
            return true;
        }
        inputCodePoints++;
+2 −2
Original line number Diff line number Diff line
@@ -18,9 +18,9 @@

#include <cmath>

#include "char_utils.h"
#include "correction.h"
#include "defines.h"
#include "suggest/core/dictionary/char_utils.h"
#include "suggest/core/layout/proximity_info_state.h"
#include "suggest/core/layout/touch_position_correction_utils.h"
#include "suggest/policyimpl/utils/edit_distance.h"
@@ -528,7 +528,7 @@ inline static int getQuoteCount(const int *word, const int length) {
}

inline static bool isUpperCase(unsigned short c) {
    return isAsciiUpper(toBaseCodePoint(c));
    return CharUtils::isAsciiUpper(CharUtils::toBaseCodePoint(c));
}

//////////////////////
+5 −4
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@

#include "correction_state.h"
#include "defines.h"
#include "suggest/core/dictionary/char_utils.h"
#include "suggest/core/layout/proximity_info_state.h"

namespace latinime {
@@ -342,13 +343,13 @@ AK_FORCE_INLINE static void calcEditDistanceOneStep(int *editDistanceTable, cons
    const int *const prevprev =
            outputLength >= 2 ? editDistanceTable + (outputLength - 2) * (inputSize + 1) : 0;
    current[0] = outputLength;
    const int co = toBaseLowerCase(output[outputLength - 1]);
    const int prevCO = outputLength >= 2 ? toBaseLowerCase(output[outputLength - 2]) : 0;
    const int co = CharUtils::toBaseLowerCase(output[outputLength - 1]);
    const int prevCO = outputLength >= 2 ? CharUtils::toBaseLowerCase(output[outputLength - 2]) : 0;
    for (int i = 1; i <= inputSize; ++i) {
        const int ci = toBaseLowerCase(input[i - 1]);
        const int ci = CharUtils::toBaseLowerCase(input[i - 1]);
        const int cost = (ci == co) ? 0 : 1;
        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 == CharUtils::toBaseLowerCase(input[i - 2])) {
            current[i] = min(current[i], prevprev[i - 2] + 1);
        }
    }
+3 −3
Original line number Diff line number Diff line
@@ -17,12 +17,12 @@
#ifndef LATINIME_DIC_NODE_H
#define LATINIME_DIC_NODE_H

#include "char_utils.h"
#include "defines.h"
#include "suggest/core/dicnode/dic_node_state.h"
#include "suggest/core/dicnode/dic_node_profiler.h"
#include "suggest/core/dicnode/dic_node_properties.h"
#include "suggest/core/dicnode/dic_node_release_listener.h"
#include "suggest/core/dictionary/char_utils.h"
#include "suggest/core/dictionary/digraph_utils.h"

#if DEBUG_DICT
@@ -221,7 +221,7 @@ class DicNode {

    bool isFirstCharUppercase() const {
        const int c = getOutputWordBuf()[0];
        return isAsciiUpper(c);
        return CharUtils::isAsciiUpper(c);
    }

    bool isFirstWord() const {
@@ -375,7 +375,7 @@ class DicNode {
    // Whether the current codepoint can be an intentional omission, in which case the traversal
    // algorithm will always check for a possible omission here.
    bool canBeIntentionalOmission() const {
        return isIntentionalOmissionCodePoint(getNodeCodePoint());
        return CharUtils::isIntentionalOmissionCodePoint(getNodeCodePoint());
    }

    // Whether the omission is so frequent that it should incur zero cost.
Loading