aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeisuke Kuroynagi <ksk@google.com>2013-06-26 21:00:25 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-06-26 21:00:25 -0700
commit67552eee3961d14f7dd6646d9dde7ada514cf007 (patch)
tree0e7d1168ca628e5eb651fc4c03eac628e46ab526
parent12c6ed411a56117cb4813d15a28688e751319b1e (diff)
parentd9e08beebf1bf7cfb45173a8140b9eaf62ba1319 (diff)
downloadlatinime-67552eee3961d14f7dd6646d9dde7ada514cf007.tar.gz
latinime-67552eee3961d14f7dd6646d9dde7ada514cf007.tar.xz
latinime-67552eee3961d14f7dd6646d9dde7ada514cf007.zip
am d9e08bee: Merge "Add DictionaryStructure as a policy."
* commit 'd9e08beebf1bf7cfb45173a8140b9eaf62ba1319': Add DictionaryStructure as a policy.
-rw-r--r--native/jni/src/suggest/core/policy/dictionary_structure_policy.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/native/jni/src/suggest/core/policy/dictionary_structure_policy.h b/native/jni/src/suggest/core/policy/dictionary_structure_policy.h
new file mode 100644
index 000000000..ab42c13b4
--- /dev/null
+++ b/native/jni/src/suggest/core/policy/dictionary_structure_policy.h
@@ -0,0 +1,72 @@
+/*
+ * 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_DICTIONARY_STRUCTURE_POLICY_H
+#define LATINIME_DICTIONARY_STRUCTURE_POLICY_H
+
+#include "defines.h"
+
+namespace latinime {
+
+class BinaryDictionaryInfo;
+class DicNode;
+class DicNodeVector;
+
+/*
+ * This class abstracts structure of dictionaries.
+ * Implement this policy to support additional dictionaries.
+ */
+class DictionaryStructurePolicy {
+ public:
+ // This provides a filtering method for filtering new node.
+ class NodeFilter {
+ public:
+ virtual bool isFilteredOut(const int codePoint) const = 0;
+
+ protected:
+ NodeFilter() {}
+ virtual ~NodeFilter() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(NodeFilter);
+ };
+
+ virtual int getRootPosition() const = 0;
+
+ virtual void createAndGetAllChildNodes(const DicNode *const dicNode,
+ const BinaryDictionaryInfo *const binaryDictionaryInfo,
+ const NodeFilter *const nodeFilter, DicNodeVector *const childDicNodes) const = 0;
+
+ virtual void getWordAtPosition(const BinaryDictionaryInfo *const binaryDictionaryInfo,
+ const int terminalNodePos, const int maxDepth, int *const outWord,
+ int *const outUnigramProbability) const = 0;
+
+ virtual int getTerminalNodePositionOfWord(
+ const BinaryDictionaryInfo *const binaryDictionaryInfo, const int *const inWord,
+ const int length, const bool forceLowerCaseSearch) const = 0;
+
+ virtual int getUnigramProbability(const BinaryDictionaryInfo *const binaryDictionaryInfo,
+ const int nodePos) const = 0;
+
+ protected:
+ DictionaryStructurePolicy() {}
+ virtual ~DictionaryStructurePolicy() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DictionaryStructurePolicy);
+};
+} // namespace latinime
+#endif /* LATINIME_DICTIONARY_STRUCTURE_POLICY_H */