Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: third_party/prediction/suggest/core/policy/weighting.h

Issue 1247903003: Add spellcheck and word suggestion to the prediction service (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013 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_WEIGHTING_H
18 #define LATINIME_WEIGHTING_H
19
20 #include "third_party/prediction/defines.h"
21 #include "third_party/prediction/suggest/core/dictionary/error_type_utils.h"
22
23 namespace latinime {
24
25 class DicNode;
26 class DicTraverseSession;
27 struct DicNode_InputStateG;
28 class MultiBigramMap;
29
30 class Weighting {
31 public:
32 static void addCostAndForwardInputIndex(
33 const Weighting* const weighting,
34 const CorrectionType correctionType,
35 const DicTraverseSession* const traverseSession,
36 const DicNode* const parentDicNode,
37 DicNode* const dicNode,
38 MultiBigramMap* const multiBigramMap);
39
40 protected:
41 virtual float getTerminalSpatialCost(
42 const DicTraverseSession* const traverseSession,
43 const DicNode* const dicNode) const = 0;
44
45 virtual float getOmissionCost(const DicNode* const parentDicNode,
46 const DicNode* const dicNode) const = 0;
47
48 virtual float getMatchedCost(const DicTraverseSession* const traverseSession,
49 const DicNode* const dicNode,
50 DicNode_InputStateG* inputStateG) const = 0;
51
52 virtual bool isProximityDicNode(
53 const DicTraverseSession* const traverseSession,
54 const DicNode* const dicNode) const = 0;
55
56 virtual float getTranspositionCost(
57 const DicTraverseSession* const traverseSession,
58 const DicNode* const parentDicNode,
59 const DicNode* const dicNode) const = 0;
60
61 virtual float getInsertionCost(
62 const DicTraverseSession* const traverseSession,
63 const DicNode* const parentDicNode,
64 const DicNode* const dicNode) const = 0;
65
66 virtual float getNewWordSpatialCost(
67 const DicTraverseSession* const traverseSession,
68 const DicNode* const dicNode,
69 DicNode_InputStateG* const inputStateG) const = 0;
70
71 virtual float getNewWordBigramLanguageCost(
72 const DicTraverseSession* const traverseSession,
73 const DicNode* const dicNode,
74 MultiBigramMap* const multiBigramMap) const = 0;
75
76 virtual float getCompletionCost(
77 const DicTraverseSession* const traverseSession,
78 const DicNode* const dicNode) const = 0;
79
80 virtual float getTerminalInsertionCost(
81 const DicTraverseSession* const traverseSession,
82 const DicNode* const dicNode) const = 0;
83
84 virtual float getTerminalLanguageCost(
85 const DicTraverseSession* const traverseSession,
86 const DicNode* const dicNode,
87 float dicNodeLanguageImprobability) const = 0;
88
89 virtual bool needsToNormalizeCompoundDistance() const = 0;
90
91 virtual float getAdditionalProximityCost() const = 0;
92
93 virtual float getSubstitutionCost() const = 0;
94
95 virtual float getSpaceSubstitutionCost(
96 const DicTraverseSession* const traverseSession,
97 const DicNode* const dicNode) const = 0;
98
99 virtual ErrorTypeUtils::ErrorType getErrorType(
100 const CorrectionType correctionType,
101 const DicTraverseSession* const traverseSession,
102 const DicNode* const parentDicNode,
103 const DicNode* const dicNode) const = 0;
104
105 Weighting() {}
106 virtual ~Weighting() {}
107
108 private:
109 DISALLOW_COPY_AND_ASSIGN(Weighting);
110
111 static float getSpatialCost(const Weighting* const weighting,
112 const CorrectionType correctionType,
113 const DicTraverseSession* const traverseSession,
114 const DicNode* const parentDicNode,
115 const DicNode* const dicNode,
116 DicNode_InputStateG* const inputStateG);
117 static float getLanguageCost(const Weighting* const weighting,
118 const CorrectionType correctionType,
119 const DicTraverseSession* const traverseSession,
120 const DicNode* const parentDicNode,
121 const DicNode* const dicNode,
122 MultiBigramMap* const multiBigramMap);
123 // TODO: Move to TypingWeighting and GestureWeighting?
124 static int getForwardInputCount(const CorrectionType correctionType);
125 };
126 } // namespace latinime
127 #endif // LATINIME_WEIGHTING_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698