Merge "Allow one-character suggestions." into jb-mr1-dev
This commit is contained in:
commit
e2ac3932e3
4 changed files with 35 additions and 42 deletions
|
@ -178,7 +178,7 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object,
|
||||||
memset(outputTypes, 0, outputTypesLength * sizeof(outputTypes[0]));
|
memset(outputTypes, 0, outputTypesLength * sizeof(outputTypes[0]));
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
if (isGesture || arraySize > 1) {
|
if (isGesture || arraySize > 0) {
|
||||||
count = dictionary->getSuggestions(pInfo, traverseSession, xCoordinates, yCoordinates,
|
count = dictionary->getSuggestions(pInfo, traverseSession, xCoordinates, yCoordinates,
|
||||||
times, pointerIds, inputCodePoints, arraySize, prevWordCodePoints,
|
times, pointerIds, inputCodePoints, arraySize, prevWordCodePoints,
|
||||||
prevWordCodePointsLength, commitPoint, isGesture, useFullEditDistance, outputChars,
|
prevWordCodePointsLength, commitPoint, isGesture, useFullEditDistance, outputChars,
|
||||||
|
|
|
@ -181,10 +181,6 @@ int Correction::getFinalProbabilityInternal(const int probability, unsigned shor
|
||||||
const int outputIndex = mTerminalOutputIndex;
|
const int outputIndex = mTerminalOutputIndex;
|
||||||
const int inputIndex = mTerminalInputIndex;
|
const int inputIndex = mTerminalInputIndex;
|
||||||
*wordLength = outputIndex + 1;
|
*wordLength = outputIndex + 1;
|
||||||
if (outputIndex < MIN_SUGGEST_DEPTH) {
|
|
||||||
return NOT_A_PROBABILITY;
|
|
||||||
}
|
|
||||||
|
|
||||||
*word = mWord;
|
*word = mWord;
|
||||||
int finalProbability= Correction::RankingAlgorithm::calculateFinalProbability(
|
int finalProbability= Correction::RankingAlgorithm::calculateFinalProbability(
|
||||||
inputIndex, outputIndex, probability, mEditDistanceTable, this, inputLength);
|
inputIndex, outputIndex, probability, mEditDistanceTable, this, inputLength);
|
||||||
|
|
|
@ -298,8 +298,6 @@ static inline void prof_out(void) {
|
||||||
// word in the dictionary for languages with digraphs, like German and French
|
// word in the dictionary for languages with digraphs, like German and French
|
||||||
#define DEFAULT_MAX_DIGRAPH_SEARCH_DEPTH 5
|
#define DEFAULT_MAX_DIGRAPH_SEARCH_DEPTH 5
|
||||||
|
|
||||||
// Minimum suggest depth for one word for all cases except for missing space suggestions.
|
|
||||||
#define MIN_SUGGEST_DEPTH 1
|
|
||||||
#define MIN_USER_TYPED_LENGTH_FOR_MULTIPLE_WORD_SUGGESTION 3
|
#define MIN_USER_TYPED_LENGTH_FOR_MULTIPLE_WORD_SUGGESTION 3
|
||||||
#define MIN_USER_TYPED_LENGTH_FOR_EXCESSIVE_CHARACTER_SUGGESTION 3
|
#define MIN_USER_TYPED_LENGTH_FOR_EXCESSIVE_CHARACTER_SUGGESTION 3
|
||||||
|
|
||||||
|
|
|
@ -390,43 +390,42 @@ inline void UnigramDictionary::onTerminal(const int probability,
|
||||||
WordsPriorityQueue *masterQueue = queuePool->getMasterQueue();
|
WordsPriorityQueue *masterQueue = queuePool->getMasterQueue();
|
||||||
const int finalProbability =
|
const int finalProbability =
|
||||||
correction->getFinalProbability(probability, &wordPointer, &wordLength);
|
correction->getFinalProbability(probability, &wordPointer, &wordLength);
|
||||||
if (finalProbability != NOT_A_PROBABILITY) {
|
|
||||||
if (0 != finalProbability) {
|
|
||||||
// If the probability is 0, we don't want to add this word. However we still
|
|
||||||
// want to add its shortcuts (including a possible whitelist entry) if any.
|
|
||||||
addWord(wordPointer, wordLength, finalProbability, masterQueue,
|
|
||||||
Dictionary::KIND_CORRECTION);
|
|
||||||
}
|
|
||||||
|
|
||||||
const int shortcutProbability = finalProbability > 0 ? finalProbability - 1 : 0;
|
if (0 != finalProbability) {
|
||||||
// Please note that the shortcut candidates will be added to the master queue only.
|
// If the probability is 0, we don't want to add this word. However we still
|
||||||
TerminalAttributes::ShortcutIterator iterator =
|
// want to add its shortcuts (including a possible whitelist entry) if any.
|
||||||
terminalAttributes.getShortcutIterator();
|
addWord(wordPointer, wordLength, finalProbability, masterQueue,
|
||||||
while (iterator.hasNextShortcutTarget()) {
|
Dictionary::KIND_CORRECTION);
|
||||||
// TODO: addWord only supports weak ordering, meaning we have no means
|
}
|
||||||
// to control the order of the shortcuts relative to one another or to the word.
|
|
||||||
// We need to either modulate the probability of each shortcut according
|
const int shortcutProbability = finalProbability > 0 ? finalProbability - 1 : 0;
|
||||||
// to its own shortcut probability or to make the queue
|
// Please note that the shortcut candidates will be added to the master queue only.
|
||||||
// so that the insert order is protected inside the queue for words
|
TerminalAttributes::ShortcutIterator iterator =
|
||||||
// with the same score. For the moment we use -1 to make sure the shortcut will
|
terminalAttributes.getShortcutIterator();
|
||||||
// never be in front of the word.
|
while (iterator.hasNextShortcutTarget()) {
|
||||||
uint16_t shortcutTarget[MAX_WORD_LENGTH_INTERNAL];
|
// TODO: addWord only supports weak ordering, meaning we have no means
|
||||||
int shortcutFrequency;
|
// to control the order of the shortcuts relative to one another or to the word.
|
||||||
const int shortcutTargetStringLength = iterator.getNextShortcutTarget(
|
// We need to either modulate the probability of each shortcut according
|
||||||
MAX_WORD_LENGTH_INTERNAL, shortcutTarget, &shortcutFrequency);
|
// to its own shortcut probability or to make the queue
|
||||||
int shortcutScore;
|
// so that the insert order is protected inside the queue for words
|
||||||
int kind;
|
// with the same score. For the moment we use -1 to make sure the shortcut will
|
||||||
if (shortcutFrequency == BinaryFormat::WHITELIST_SHORTCUT_FREQUENCY
|
// never be in front of the word.
|
||||||
&& correction->sameAsTyped()) {
|
uint16_t shortcutTarget[MAX_WORD_LENGTH_INTERNAL];
|
||||||
shortcutScore = S_INT_MAX;
|
int shortcutFrequency;
|
||||||
kind = Dictionary::KIND_WHITELIST;
|
const int shortcutTargetStringLength = iterator.getNextShortcutTarget(
|
||||||
} else {
|
MAX_WORD_LENGTH_INTERNAL, shortcutTarget, &shortcutFrequency);
|
||||||
shortcutScore = shortcutProbability;
|
int shortcutScore;
|
||||||
kind = Dictionary::KIND_CORRECTION;
|
int kind;
|
||||||
}
|
if (shortcutFrequency == BinaryFormat::WHITELIST_SHORTCUT_FREQUENCY
|
||||||
addWord(shortcutTarget, shortcutTargetStringLength, shortcutScore,
|
&& correction->sameAsTyped()) {
|
||||||
masterQueue, kind);
|
shortcutScore = S_INT_MAX;
|
||||||
|
kind = Dictionary::KIND_WHITELIST;
|
||||||
|
} else {
|
||||||
|
shortcutScore = shortcutProbability;
|
||||||
|
kind = Dictionary::KIND_CORRECTION;
|
||||||
}
|
}
|
||||||
|
addWord(shortcutTarget, shortcutTargetStringLength, shortcutScore,
|
||||||
|
masterQueue, kind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue