suggestion_results.h revision d73edf23aca59e6a0a83a79cf24db3850ef473ff
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 27namespace latinime { 28 29class SuggestionResults { 30 public: 31 explicit SuggestionResults(const int maxSuggestionCount) 32 : mMaxSuggestionCount(maxSuggestionCount), mSuggestedWords() {} 33 34 // Returns suggestion count. 35 void outputSuggestions(JNIEnv *env, jintArray outSuggestionCount, jintArray outCodePointsArray, 36 jintArray outScoresArray, jintArray outSpaceIndicesArray, jintArray outTypesArray, 37 jintArray outAutoCommitFirstWordConfidenceArray); 38 void addPrediction(const int *const codePoints, const int codePointCount, const int score); 39 void addSuggestion(const int *const codePoints, const int codePointCount, 40 const int score, const int type, const int indexToPartialCommit, 41 const int autocimmitFirstWordConfindence); 42 void getSortedScores(int *const outScores) const; 43 void dumpSuggestions() const; 44 45 int getSuggestionCount() const { 46 return mSuggestedWords.size(); 47 } 48 49 private: 50 DISALLOW_IMPLICIT_CONSTRUCTORS(SuggestionResults); 51 52 const int mMaxSuggestionCount; 53 std::priority_queue< 54 SuggestedWord, std::vector<SuggestedWord>, SuggestedWord::Comparator> mSuggestedWords; 55}; 56} // namespace latinime 57#endif // LATINIME_SUGGESTION_RESULTS_H 58