1 /* 2 * Copyright (C) 2012 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_DIC_NODE_UTILS_H 18 #define LATINIME_DIC_NODE_UTILS_H 19 20 #include "defines.h" 21 #include "utils/int_array_view.h" 22 23 namespace latinime { 24 25 class DicNode; 26 class DicNodeVector; 27 class DictionaryStructureWithBufferPolicy; 28 class MultiBigramMap; 29 30 class DicNodeUtils { 31 public: 32 static void initAsRoot( 33 const DictionaryStructureWithBufferPolicy *const dictionaryStructurePolicy, 34 const WordIdArrayView prevWordIds, DicNode *const newRootDicNode); 35 static void initAsRootWithPreviousWord( 36 const DictionaryStructureWithBufferPolicy *const dictionaryStructurePolicy, 37 const DicNode *const prevWordLastDicNode, DicNode *const newRootDicNode); 38 static void initByCopy(const DicNode *const srcDicNode, DicNode *const destDicNode); 39 static void getAllChildDicNodes(const DicNode *dicNode, 40 const DictionaryStructureWithBufferPolicy *const dictionaryStructurePolicy, 41 DicNodeVector *childDicNodes); 42 static float getBigramNodeImprobability( 43 const DictionaryStructureWithBufferPolicy *const dictionaryStructurePolicy, 44 const DicNode *const dicNode, MultiBigramMap *const multiBigramMap); 45 46 private: 47 DISALLOW_IMPLICIT_CONSTRUCTORS(DicNodeUtils); 48 // Max number of bigrams to look up 49 static const int MAX_BIGRAMS_CONSIDERED_PER_CONTEXT = 500; 50 }; 51 } // namespace latinime 52 #endif // LATINIME_DIC_NODE_UTILS_H 53