dic_node_utils.h revision d9b8602f4862c2c876e1499aad7ca7d77ea66595
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
22namespace latinime {
23
24class DicNode;
25class DicNodeVector;
26class DictionaryStructureWithBufferPolicy;
27class MultiBigramMap;
28
29class DicNodeUtils {
30 public:
31    static void initAsRoot(
32            const DictionaryStructureWithBufferPolicy *const dictionaryStructurePolicy,
33            const int *const prevWordPtNodePos, DicNode *const newRootDicNode);
34    static void initAsRootWithPreviousWord(
35            const DictionaryStructureWithBufferPolicy *const dictionaryStructurePolicy,
36            const DicNode *const prevWordLastDicNode, DicNode *const newRootDicNode);
37    static void initByCopy(const DicNode *const srcDicNode, DicNode *const destDicNode);
38    static void getAllChildDicNodes(const DicNode *dicNode,
39            const DictionaryStructureWithBufferPolicy *const dictionaryStructurePolicy,
40            DicNodeVector *childDicNodes);
41    static float getBigramNodeImprobability(
42            const DictionaryStructureWithBufferPolicy *const dictionaryStructurePolicy,
43            const DicNode *const dicNode, MultiBigramMap *const multiBigramMap);
44
45 private:
46    DISALLOW_IMPLICIT_CONSTRUCTORS(DicNodeUtils);
47    // Max number of bigrams to look up
48    static const int MAX_BIGRAMS_CONSIDERED_PER_CONTEXT = 500;
49
50    static int getBigramNodeProbability(
51            const DictionaryStructureWithBufferPolicy *const dictionaryStructurePolicy,
52            const DicNode *const dicNode, MultiBigramMap *const multiBigramMap);
53};
54} // namespace latinime
55#endif // LATINIME_DIC_NODE_UTILS_H
56