am 7c20f140: Merge "Remove unused partial commit."
* commit '7c20f140e0ab3efa25dd0708e1373b231339f5e2': Remove unused partial commit.main
commit
607ed07fa7
|
@ -161,9 +161,9 @@ public final class BinaryDictionary extends Dictionary {
|
|||
private static native int getNextWordNative(long dict, int token, int[] outCodePoints);
|
||||
private static native void getSuggestionsNative(long dict, long proximityInfo,
|
||||
long traverseSession, int[] xCoordinates, int[] yCoordinates, int[] times,
|
||||
int[] pointerIds, int[] inputCodePoints, int inputSize, int commitPoint,
|
||||
int[] suggestOptions, int[] prevWordCodePointArray, int[] outputSuggestionCount,
|
||||
int[] outputCodePoints, int[] outputScores, int[] outputIndices, int[] outputTypes,
|
||||
int[] pointerIds, int[] inputCodePoints, int inputSize, int[] suggestOptions,
|
||||
int[] prevWordCodePointArray, int[] outputSuggestionCount, int[] outputCodePoints,
|
||||
int[] outputScores, int[] outputIndices, int[] outputTypes,
|
||||
int[] outputAutoCommitFirstWordConfidence);
|
||||
private static native void addUnigramWordNative(long dict, int[] word, int probability,
|
||||
int[] shortcutTarget, int shortcutProbability, boolean isNotAWord,
|
||||
|
@ -262,7 +262,7 @@ public final class BinaryDictionary extends Dictionary {
|
|||
getSuggestionsNative(mNativeDict, proximityInfo.getNativeProximityInfo(),
|
||||
getTraverseSession(sessionId).getSession(), ips.getXCoordinates(),
|
||||
ips.getYCoordinates(), ips.getTimes(), ips.getPointerIds(), mInputCodePoints,
|
||||
inputSize, 0 /* commitPoint */, mNativeSuggestOptions.getOptions(),
|
||||
inputSize, mNativeSuggestOptions.getOptions(),
|
||||
prevWordCodePointArray, mOutputSuggestionCount, mOutputCodePoints, mOutputScores,
|
||||
mSpaceIndices, mOutputTypes, mOutputAutoCommitFirstWordConfidence);
|
||||
final int count = mOutputSuggestionCount[0];
|
||||
|
|
|
@ -143,7 +143,7 @@ static int latinime_BinaryDictionary_getFormatVersion(JNIEnv *env, jclass clazz,
|
|||
static void latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jclass clazz, jlong dict,
|
||||
jlong proximityInfo, jlong dicTraverseSession, jintArray xCoordinatesArray,
|
||||
jintArray yCoordinatesArray, jintArray timesArray, jintArray pointerIdsArray,
|
||||
jintArray inputCodePointsArray, jint inputSize, jint commitPoint, jintArray suggestOptions,
|
||||
jintArray inputCodePointsArray, jint inputSize, jintArray suggestOptions,
|
||||
jintArray prevWordCodePointsForBigrams, jintArray outSuggestionCount,
|
||||
jintArray outCodePointsArray, jintArray outScoresArray, jintArray outSpaceIndicesArray,
|
||||
jintArray outTypesArray, jintArray outAutoCommitFirstWordConfidenceArray) {
|
||||
|
@ -220,7 +220,7 @@ static void latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jclass clazz,
|
|||
// TODO: Use SuggestionResults to return suggestions.
|
||||
count = dictionary->getSuggestions(pInfo, traverseSession, xCoordinates, yCoordinates,
|
||||
times, pointerIds, inputCodePoints, inputSize, prevWordCodePoints,
|
||||
prevWordCodePointsLength, commitPoint, &givenSuggestOptions, outputCodePoints,
|
||||
prevWordCodePointsLength, &givenSuggestOptions, outputCodePoints,
|
||||
scores, spaceIndices, outputTypes, outputAutoCommitFirstWordConfidence);
|
||||
} else {
|
||||
SuggestionResults suggestionResults(MAX_RESULTS);
|
||||
|
@ -506,7 +506,7 @@ static const JNINativeMethod sMethods[] = {
|
|||
},
|
||||
{
|
||||
const_cast<char *>("getSuggestionsNative"),
|
||||
const_cast<char *>("(JJJ[I[I[I[I[III[I[I[I[I[I[I[I[I)V"),
|
||||
const_cast<char *>("(JJJ[I[I[I[I[II[I[I[I[I[I[I[I[I)V"),
|
||||
reinterpret_cast<void *>(latinime_BinaryDictionary_getSuggestions)
|
||||
},
|
||||
{
|
||||
|
|
|
@ -284,33 +284,6 @@ class DicNode {
|
|||
return prevWordsLen + currentWordDepth > MAX_WORD_LENGTH - 3;
|
||||
}
|
||||
|
||||
// TODO: This may be defective. Needs to be revised.
|
||||
bool truncateNode(const DicNode *const topNode, const int inputCommitPoint) {
|
||||
const int prevWordLenOfTop = mDicNodeState.mDicNodeStatePrevWord.getPrevWordLength();
|
||||
int newPrevWordStartIndex = inputCommitPoint;
|
||||
int charCount = 0;
|
||||
// Find new word start index
|
||||
for (int i = 0; i < prevWordLenOfTop; ++i) {
|
||||
const int c = mDicNodeState.mDicNodeStatePrevWord.getPrevWordCodePointAt(i);
|
||||
// TODO: Check other separators.
|
||||
if (c != KEYCODE_SPACE && c != KEYCODE_SINGLE_QUOTE) {
|
||||
if (charCount == inputCommitPoint) {
|
||||
newPrevWordStartIndex = i;
|
||||
break;
|
||||
}
|
||||
++charCount;
|
||||
}
|
||||
}
|
||||
if (!mDicNodeState.mDicNodeStatePrevWord.startsWith(
|
||||
&topNode->mDicNodeState.mDicNodeStatePrevWord, newPrevWordStartIndex - 1)) {
|
||||
// Node mismatch.
|
||||
return false;
|
||||
}
|
||||
mDicNodeState.mDicNodeStateInput.truncate(inputCommitPoint);
|
||||
mDicNodeState.mDicNodeStatePrevWord.truncate(newPrevWordStartIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
void outputResult(int *dest) const {
|
||||
const uint16_t prevWordLength = mDicNodeState.mDicNodeStatePrevWord.getPrevWordLength();
|
||||
const uint16_t currentDepth = getNodeCodePointCount();
|
||||
|
|
|
@ -28,37 +28,4 @@ const int DicNodesCache::LARGE_PRIORITY_QUEUE_CAPACITY = 310;
|
|||
// Capacity for reducing memory footprint.
|
||||
const int DicNodesCache::SMALL_PRIORITY_QUEUE_CAPACITY = 100;
|
||||
|
||||
/**
|
||||
* Truncates all of the dicNodes so that they start at the given commit point.
|
||||
* Only called for multi-word typing input.
|
||||
*/
|
||||
DicNode *DicNodesCache::setCommitPoint(int commitPoint) {
|
||||
std::list<DicNode> dicNodesList;
|
||||
while (mCachedDicNodesForContinuousSuggestion->getSize() > 0) {
|
||||
DicNode dicNode;
|
||||
mCachedDicNodesForContinuousSuggestion->copyPop(&dicNode);
|
||||
dicNodesList.push_front(dicNode);
|
||||
}
|
||||
|
||||
// Get the starting words of the top scoring dicNode (last dicNode popped from priority queue)
|
||||
// up to the commit point. These words have already been committed to the text view.
|
||||
DicNode *topDicNode = &dicNodesList.front();
|
||||
DicNode topDicNodeCopy;
|
||||
DicNodeUtils::initByCopy(topDicNode, &topDicNodeCopy);
|
||||
|
||||
// Keep only those dicNodes that match the same starting words.
|
||||
std::list<DicNode>::iterator iter;
|
||||
for (iter = dicNodesList.begin(); iter != dicNodesList.end(); iter++) {
|
||||
DicNode *dicNode = &*iter;
|
||||
if (dicNode->truncateNode(&topDicNodeCopy, commitPoint)) {
|
||||
mCachedDicNodesForContinuousSuggestion->copyPush(dicNode);
|
||||
} else {
|
||||
// Top dicNode should be reprocessed.
|
||||
ASSERT(dicNode != topDicNode);
|
||||
DicNode::managedDelete(dicNode);
|
||||
}
|
||||
}
|
||||
mInputIndex -= commitPoint;
|
||||
return topDicNode;
|
||||
}
|
||||
} // namespace latinime
|
||||
|
|
|
@ -76,8 +76,6 @@ class DicNodesCache {
|
|||
moveNodesAndReturnReusableEmptyQueue(mNextActiveDicNodes, &mActiveDicNodes);
|
||||
}
|
||||
|
||||
DicNode *setCommitPoint(int commitPoint);
|
||||
|
||||
int activeSize() const { return mActiveDicNodes->getSize(); }
|
||||
int terminalSize() const { return mTerminalDicNodes->getSize(); }
|
||||
bool isLookAheadCorrectionInputIndex(const int inputIndex) const {
|
||||
|
|
|
@ -27,11 +27,6 @@ class DicNodeStateInput {
|
|||
DicNodeStateInput() {}
|
||||
~DicNodeStateInput() {}
|
||||
|
||||
// TODO: Merge into DicNodeStatePrevWord::truncate
|
||||
void truncate(const int commitPoint) {
|
||||
mInputIndex[0] -= commitPoint;
|
||||
}
|
||||
|
||||
void init() {
|
||||
for (int i = 0; i < MAX_POINTER_COUNT_G; i++) {
|
||||
// TODO: The initial value for mInputIndex should be -1?
|
||||
|
|
|
@ -70,18 +70,6 @@ class DicNodeStatePrevWord {
|
|||
mSecondWordFirstInputIndex = prevWordSecondWordFirstInputIndex;
|
||||
}
|
||||
|
||||
void truncate(const int offset) {
|
||||
// TODO: memmove
|
||||
if (mPrevWordLength < offset) {
|
||||
memset(mPrevWord, 0, sizeof(mPrevWord));
|
||||
mPrevWordLength = 0;
|
||||
return;
|
||||
}
|
||||
const int newPrevWordLength = mPrevWordLength - offset;
|
||||
memmove(mPrevWord, &mPrevWord[offset], newPrevWordLength * sizeof(mPrevWord[0]));
|
||||
mPrevWordLength = newPrevWordLength;
|
||||
}
|
||||
|
||||
void setSecondWordFirstInputIndex(const int inputIndex) {
|
||||
mSecondWordFirstInputIndex = inputIndex;
|
||||
}
|
||||
|
@ -111,18 +99,6 @@ class DicNodeStatePrevWord {
|
|||
return mPrevWord[id];
|
||||
}
|
||||
|
||||
bool startsWith(const DicNodeStatePrevWord *const prefix, const int prefixLen) const {
|
||||
if (prefixLen > mPrevWordLength) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < prefixLen; ++i) {
|
||||
if (mPrevWord[i] != prefix->mPrevWord[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const int *getPrevWordBuf() const {
|
||||
return mPrevWord;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ Dictionary::Dictionary(JNIEnv *env, DictionaryStructureWithBufferPolicy::Structu
|
|||
|
||||
int Dictionary::getSuggestions(ProximityInfo *proximityInfo, DicTraverseSession *traverseSession,
|
||||
int *xcoordinates, int *ycoordinates, int *times, int *pointerIds, int *inputCodePoints,
|
||||
int inputSize, int *prevWordCodePoints, int prevWordLength, int commitPoint,
|
||||
int inputSize, int *prevWordCodePoints, int prevWordLength,
|
||||
const SuggestOptions *const suggestOptions, int *outWords, int *outputScores,
|
||||
int *spaceIndices, int *outputTypes, int *outputAutoCommitFirstWordConfidence) const {
|
||||
TimeKeeper::setCurrentTime();
|
||||
|
@ -54,7 +54,7 @@ int Dictionary::getSuggestions(ProximityInfo *proximityInfo, DicTraverseSession
|
|||
DicTraverseSession::initSessionInstance(
|
||||
traverseSession, this, prevWordCodePoints, prevWordLength, suggestOptions);
|
||||
result = mGestureSuggest->getSuggestions(proximityInfo, traverseSession, xcoordinates,
|
||||
ycoordinates, times, pointerIds, inputCodePoints, inputSize, commitPoint, outWords,
|
||||
ycoordinates, times, pointerIds, inputCodePoints, inputSize, outWords,
|
||||
outputScores, spaceIndices, outputTypes, outputAutoCommitFirstWordConfidence);
|
||||
if (DEBUG_DICT) {
|
||||
DUMP_RESULT(outWords, outputScores);
|
||||
|
@ -64,7 +64,7 @@ int Dictionary::getSuggestions(ProximityInfo *proximityInfo, DicTraverseSession
|
|||
DicTraverseSession::initSessionInstance(
|
||||
traverseSession, this, prevWordCodePoints, prevWordLength, suggestOptions);
|
||||
result = mTypingSuggest->getSuggestions(proximityInfo, traverseSession, xcoordinates,
|
||||
ycoordinates, times, pointerIds, inputCodePoints, inputSize, commitPoint,
|
||||
ycoordinates, times, pointerIds, inputCodePoints, inputSize,
|
||||
outWords, outputScores, spaceIndices, outputTypes,
|
||||
outputAutoCommitFirstWordConfidence);
|
||||
if (DEBUG_DICT) {
|
||||
|
|
|
@ -64,7 +64,7 @@ class Dictionary {
|
|||
|
||||
int getSuggestions(ProximityInfo *proximityInfo, DicTraverseSession *traverseSession,
|
||||
int *xcoordinates, int *ycoordinates, int *times, int *pointerIds, int *inputCodePoints,
|
||||
int inputSize, int *prevWordCodePoints, int prevWordLength, int commitPoint,
|
||||
int inputSize, int *prevWordCodePoints, int prevWordLength,
|
||||
const SuggestOptions *const suggestOptions, int *outWords, int *outputScores,
|
||||
int *spaceIndices, int *outputTypes, int *outputAutoCommitFirstWordConfidence) const;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ const int Suggest::MIN_CONTINUOUS_SUGGESTION_INPUT_SIZE = 2;
|
|||
*/
|
||||
int Suggest::getSuggestions(ProximityInfo *pInfo, void *traverseSession,
|
||||
int *inputXs, int *inputYs, int *times, int *pointerIds, int *inputCodePoints,
|
||||
int inputSize, int commitPoint, int *outWords, int *outputScores, int *outputIndices,
|
||||
int inputSize, int *outWords, int *outputScores, int *outputIndices,
|
||||
int *outputTypes, int *outputAutoCommitFirstWordConfidence) const {
|
||||
PROF_OPEN;
|
||||
PROF_START(0);
|
||||
|
@ -54,7 +54,7 @@ int Suggest::getSuggestions(ProximityInfo *pInfo, void *traverseSession,
|
|||
pointerIds, maxSpatialDistance, TRAVERSAL->getMaxPointerCount());
|
||||
// TODO: Add the way to evaluate cache
|
||||
|
||||
initializeSearch(tSession, commitPoint);
|
||||
initializeSearch(tSession);
|
||||
PROF_END(0);
|
||||
PROF_START(1);
|
||||
|
||||
|
@ -77,27 +77,15 @@ int Suggest::getSuggestions(ProximityInfo *pInfo, void *traverseSession,
|
|||
* Initializes the search at the root of the lexicon trie. Note that when possible the search will
|
||||
* continue suggestion from where it left off during the last call.
|
||||
*/
|
||||
void Suggest::initializeSearch(DicTraverseSession *traverseSession, int commitPoint) const {
|
||||
void Suggest::initializeSearch(DicTraverseSession *traverseSession) const {
|
||||
if (!traverseSession->getProximityInfoState(0)->isUsed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Never auto partial commit for now.
|
||||
commitPoint = 0;
|
||||
|
||||
if (traverseSession->getInputSize() > MIN_CONTINUOUS_SUGGESTION_INPUT_SIZE
|
||||
&& traverseSession->isContinuousSuggestionPossible()) {
|
||||
if (commitPoint == 0) {
|
||||
// Continue suggestion
|
||||
traverseSession->getDicTraverseCache()->continueSearch();
|
||||
} else {
|
||||
// Continue suggestion after partial commit.
|
||||
DicNode *topDicNode =
|
||||
traverseSession->getDicTraverseCache()->setCommitPoint(commitPoint);
|
||||
traverseSession->setPrevWordPtNodePos(topDicNode->getPrevWordPtNodePos());
|
||||
traverseSession->getDicTraverseCache()->continueSearch();
|
||||
traverseSession->setPartiallyCommited();
|
||||
}
|
||||
} else {
|
||||
// Restart recognition at the root.
|
||||
traverseSession->resetCache(TRAVERSAL->getMaxCacheSize(traverseSession->getInputSize()),
|
||||
|
|
|
@ -47,15 +47,15 @@ class Suggest : public SuggestInterface {
|
|||
WEIGHTING(suggestPolicy ? suggestPolicy->getWeighting() : nullptr) {}
|
||||
AK_FORCE_INLINE virtual ~Suggest() {}
|
||||
int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs,
|
||||
int *times, int *pointerIds, int *inputCodePoints, int inputSize, int commitPoint,
|
||||
int *outWords, int *outputScores, int *outputIndices, int *outputTypes,
|
||||
int *times, int *pointerIds, int *inputCodePoints, int inputSize, int *outWords,
|
||||
int *outputScores, int *outputIndices, int *outputTypes,
|
||||
int *outputAutoCommitFirstWordConfidence) const;
|
||||
|
||||
private:
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(Suggest);
|
||||
void createNextWordDicNode(DicTraverseSession *traverseSession, DicNode *dicNode,
|
||||
const bool spaceSubstitution) const;
|
||||
void initializeSearch(DicTraverseSession *traverseSession, int commitPoint) const;
|
||||
void initializeSearch(DicTraverseSession *traverseSession) const;
|
||||
void expandCurrentDicNodes(DicTraverseSession *traverseSession) const;
|
||||
void processTerminalDicNode(DicTraverseSession *traverseSession, DicNode *dicNode) const;
|
||||
void processExpandedDicNode(DicTraverseSession *traverseSession, DicNode *dicNode) const;
|
||||
|
|
|
@ -27,8 +27,8 @@ class SuggestInterface {
|
|||
public:
|
||||
virtual int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs,
|
||||
int *inputYs, int *times, int *pointerIds, int *inputCodePoints, int inputSize,
|
||||
int commitPoint, int *outWords, int *outputScores, int *outputIndices,
|
||||
int *outputTypes, int *outputAutoCommitFirstWordConfidence) const = 0;
|
||||
int *outWords, int *outputScores, int *outputIndices, int *outputTypes,
|
||||
int *outputAutoCommitFirstWordConfidence) const = 0;
|
||||
SuggestInterface() {}
|
||||
virtual ~SuggestInterface() {}
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue