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), mLanguageWeight(NOT_A_LANGUAGE_WEIGHT), 33 mSuggestedWords() {} 34 35 // Returns suggestion count. 36 void outputSuggestions(JNIEnv *env, jintArray outSuggestionCount, jintArray outCodePointsArray, 37 jintArray outScoresArray, jintArray outSpaceIndicesArray, jintArray outTypesArray, 38 jintArray outAutoCommitFirstWordConfidenceArray, jfloatArray outLanguageWeight); 39 void addPrediction(const int *const codePoints, const int codePointCount, const int score); 40 void addSuggestion(const int *const codePoints, const int codePointCount, 41 const int score, const int type, const int indexToPartialCommit, 42 const int autocimmitFirstWordConfindence); 43 void getSortedScores(int *const outScores) const; 44 void dumpSuggestions() const; 45 setLanguageWeight(const float languageWeight)46 void setLanguageWeight(const float languageWeight) { 47 mLanguageWeight = languageWeight; 48 } 49 getSuggestionCount()50 int getSuggestionCount() const { 51 return mSuggestedWords.size(); 52 } 53 54 private: 55 DISALLOW_IMPLICIT_CONSTRUCTORS(SuggestionResults); 56 57 const int mMaxSuggestionCount; 58 float mLanguageWeight; 59 std::priority_queue< 60 SuggestedWord, std::vector<SuggestedWord>, SuggestedWord::Comparator> mSuggestedWords; 61 }; 62 } // namespace latinime 63 #endif // LATINIME_SUGGESTION_RESULTS_H 64