1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef LATINIME_WORD_PROPERTY_H 18 #define LATINIME_WORD_PROPERTY_H 19 20 #include <vector> 21 22 #include "defines.h" 23 #include "jni.h" 24 #include "suggest/core/dictionary/property/bigram_property.h" 25 #include "suggest/core/dictionary/property/unigram_property.h" 26 27 namespace latinime { 28 29 // This class is used for returning information belonging to a word to java side. 30 class WordProperty { 31 public: 32 // Default constructor is used to create an instance that indicates an invalid word. WordProperty()33 WordProperty() 34 : mCodePoints(), mUnigramProperty(), mBigrams() {} 35 WordProperty(const std::vector<int> * const codePoints,const UnigramProperty * const unigramProperty,const std::vector<BigramProperty> * const bigrams)36 WordProperty(const std::vector<int> *const codePoints, 37 const UnigramProperty *const unigramProperty, 38 const std::vector<BigramProperty> *const bigrams) 39 : mCodePoints(*codePoints), mUnigramProperty(*unigramProperty), mBigrams(*bigrams) {} 40 41 void outputProperties(JNIEnv *const env, jintArray outCodePoints, jbooleanArray outFlags, 42 jintArray outProbabilityInfo, jobject outBigramTargets, jobject outBigramProbabilities, 43 jobject outShortcutTargets, jobject outShortcutProbabilities) const; 44 getUnigramProperty()45 const UnigramProperty *getUnigramProperty() const { 46 return &mUnigramProperty; 47 } 48 getBigramProperties()49 const std::vector<BigramProperty> *getBigramProperties() const { 50 return &mBigrams; 51 } 52 53 private: 54 // Default copy constructor is used for using as a return value. 55 DISALLOW_ASSIGNMENT_OPERATOR(WordProperty); 56 57 const std::vector<int> mCodePoints; 58 const UnigramProperty mUnigramProperty; 59 const std::vector<BigramProperty> mBigrams; 60 }; 61 } // namespace latinime 62 #endif // LATINIME_WORD_PROPERTY_H 63