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_SUGGESTION_RESULTS_H 18 #define LATINIME_SUGGESTION_RESULTS_H 19 20 #include <queue> 21 #include <vector> 22 23 #include "defines.h" 24 #include "jni.h" 25 #include "suggest/core/result/suggested_word.h" 26 27 namespace latinime { 28 29 class SuggestionResults { 30 public: SuggestionResults(const int maxSuggestionCount)31 explicit SuggestionResults(const int maxSuggestionCount) 32 : mMaxSuggestionCount(maxSuggestionCount), 33 mWeightOfLangModelVsSpatialModel(NOT_A_WEIGHT_OF_LANG_MODEL_VS_SPATIAL_MODEL), 34 mSuggestedWords() {} 35 36 // Returns suggestion count. 37 void outputSuggestions(JNIEnv *env, jintArray outSuggestionCount, jintArray outCodePointsArray, 38 jintArray outScoresArray, jintArray outSpaceIndicesArray, jintArray outTypesArray, 39 jintArray outAutoCommitFirstWordConfidenceArray, 40 jfloatArray outWeightOfLangModelVsSpatialModel); 41 void addPrediction(const int *const codePoints, const int codePointCount, const int score); 42 void addSuggestion(const int *const codePoints, const int codePointCount, 43 const int score, const int type, const int indexToPartialCommit, 44 const int autocimmitFirstWordConfindence); 45 void getSortedScores(int *const outScores) const; 46 void dumpSuggestions() const; 47 setWeightOfLangModelVsSpatialModel(const float weightOfLangModelVsSpatialModel)48 void setWeightOfLangModelVsSpatialModel(const float weightOfLangModelVsSpatialModel) { 49 mWeightOfLangModelVsSpatialModel = weightOfLangModelVsSpatialModel; 50 } 51 getSuggestionCount()52 int getSuggestionCount() const { 53 return mSuggestedWords.size(); 54 } 55 56 private: 57 DISALLOW_IMPLICIT_CONSTRUCTORS(SuggestionResults); 58 59 const int mMaxSuggestionCount; 60 float mWeightOfLangModelVsSpatialModel; 61 std::priority_queue< 62 SuggestedWord, std::vector<SuggestedWord>, SuggestedWord::Comparator> mSuggestedWords; 63 }; 64 } // namespace latinime 65 #endif // LATINIME_SUGGESTION_RESULTS_H 66