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

Commit 8045b7cd authored by Keisuke Kuroynagi's avatar Keisuke Kuroynagi Committed by Android (Google) Code Review
Browse files

Merge "Introduce DynamicPatriciaTriePolicy for ver 3 dictionary."

parents 932aeb9d 26de7079
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -70,7 +70,9 @@ LATIN_IME_CORE_SRC_FILES := \
        proximity_info_state_utils.cpp) \
    suggest/core/policy/weighting.cpp \
    suggest/core/session/dic_traverse_session.cpp \
    suggest/policyimpl/dictionary/patricia_trie_policy.cpp \
    $(addprefix suggest/policyimpl/dictionary/, \
        dynamic_patricia_trie_policy.cpp \
        patricia_trie_policy.cpp) \
    suggest/policyimpl/gesture/gesture_suggest_policy_factory.cpp \
    $(addprefix suggest/policyimpl/typing/, \
        scoring_params.cpp \
+2 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

#include "defines.h"
#include "suggest/core/dictionary/binary_dictionary_format_utils.h"
#include "suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.h"
#include "suggest/policyimpl/dictionary/patricia_trie_policy.h"

namespace latinime {
@@ -33,8 +34,7 @@ class DictionaryStructurePolicyFactory {
            case BinaryDictionaryFormatUtils::VERSION_2:
                return PatriciaTriePolicy::getInstance();
            case BinaryDictionaryFormatUtils::VERSION_3:
                // TODO: support version 3 dictionaries.
                return 0;
                return DynamicPatriciaTriePolicy::getInstance();
            default:
                ASSERT(false);
                return 0;
+70 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "suggest/policyimpl/dictionary/patricia_trie_policy.h"

#include "defines.h"
#include "suggest/core/dicnode/dic_node.h"
#include "suggest/core/dicnode/dic_node_vector.h"
#include "suggest/core/dictionary/binary_dictionary_info.h"
#include "suggest/core/dictionary/binary_format.h"

namespace latinime {

const DynamicPatriciaTriePolicy DynamicPatriciaTriePolicy::sInstance;

void DynamicPatriciaTriePolicy::createAndGetAllChildNodes(const DicNode *const dicNode,
        const BinaryDictionaryInfo *const binaryDictionaryInfo,
        const NodeFilter *const nodeFilter, DicNodeVector *const childDicNodes) const {
    // TODO: Implement.
}

int DynamicPatriciaTriePolicy::getCodePointsAndProbabilityAndReturnCodePointCount(
        const BinaryDictionaryInfo *const binaryDictionaryInfo,
        const int nodePos, const int maxCodePointCount, int *const outCodePoints,
        int *const outUnigramProbability) const {
    // TODO: Implement.
    return 0;
}

int DynamicPatriciaTriePolicy::getTerminalNodePositionOfWord(
        const BinaryDictionaryInfo *const binaryDictionaryInfo, const int *const inWord,
        const int length, const bool forceLowerCaseSearch) const {
    // TODO: Implement.
    return NOT_A_DICT_POS;
}

int DynamicPatriciaTriePolicy::getUnigramProbability(
        const BinaryDictionaryInfo *const binaryDictionaryInfo, const int nodePos) const {
    // TODO: Implement.
    return NOT_A_PROBABILITY;
}

int DynamicPatriciaTriePolicy::getShortcutPositionOfNode(
        const BinaryDictionaryInfo *const binaryDictionaryInfo,
        const int nodePos) const {
    // TODO: Implement.
    return NOT_A_DICT_POS;
}

int DynamicPatriciaTriePolicy::getBigramsPositionOfNode(
        const BinaryDictionaryInfo *const binaryDictionaryInfo,
        const int nodePos) const {
    // TODO: Implement.
    return NOT_A_DICT_POS;
}

} // namespace latinime
+69 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef LATINIME_DYNAMIC_PATRICIA_TRIE_POLICY_H
#define LATINIME_DYNAMIC_PATRICIA_TRIE_POLICY_H

#include "defines.h"
#include "suggest/core/policy/dictionary_structure_policy.h"

namespace latinime {

class BinaryDictionaryInfo;
class DicNode;
class DicNodeVector;

class DynamicPatriciaTriePolicy : public DictionaryStructurePolicy {
 public:
    static AK_FORCE_INLINE const DynamicPatriciaTriePolicy *getInstance() {
        return &sInstance;
    }

    AK_FORCE_INLINE int getRootPosition() const {
        return 0;
    }

    void createAndGetAllChildNodes(const DicNode *const dicNode,
            const BinaryDictionaryInfo *const binaryDictionaryInfo,
            const NodeFilter *const nodeFilter, DicNodeVector *const childDicNodes) const;

    int getCodePointsAndProbabilityAndReturnCodePointCount(
            const BinaryDictionaryInfo *const binaryDictionaryInfo,
            const int terminalNodePos, const int maxCodePointCount, int *const outCodePoints,
            int *const outUnigramProbability) const;

    int getTerminalNodePositionOfWord(
            const BinaryDictionaryInfo *const binaryDictionaryInfo, const int *const inWord,
            const int length, const bool forceLowerCaseSearch) const;

    int getUnigramProbability(const BinaryDictionaryInfo *const binaryDictionaryInfo,
            const int nodePos) const;

    int getShortcutPositionOfNode(const BinaryDictionaryInfo *const binaryDictionaryInfo,
            const int nodePos) const;

    int getBigramsPositionOfNode(const BinaryDictionaryInfo *const binaryDictionaryInfo,
            const int nodePos) const;

 private:
    DISALLOW_COPY_AND_ASSIGN(DynamicPatriciaTriePolicy);
    static const DynamicPatriciaTriePolicy sInstance;

    DynamicPatriciaTriePolicy() {}
    ~DynamicPatriciaTriePolicy() {}
};
} // namespace latinime
#endif // LATINIME_DYNAMIC_PATRICIA_TRIE_POLICY_H