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 22 namespace latinime { 23 24 class BinaryDictionaryShortcutIterator; 25 class DicNode; 26 class DicTraverseSession; 27 class Scoring; 28 class SuggestionResults; 29 30 class SuggestionsOutputUtils { 31 public: 32 /** 33 * Outputs the final list of suggestions (i.e., terminal nodes). 34 */ 35 static void outputSuggestions(const Scoring *const scoringPolicy, 36 DicTraverseSession *traverseSession, const float languageWeight, 37 SuggestionResults *const outSuggestionResults); 38 39 private: 40 DISALLOW_IMPLICIT_CONSTRUCTORS(SuggestionsOutputUtils); 41 42 // Inputs longer than this will autocorrect if the suggestion is multi-word 43 static const int MIN_LEN_FOR_MULTI_WORD_AUTOCORRECT; 44 45 static void outputSuggestionsOfDicNode(const Scoring *const scoringPolicy, 46 DicTraverseSession *traverseSession, const DicNode *const terminalDicNode, 47 const float languageWeight, const bool boostExactMatches, 48 const bool forceCommitMultiWords, const bool outputSecondWordFirstLetterInputIndex, 49 SuggestionResults *const outSuggestionResults); 50 static void outputShortcuts(BinaryDictionaryShortcutIterator *const shortcutIt, 51 const int finalScore, const bool sameAsTyped, 52 SuggestionResults *const outSuggestionResults); 53 static int computeFirstWordConfidence(const DicNode *const terminalDicNode); 54 }; 55 } // namespace latinime 56 #endif // LATINIME_SUGGESTIONS_OUTPUT_UTILS 57