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_ATTRIBUTES_H 18 #define LATINIME_WORD_ATTRIBUTES_H 19 20 #include "defines.h" 21 22 class WordAttributes { 23 public: 24 // Invalid word attributes. WordAttributes()25 WordAttributes() 26 : mProbability(NOT_A_PROBABILITY), mIsBlacklisted(false), mIsNotAWord(false), 27 mIsPossiblyOffensive(false) {} 28 WordAttributes(const int probability,const bool isBlacklisted,const bool isNotAWord,const bool isPossiblyOffensive)29 WordAttributes(const int probability, const bool isBlacklisted, const bool isNotAWord, 30 const bool isPossiblyOffensive) 31 : mProbability(probability), mIsBlacklisted(isBlacklisted), mIsNotAWord(isNotAWord), 32 mIsPossiblyOffensive(isPossiblyOffensive) {} 33 getProbability()34 int getProbability() const { 35 return mProbability; 36 } 37 isBlacklisted()38 bool isBlacklisted() const { 39 return mIsBlacklisted; 40 } 41 isNotAWord()42 bool isNotAWord() const { 43 return mIsNotAWord; 44 } 45 46 // Whether or not a word is possibly offensive. 47 // * Static dictionaries <v202, as well as dynamic dictionaries <v403, will set this based on 48 // whether or not the probability of the word is zero. 49 // * Static dictionaries >=v203 will set this based on the IS_POSSIBLY_OFFENSIVE PtNode flag. 50 // * Dynamic dictionaries >=v403 will set this based on the IS_POSSIBLY_OFFENSIVE language model 51 // flag (the PtNode flag IS_BLACKLISTED is ignored and kept as zero) 52 // 53 // See the ::getWordAttributes function for each of these dictionary policies for more details. isPossiblyOffensive()54 bool isPossiblyOffensive() const { 55 return mIsPossiblyOffensive; 56 } 57 58 private: 59 DISALLOW_ASSIGNMENT_OPERATOR(WordAttributes); 60 61 int mProbability; 62 bool mIsBlacklisted; 63 bool mIsNotAWord; 64 bool mIsPossiblyOffensive; 65 }; 66 67 // namespace 68 #endif /* LATINIME_WORD_ATTRIBUTES_H */ 69