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_UNIGRAM_PROPERTY_H 18 #define LATINIME_UNIGRAM_PROPERTY_H 19 20 #include <vector> 21 22 #include "defines.h" 23 24 namespace latinime { 25 26 class UnigramProperty { 27 public: 28 class ShortcutProperty { 29 public: ShortcutProperty(const std::vector<int> * const targetCodePoints,const int probability)30 ShortcutProperty(const std::vector<int> *const targetCodePoints, const int probability) 31 : mTargetCodePoints(*targetCodePoints), mProbability(probability) {} 32 getTargetCodePoints()33 const std::vector<int> *getTargetCodePoints() const { 34 return &mTargetCodePoints; 35 } 36 getProbability()37 int getProbability() const { 38 return mProbability; 39 } 40 41 private: 42 // Default copy constructor and assign operator are used for using in std::vector. 43 DISALLOW_DEFAULT_CONSTRUCTOR(ShortcutProperty); 44 45 // TODO: Make members const. 46 std::vector<int> mTargetCodePoints; 47 int mProbability; 48 }; 49 UnigramProperty()50 UnigramProperty() 51 : mRepresentsBeginningOfSentence(false), mIsNotAWord(false), mIsBlacklisted(false), 52 mProbability(NOT_A_PROBABILITY), mTimestamp(NOT_A_TIMESTAMP), mLevel(0), mCount(0), 53 mShortcuts() {} 54 UnigramProperty(const bool representsBeginningOfSentence,const bool isNotAWord,const bool isBlacklisted,const int probability,const int timestamp,const int level,const int count,const std::vector<ShortcutProperty> * const shortcuts)55 UnigramProperty(const bool representsBeginningOfSentence, const bool isNotAWord, 56 const bool isBlacklisted, const int probability, const int timestamp, const int level, 57 const int count, const std::vector<ShortcutProperty> *const shortcuts) 58 : mRepresentsBeginningOfSentence(representsBeginningOfSentence), 59 mIsNotAWord(isNotAWord), mIsBlacklisted(isBlacklisted), mProbability(probability), 60 mTimestamp(timestamp), mLevel(level), mCount(count), mShortcuts(*shortcuts) {} 61 representsBeginningOfSentence()62 bool representsBeginningOfSentence() const { 63 return mRepresentsBeginningOfSentence; 64 } 65 isNotAWord()66 bool isNotAWord() const { 67 return mIsNotAWord; 68 } 69 isBlacklisted()70 bool isBlacklisted() const { 71 return mIsBlacklisted; 72 } 73 hasShortcuts()74 bool hasShortcuts() const { 75 return !mShortcuts.empty(); 76 } 77 getProbability()78 int getProbability() const { 79 return mProbability; 80 } 81 getTimestamp()82 int getTimestamp() const { 83 return mTimestamp; 84 } 85 getLevel()86 int getLevel() const { 87 return mLevel; 88 } 89 getCount()90 int getCount() const { 91 return mCount; 92 } 93 getShortcuts()94 const std::vector<ShortcutProperty> &getShortcuts() const { 95 return mShortcuts; 96 } 97 98 private: 99 // Default copy constructor is used for using as a return value. 100 DISALLOW_ASSIGNMENT_OPERATOR(UnigramProperty); 101 102 // TODO: Make members const. 103 bool mRepresentsBeginningOfSentence; 104 bool mIsNotAWord; 105 bool mIsBlacklisted; 106 int mProbability; 107 // Historical information 108 int mTimestamp; 109 int mLevel; 110 int mCount; 111 std::vector<ShortcutProperty> mShortcuts; 112 }; 113 } // namespace latinime 114 #endif // LATINIME_UNIGRAM_PROPERTY_H 115