• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SUGGESTIONS_OUTPUT_UTILS
18 #define LATINIME_SUGGESTIONS_OUTPUT_UTILS
19 
20 #include "defines.h"
21 #include "dictionary/property/word_attributes.h"
22 
23 namespace latinime {
24 
25 class BinaryDictionaryShortcutIterator;
26 class DicNode;
27 class DicTraverseSession;
28 class Scoring;
29 class SuggestOptions;
30 class SuggestionResults;
31 
32 class SuggestionsOutputUtils {
33  public:
34     /**
35      * Returns true if we should block the incoming word, in the context of the user's
36      * preferences to include or not include possibly offensive words
37      */
38     static bool shouldBlockWord(const SuggestOptions *const suggestOptions,
39             const DicNode *const terminalDicNode, const WordAttributes wordAttributes,
40             const bool isLastWord);
41     /**
42      * Outputs the final list of suggestions (i.e., terminal nodes).
43      */
44     static void outputSuggestions(const Scoring *const scoringPolicy,
45             DicTraverseSession *traverseSession, const float weightOfLangModelVsSpatialModel,
46             SuggestionResults *const outSuggestionResults);
47 
48  private:
49     DISALLOW_IMPLICIT_CONSTRUCTORS(SuggestionsOutputUtils);
50 
51     // Inputs longer than this will autocorrect if the suggestion is multi-word
52     static const int MIN_LEN_FOR_MULTI_WORD_AUTOCORRECT;
53 
54     static void outputSuggestionsOfDicNode(const Scoring *const scoringPolicy,
55             DicTraverseSession *traverseSession, const DicNode *const terminalDicNode,
56             const float weightOfLangModelVsSpatialModel, const bool boostExactMatches,
57             const bool forceCommitMultiWords, const bool outputSecondWordFirstLetterInputIndex,
58             SuggestionResults *const outSuggestionResults);
59     static void outputShortcuts(BinaryDictionaryShortcutIterator *const shortcutIt,
60             const int finalScore, const bool sameAsTyped,
61             SuggestionResults *const outSuggestionResults);
62     static int computeFirstWordConfidence(const DicNode *const terminalDicNode);
63 };
64 } // namespace latinime
65 #endif // LATINIME_SUGGESTIONS_OUTPUT_UTILS
66