Home | History | Annotate | Download | only in dicnode
      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 <stdint.h>
     21 
     22 #include "defines.h"
     23 
     24 namespace latinime {
     25 
     26 class DicNode;
     27 class DicNodeVector;
     28 class DictionaryStructureWithBufferPolicy;
     29 class MultiBigramMap;
     30 
     31 class DicNodeUtils {
     32  public:
     33     static int appendTwoWords(const int *src0, const int16_t length0, const int *src1,
     34             const int16_t length1, int *dest);
     35     static void initAsRoot(
     36             const DictionaryStructureWithBufferPolicy *const dictionaryStructurePolicy,
     37             const int prevWordNodePos, DicNode *newRootNode);
     38     static void initAsRootWithPreviousWord(
     39             const DictionaryStructureWithBufferPolicy *const dictionaryStructurePolicy,
     40             DicNode *prevWordLastNode, DicNode *newRootNode);
     41     static void initByCopy(DicNode *srcNode, DicNode *destNode);
     42     static void getAllChildDicNodes(DicNode *dicNode,
     43             const DictionaryStructureWithBufferPolicy *const dictionaryStructurePolicy,
     44             DicNodeVector *childDicNodes);
     45     static float getBigramNodeImprobability(
     46             const DictionaryStructureWithBufferPolicy *const dictionaryStructurePolicy,
     47             const DicNode *const node, MultiBigramMap *const multiBigramMap);
     48 
     49  private:
     50     DISALLOW_IMPLICIT_CONSTRUCTORS(DicNodeUtils);
     51     // Max number of bigrams to look up
     52     static const int MAX_BIGRAMS_CONSIDERED_PER_CONTEXT = 500;
     53 
     54     static int getBigramNodeProbability(
     55             const DictionaryStructureWithBufferPolicy *const dictionaryStructurePolicy,
     56             const DicNode *const node, MultiBigramMap *multiBigramMap);
     57 };
     58 } // namespace latinime
     59 #endif // LATINIME_DIC_NODE_UTILS_H
     60