Add values for suggestion types (A120)
Also, use it in getBigrams. Change-Id: Ia0be9b57d1b7effcd8a936e01e957d1195b39c68main
parent
6931df9c17
commit
c7387a4fd0
|
@ -125,6 +125,7 @@ public class SuggestedWords {
|
|||
public static final int KIND_HARDCODED = 5; // Hardcoded suggestion, e.g. punctuation
|
||||
public static final int KIND_APP_DEFINED = 6; // Suggested by the application
|
||||
public static final int KIND_SHORTCUT = 7; // A shortcut
|
||||
public static final int KIND_PREDICTION = 8; // A prediction (== a suggestion with no input)
|
||||
public final String mWord;
|
||||
public final int mScore;
|
||||
public final int mKind; // one of the KIND_* constants above
|
||||
|
|
|
@ -38,7 +38,7 @@ BigramDictionary::~BigramDictionary() {
|
|||
}
|
||||
|
||||
bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequency,
|
||||
int *bigramFreq, unsigned short *bigramChars) const {
|
||||
int *bigramFreq, unsigned short *bigramChars, int *outputTypes) const {
|
||||
word[length] = 0;
|
||||
if (DEBUG_DICT) {
|
||||
#ifdef FLAG_DBG
|
||||
|
@ -65,6 +65,7 @@ bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequ
|
|||
(char*) bigramFreq + insertAt * sizeof(bigramFreq[0]),
|
||||
(MAX_PREDICTIONS - insertAt - 1) * sizeof(bigramFreq[0]));
|
||||
bigramFreq[insertAt] = frequency;
|
||||
outputTypes[insertAt] = Dictionary::KIND_PREDICTION;
|
||||
memmove((char*) bigramChars + (insertAt + 1) * MAX_WORD_LENGTH * sizeof(short),
|
||||
(char*) bigramChars + (insertAt ) * MAX_WORD_LENGTH * sizeof(short),
|
||||
(MAX_PREDICTIONS - insertAt - 1) * sizeof(short) * MAX_WORD_LENGTH);
|
||||
|
@ -134,8 +135,8 @@ int BigramDictionary::getBigrams(const int32_t *prevWord, int prevWordLength, in
|
|||
// here, but it can't get too bad.
|
||||
const int frequency =
|
||||
BinaryFormat::computeFrequencyForBigram(unigramFreq, bigramFreqTemp);
|
||||
if (addWordBigram(
|
||||
bigramBuffer, length, frequency, bigramFreq, bigramChars)) {
|
||||
if (addWordBigram(bigramBuffer, length, frequency, bigramFreq, bigramChars,
|
||||
outputTypes)) {
|
||||
++bigramCount;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class BigramDictionary {
|
|||
private:
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(BigramDictionary);
|
||||
bool addWordBigram(unsigned short *word, int length, int frequency,
|
||||
int *bigramFreq, unsigned short *bigramChars) const;
|
||||
int *bigramFreq, unsigned short *bigramChars, int *outputTypes) const;
|
||||
int getBigramAddress(int *pos, bool advance);
|
||||
int getBigramFreq(int *pos);
|
||||
void searchForTerminalNode(int addressLookingFor, int frequency);
|
||||
|
|
|
@ -31,6 +31,17 @@ namespace latinime {
|
|||
|
||||
class Dictionary {
|
||||
public:
|
||||
// Taken from SuggestedWords.java
|
||||
const static int KIND_TYPED = 0; // What user typed
|
||||
const static int KIND_CORRECTION = 1; // Simple correction/suggestion
|
||||
const static int KIND_COMPLETION = 2; // Completion (suggestion with appended chars)
|
||||
const static int KIND_WHITELIST = 3; // Whitelisted word
|
||||
const static int KIND_BLACKLIST = 4; // Blacklisted word
|
||||
const static int KIND_HARDCODED = 5; // Hardcoded suggestion, e.g. punctuation
|
||||
const static int KIND_APP_DEFINED = 6; // Suggested by the application
|
||||
const static int KIND_SHORTCUT = 7; // A shortcut
|
||||
const static int KIND_PREDICTION = 8; // A prediction (== a suggestion with no input)
|
||||
|
||||
Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, int typedLetterMultipler,
|
||||
int fullWordMultiplier, int maxWordLength, int maxWords, int maxPredictions);
|
||||
|
||||
|
|
Loading…
Reference in New Issue