Loading native/jni/NativeFileList.mk +1 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ LATIN_IME_CORE_SRC_FILES := \ digraph_utils.cpp \ error_type_utils.cpp \ multi_bigram_map.cpp \ word_property.cpp) \ property/word_property.cpp) \ $(addprefix suggest/core/layout/, \ additional_proximity_chars.cpp \ proximity_info.cpp \ Loading native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ #include "jni.h" #include "jni_common.h" #include "suggest/core/dictionary/dictionary.h" #include "suggest/core/dictionary/word_property.h" #include "suggest/core/dictionary/property/word_property.h" #include "suggest/core/result/suggestion_results.h" #include "suggest/core/suggest_options.h" #include "suggest/policyimpl/dictionary/structure/dictionary_structure_with_buffer_policy_factory.h" Loading native/jni/src/suggest/core/dictionary/dictionary.h +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ #include "defines.h" #include "jni.h" #include "suggest/core/dictionary/bigram_dictionary.h" #include "suggest/core/dictionary/word_property.h" #include "suggest/core/dictionary/property/word_property.h" #include "suggest/core/policy/dictionary_header_structure_policy.h" #include "suggest/core/policy/dictionary_structure_with_buffer_policy.h" #include "suggest/core/suggest_interface.h" Loading native/jni/src/suggest/core/dictionary/property/bigram_property.h 0 → 100644 +65 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 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_BIGRAM_PROPERTY_H #define LATINIME_BIGRAM_PROPERTY_H #include <vector> #include "defines.h" namespace latinime { class BigramProperty { public: BigramProperty(const std::vector<int> *const targetCodePoints, const int probability, const int timestamp, const int level, const int count) : mTargetCodePoints(*targetCodePoints), mProbability(probability), mTimestamp(timestamp), mLevel(level), mCount(count) {} const std::vector<int> *getTargetCodePoints() const { return &mTargetCodePoints; } int getProbability() const { return mProbability; } int getTimestamp() const { return mTimestamp; } int getLevel() const { return mLevel; } int getCount() const { return mCount; } private: // Default copy constructor and assign operator are used for using in std::vector. DISALLOW_DEFAULT_CONSTRUCTOR(BigramProperty); // TODO: Make members const. std::vector<int> mTargetCodePoints; int mProbability; int mTimestamp; int mLevel; int mCount; }; } // namespace latinime #endif // LATINIME_WORD_PROPERTY_H native/jni/src/suggest/core/dictionary/word_property.h→native/jni/src/suggest/core/dictionary/property/unigram_property.h +107 −0 Original line number Diff line number Diff line /* * Copyright (C) 2013 The Android Open Source Project * Copyright (C) 2014 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. Loading @@ -14,26 +14,21 @@ * limitations under the License. */ #ifndef LATINIME_WORD_PROPERTY_H #define LATINIME_WORD_PROPERTY_H #ifndef LATINIME_UNIGRAM_PROPERTY_H #define LATINIME_UNIGRAM_PROPERTY_H #include <cstring> #include <vector> #include "defines.h" #include "jni.h" namespace latinime { // This class is used for returning information belonging to a word to java side. class WordProperty { class UnigramProperty { public: class BigramProperty { class ShortcutProperty { public: BigramProperty(const std::vector<int> *const targetCodePoints, const int probability, const int timestamp, const int level, const int count) : mTargetCodePoints(*targetCodePoints), mProbability(probability), mTimestamp(timestamp), mLevel(level), mCount(count) {} ShortcutProperty(const std::vector<int> *const targetCodePoints, const int probability) : mTargetCodePoints(*targetCodePoints), mProbability(probability) {} const std::vector<int> *getTargetCodePoints() const { return &mTargetCodePoints; Loading @@ -43,79 +38,70 @@ class WordProperty { return mProbability; } int getTimestamp() const { return mTimestamp; } int getLevel() const { return mLevel; } int getCount() const { return mCount; } private: // Default copy constructor and assign operator are used for using in std::vector. DISALLOW_DEFAULT_CONSTRUCTOR(ShortcutProperty); // TODO: Make members const. std::vector<int> mTargetCodePoints; int mProbability; int mTimestamp; int mLevel; int mCount; }; class ShortcutProperty { public: ShortcutProperty(const std::vector<int> *const targetCodePoints, const int probability) : mTargetCodePoints(*targetCodePoints), mProbability(probability) {} UnigramProperty() : mIsNotAWord(false), mIsBlacklisted(false), mProbability(NOT_A_PROBABILITY), mTimestamp(NOT_A_TIMESTAMP), mLevel(0), mCount(0), mShortcuts() {} const std::vector<int> *getTargetCodePoints() const { return &mTargetCodePoints; UnigramProperty(const bool isNotAWord, const bool isBlacklisted, const int probability, const int timestamp, const int level, const int count, const std::vector<ShortcutProperty> *const shortcuts) : mIsNotAWord(isNotAWord), mIsBlacklisted(isBlacklisted), mProbability(probability), mTimestamp(timestamp), mLevel(level), mCount(count), mShortcuts(*shortcuts) {} bool isNotAWord() const { return mIsNotAWord; } bool isBlacklisted() const { return mIsBlacklisted; } bool hasShortcuts() const { return !mShortcuts.empty(); } int getProbability() const { return mProbability; } private: std::vector<int> mTargetCodePoints; int mProbability; }; int getTimestamp() const { return mTimestamp; } // Invalid word. WordProperty() : mCodePoints(), mIsNotAWord(false), mIsBlacklisted(false), mHasBigrams(false), mHasShortcuts(false), mProbability(NOT_A_PROBABILITY), mTimestamp(0), mLevel(0), mCount(0), mBigrams(), mShortcuts() {} int getLevel() const { return mLevel; } WordProperty(const std::vector<int> *const codePoints, const bool isNotAWord, const bool isBlacklisted, const bool hasBigrams, const bool hasShortcuts, const int probability, const int timestamp, const int level, const int count, const std::vector<BigramProperty> *const bigrams, const std::vector<ShortcutProperty> *const shortcuts) : mCodePoints(*codePoints), mIsNotAWord(isNotAWord), mIsBlacklisted(isBlacklisted), mHasBigrams(hasBigrams), mHasShortcuts(hasShortcuts), mProbability(probability), mTimestamp(timestamp), mLevel(level), mCount(count), mBigrams(*bigrams), mShortcuts(*shortcuts) {} int getCount() const { return mCount; } void outputProperties(JNIEnv *const env, jintArray outCodePoints, jbooleanArray outFlags, jintArray outProbabilityInfo, jobject outBigramTargets, jobject outBigramProbabilities, jobject outShortcutTargets, jobject outShortcutProbabilities) const; const std::vector<ShortcutProperty> &getShortcuts() const { return mShortcuts; } private: DISALLOW_ASSIGNMENT_OPERATOR(WordProperty); // Default copy constructor is used for using as a return value. DISALLOW_ASSIGNMENT_OPERATOR(UnigramProperty); std::vector<int> mCodePoints; // TODO: Make members const. bool mIsNotAWord; bool mIsBlacklisted; bool mHasBigrams; bool mHasShortcuts; int mProbability; // Historical information int mTimestamp; int mLevel; int mCount; std::vector<BigramProperty> mBigrams; std::vector<ShortcutProperty> mShortcuts; }; } // namespace latinime #endif // LATINIME_WORD_PROPERTY_H #endif // LATINIME_UNIGRAM_PROPERTY_H Loading
native/jni/NativeFileList.mk +1 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ LATIN_IME_CORE_SRC_FILES := \ digraph_utils.cpp \ error_type_utils.cpp \ multi_bigram_map.cpp \ word_property.cpp) \ property/word_property.cpp) \ $(addprefix suggest/core/layout/, \ additional_proximity_chars.cpp \ proximity_info.cpp \ Loading
native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ #include "jni.h" #include "jni_common.h" #include "suggest/core/dictionary/dictionary.h" #include "suggest/core/dictionary/word_property.h" #include "suggest/core/dictionary/property/word_property.h" #include "suggest/core/result/suggestion_results.h" #include "suggest/core/suggest_options.h" #include "suggest/policyimpl/dictionary/structure/dictionary_structure_with_buffer_policy_factory.h" Loading
native/jni/src/suggest/core/dictionary/dictionary.h +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ #include "defines.h" #include "jni.h" #include "suggest/core/dictionary/bigram_dictionary.h" #include "suggest/core/dictionary/word_property.h" #include "suggest/core/dictionary/property/word_property.h" #include "suggest/core/policy/dictionary_header_structure_policy.h" #include "suggest/core/policy/dictionary_structure_with_buffer_policy.h" #include "suggest/core/suggest_interface.h" Loading
native/jni/src/suggest/core/dictionary/property/bigram_property.h 0 → 100644 +65 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 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_BIGRAM_PROPERTY_H #define LATINIME_BIGRAM_PROPERTY_H #include <vector> #include "defines.h" namespace latinime { class BigramProperty { public: BigramProperty(const std::vector<int> *const targetCodePoints, const int probability, const int timestamp, const int level, const int count) : mTargetCodePoints(*targetCodePoints), mProbability(probability), mTimestamp(timestamp), mLevel(level), mCount(count) {} const std::vector<int> *getTargetCodePoints() const { return &mTargetCodePoints; } int getProbability() const { return mProbability; } int getTimestamp() const { return mTimestamp; } int getLevel() const { return mLevel; } int getCount() const { return mCount; } private: // Default copy constructor and assign operator are used for using in std::vector. DISALLOW_DEFAULT_CONSTRUCTOR(BigramProperty); // TODO: Make members const. std::vector<int> mTargetCodePoints; int mProbability; int mTimestamp; int mLevel; int mCount; }; } // namespace latinime #endif // LATINIME_WORD_PROPERTY_H
native/jni/src/suggest/core/dictionary/word_property.h→native/jni/src/suggest/core/dictionary/property/unigram_property.h +107 −0 Original line number Diff line number Diff line /* * Copyright (C) 2013 The Android Open Source Project * Copyright (C) 2014 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. Loading @@ -14,26 +14,21 @@ * limitations under the License. */ #ifndef LATINIME_WORD_PROPERTY_H #define LATINIME_WORD_PROPERTY_H #ifndef LATINIME_UNIGRAM_PROPERTY_H #define LATINIME_UNIGRAM_PROPERTY_H #include <cstring> #include <vector> #include "defines.h" #include "jni.h" namespace latinime { // This class is used for returning information belonging to a word to java side. class WordProperty { class UnigramProperty { public: class BigramProperty { class ShortcutProperty { public: BigramProperty(const std::vector<int> *const targetCodePoints, const int probability, const int timestamp, const int level, const int count) : mTargetCodePoints(*targetCodePoints), mProbability(probability), mTimestamp(timestamp), mLevel(level), mCount(count) {} ShortcutProperty(const std::vector<int> *const targetCodePoints, const int probability) : mTargetCodePoints(*targetCodePoints), mProbability(probability) {} const std::vector<int> *getTargetCodePoints() const { return &mTargetCodePoints; Loading @@ -43,79 +38,70 @@ class WordProperty { return mProbability; } int getTimestamp() const { return mTimestamp; } int getLevel() const { return mLevel; } int getCount() const { return mCount; } private: // Default copy constructor and assign operator are used for using in std::vector. DISALLOW_DEFAULT_CONSTRUCTOR(ShortcutProperty); // TODO: Make members const. std::vector<int> mTargetCodePoints; int mProbability; int mTimestamp; int mLevel; int mCount; }; class ShortcutProperty { public: ShortcutProperty(const std::vector<int> *const targetCodePoints, const int probability) : mTargetCodePoints(*targetCodePoints), mProbability(probability) {} UnigramProperty() : mIsNotAWord(false), mIsBlacklisted(false), mProbability(NOT_A_PROBABILITY), mTimestamp(NOT_A_TIMESTAMP), mLevel(0), mCount(0), mShortcuts() {} const std::vector<int> *getTargetCodePoints() const { return &mTargetCodePoints; UnigramProperty(const bool isNotAWord, const bool isBlacklisted, const int probability, const int timestamp, const int level, const int count, const std::vector<ShortcutProperty> *const shortcuts) : mIsNotAWord(isNotAWord), mIsBlacklisted(isBlacklisted), mProbability(probability), mTimestamp(timestamp), mLevel(level), mCount(count), mShortcuts(*shortcuts) {} bool isNotAWord() const { return mIsNotAWord; } bool isBlacklisted() const { return mIsBlacklisted; } bool hasShortcuts() const { return !mShortcuts.empty(); } int getProbability() const { return mProbability; } private: std::vector<int> mTargetCodePoints; int mProbability; }; int getTimestamp() const { return mTimestamp; } // Invalid word. WordProperty() : mCodePoints(), mIsNotAWord(false), mIsBlacklisted(false), mHasBigrams(false), mHasShortcuts(false), mProbability(NOT_A_PROBABILITY), mTimestamp(0), mLevel(0), mCount(0), mBigrams(), mShortcuts() {} int getLevel() const { return mLevel; } WordProperty(const std::vector<int> *const codePoints, const bool isNotAWord, const bool isBlacklisted, const bool hasBigrams, const bool hasShortcuts, const int probability, const int timestamp, const int level, const int count, const std::vector<BigramProperty> *const bigrams, const std::vector<ShortcutProperty> *const shortcuts) : mCodePoints(*codePoints), mIsNotAWord(isNotAWord), mIsBlacklisted(isBlacklisted), mHasBigrams(hasBigrams), mHasShortcuts(hasShortcuts), mProbability(probability), mTimestamp(timestamp), mLevel(level), mCount(count), mBigrams(*bigrams), mShortcuts(*shortcuts) {} int getCount() const { return mCount; } void outputProperties(JNIEnv *const env, jintArray outCodePoints, jbooleanArray outFlags, jintArray outProbabilityInfo, jobject outBigramTargets, jobject outBigramProbabilities, jobject outShortcutTargets, jobject outShortcutProbabilities) const; const std::vector<ShortcutProperty> &getShortcuts() const { return mShortcuts; } private: DISALLOW_ASSIGNMENT_OPERATOR(WordProperty); // Default copy constructor is used for using as a return value. DISALLOW_ASSIGNMENT_OPERATOR(UnigramProperty); std::vector<int> mCodePoints; // TODO: Make members const. bool mIsNotAWord; bool mIsBlacklisted; bool mHasBigrams; bool mHasShortcuts; int mProbability; // Historical information int mTimestamp; int mLevel; int mCount; std::vector<BigramProperty> mBigrams; std::vector<ShortcutProperty> mShortcuts; }; } // namespace latinime #endif // LATINIME_WORD_PROPERTY_H #endif // LATINIME_UNIGRAM_PROPERTY_H