Introduce DynamicPatriciaTriePolicy for ver 3 dictionary.

Bug: 6669677
Change-Id: Idd3189558aa6fbbd6b2fd007c5721bf39dde9f48
main
Keisuke Kuroynagi 2013-07-30 17:41:13 +09:00
parent ab2d273133
commit 26de7079b6
4 changed files with 144 additions and 3 deletions

View File

@ -70,7 +70,9 @@ LATIN_IME_CORE_SRC_FILES := \
proximity_info_state_utils.cpp) \ proximity_info_state_utils.cpp) \
suggest/core/policy/weighting.cpp \ suggest/core/policy/weighting.cpp \
suggest/core/session/dic_traverse_session.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 \ suggest/policyimpl/gesture/gesture_suggest_policy_factory.cpp \
$(addprefix suggest/policyimpl/typing/, \ $(addprefix suggest/policyimpl/typing/, \
scoring_params.cpp \ scoring_params.cpp \

View File

@ -19,6 +19,7 @@
#include "defines.h" #include "defines.h"
#include "suggest/core/dictionary/binary_dictionary_format_utils.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" #include "suggest/policyimpl/dictionary/patricia_trie_policy.h"
namespace latinime { namespace latinime {
@ -33,8 +34,7 @@ class DictionaryStructurePolicyFactory {
case BinaryDictionaryFormatUtils::VERSION_2: case BinaryDictionaryFormatUtils::VERSION_2:
return PatriciaTriePolicy::getInstance(); return PatriciaTriePolicy::getInstance();
case BinaryDictionaryFormatUtils::VERSION_3: case BinaryDictionaryFormatUtils::VERSION_3:
// TODO: support version 3 dictionaries. return DynamicPatriciaTriePolicy::getInstance();
return 0;
default: default:
ASSERT(false); ASSERT(false);
return 0; return 0;

View File

@ -0,0 +1,70 @@
/*
* 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

View File

@ -0,0 +1,69 @@
/*
* 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