1/*
2 * Copyright (C) 2014 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_SUGGESTED_WORD_H
18#define LATINIME_SUGGESTED_WORD_H
19
20#include <vector>
21
22#include "defines.h"
23#include "suggest/core/dictionary/dictionary.h"
24
25namespace latinime {
26
27class SuggestedWord {
28 public:
29    class Comparator {
30     public:
31        bool operator()(const SuggestedWord &left, const SuggestedWord &right) {
32            if (left.getScore() != right.getScore()) {
33                return left.getScore() > right.getScore();
34            }
35            return left.getCodePointCount() < right.getCodePointCount();
36        }
37
38     private:
39        DISALLOW_ASSIGNMENT_OPERATOR(Comparator);
40    };
41
42    SuggestedWord(const int *const codePoints, const int codePointCount,
43            const int score, const int type, const int indexToPartialCommit,
44            const int autoCommitFirstWordConfidence)
45            : mCodePoints(codePoints, codePoints + codePointCount), mScore(score),
46              mType(type), mIndexToPartialCommit(indexToPartialCommit),
47              mAutoCommitFirstWordConfidence(autoCommitFirstWordConfidence) {}
48
49    const int *getCodePoint() const {
50        return &mCodePoints.at(0);
51    }
52
53    int getCodePointCount() const {
54        return mCodePoints.size();
55    }
56
57    int getScore() const {
58        return mScore;
59    }
60
61    int getType() const {
62        return mType;
63    }
64
65    int getIndexToPartialCommit() const {
66        return mIndexToPartialCommit;
67    }
68
69    int getAutoCommitFirstWordConfidence() const {
70        return mAutoCommitFirstWordConfidence;
71    }
72
73 private:
74    DISALLOW_DEFAULT_CONSTRUCTOR(SuggestedWord);
75
76    std::vector<int> mCodePoints;
77    int mScore;
78    int mType;
79    int mIndexToPartialCommit;
80    int mAutoCommitFirstWordConfidence;
81};
82} // namespace latinime
83#endif /* LATINIME_SUGGESTED_WORD_H */
84