am a10b1a88: Misc small cleanups
* commit 'a10b1a88443a16bb1b5af1af63d0ed501b25f55d': Misc small cleanupsmain
commit
b5d3f23a4c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011, The Android Open Source Project
|
* Copyright (C) 2011 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,8 +20,6 @@
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
int register_ProximityInfo(JNIEnv *env);
|
int register_ProximityInfo(JNIEnv *env);
|
||||||
|
|
||||||
} // namespace latinime
|
} // namespace latinime
|
||||||
#endif // _COM_ANDROID_INPUTMETHOD_KEYBOARD_PROXIMITYINFO_H
|
#endif // _COM_ANDROID_INPUTMETHOD_KEYBOARD_PROXIMITYINFO_H
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011, The Android Open Source Project
|
* Copyright (C) 2011 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,8 +20,6 @@
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
int register_BinaryDictionary(JNIEnv *env);
|
int register_BinaryDictionary(JNIEnv *env);
|
||||||
|
|
||||||
} // namespace latinime
|
} // namespace latinime
|
||||||
#endif // _COM_ANDROID_INPUTMETHOD_LATIN_BINARYDICTIONARY_H
|
#endif // _COM_ANDROID_INPUTMETHOD_LATIN_BINARYDICTIONARY_H
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2012, The Android Open Source Project
|
* Copyright (C) 2012 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -17,7 +17,6 @@
|
||||||
#ifndef _COM_ANDROID_INPUTMETHOD_LATIN_DICTRAVERSESESSION_H
|
#ifndef _COM_ANDROID_INPUTMETHOD_LATIN_DICTRAVERSESESSION_H
|
||||||
#define _COM_ANDROID_INPUTMETHOD_LATIN_DICTRAVERSESESSION_H
|
#define _COM_ANDROID_INPUTMETHOD_LATIN_DICTRAVERSESESSION_H
|
||||||
|
|
||||||
#include "defines.h"
|
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011, The Android Open Source Project
|
* Copyright (C) 2011 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,9 +20,7 @@
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
int registerNativeMethods(JNIEnv *env, const char *className, JNINativeMethod *methods,
|
int registerNativeMethods(JNIEnv *env, const char *className, JNINativeMethod *methods,
|
||||||
int numMethods);
|
int numMethods);
|
||||||
|
|
||||||
} // namespace latinime
|
} // namespace latinime
|
||||||
#endif // LATINIME_JNI_COMMON_H
|
#endif // LATINIME_JNI_COMMON_H
|
||||||
|
|
|
@ -71,8 +71,7 @@ void Correction::resetCorrection() {
|
||||||
mTotalTraverseCount = 0;
|
mTotalTraverseCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Correction::initCorrection(const ProximityInfo *pi, const int inputSize,
|
void Correction::initCorrection(const ProximityInfo *pi, const int inputSize, const int maxDepth) {
|
||||||
const int maxDepth) {
|
|
||||||
mProximityInfo = pi;
|
mProximityInfo = pi;
|
||||||
mInputSize = inputSize;
|
mInputSize = inputSize;
|
||||||
mMaxDepth = maxDepth;
|
mMaxDepth = maxDepth;
|
||||||
|
@ -168,8 +167,7 @@ bool Correction::initProcessState(const int outputIndex) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Correction::goDownTree(
|
int Correction::goDownTree(const int parentIndex, const int childCount, const int firstChildPos) {
|
||||||
const int parentIndex, const int childCount, const int firstChildPos) {
|
|
||||||
mCorrectionStates[mOutputIndex].mParentIndex = parentIndex;
|
mCorrectionStates[mOutputIndex].mParentIndex = parentIndex;
|
||||||
mCorrectionStates[mOutputIndex].mChildCount = childCount;
|
mCorrectionStates[mOutputIndex].mChildCount = childCount;
|
||||||
mCorrectionStates[mOutputIndex].mSiblingPos = firstChildPos;
|
mCorrectionStates[mOutputIndex].mSiblingPos = firstChildPos;
|
||||||
|
@ -532,8 +530,7 @@ inline static bool isUpperCase(unsigned short c) {
|
||||||
// RankingAlgorithm //
|
// RankingAlgorithm //
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
||||||
/* static */
|
/* static */ int Correction::RankingAlgorithm::calculateFinalProbability(const int inputIndex,
|
||||||
int Correction::RankingAlgorithm::calculateFinalProbability(const int inputIndex,
|
|
||||||
const int outputIndex, const int freq, int *editDistanceTable, const Correction *correction,
|
const int outputIndex, const int freq, int *editDistanceTable, const Correction *correction,
|
||||||
const int inputSize) {
|
const int inputSize) {
|
||||||
const int excessivePos = correction->getExcessivePos();
|
const int excessivePos = correction->getExcessivePos();
|
||||||
|
@ -794,10 +791,9 @@ int Correction::RankingAlgorithm::calculateFinalProbability(const int inputIndex
|
||||||
return finalFreq;
|
return finalFreq;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */ int Correction::RankingAlgorithm::calcFreqForSplitMultipleWords(const int *freqArray,
|
||||||
int Correction::RankingAlgorithm::calcFreqForSplitMultipleWords(
|
const int *wordLengthArray, const int wordCount, const Correction *correction,
|
||||||
const int *freqArray, const int *wordLengthArray, const int wordCount,
|
const bool isSpaceProximity, const int *word) {
|
||||||
const Correction *correction, const bool isSpaceProximity, const int *word) {
|
|
||||||
const int typedLetterMultiplier = correction->TYPED_LETTER_MULTIPLIER;
|
const int typedLetterMultiplier = correction->TYPED_LETTER_MULTIPLIER;
|
||||||
|
|
||||||
bool firstCapitalizedWordDemotion = false;
|
bool firstCapitalizedWordDemotion = false;
|
||||||
|
@ -965,8 +961,8 @@ inline static int editDistanceInternal(int *editDistanceTable, const int *before
|
||||||
return dp[li * lo - 1];
|
return dp[li * lo - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
int Correction::RankingAlgorithm::editDistance(const int *before, const int beforeLength,
|
/* static */ int Correction::RankingAlgorithm::editDistance(const int *before,
|
||||||
const int *after, const int afterLength) {
|
const int beforeLength, const int *after, const int afterLength) {
|
||||||
int table[(beforeLength + 1) * (afterLength + 1)];
|
int table[(beforeLength + 1) * (afterLength + 1)];
|
||||||
return editDistanceInternal(table, before, beforeLength, after, afterLength);
|
return editDistanceInternal(table, before, beforeLength, after, afterLength);
|
||||||
}
|
}
|
||||||
|
@ -993,9 +989,8 @@ int Correction::RankingAlgorithm::editDistance(const int *before, const int befo
|
||||||
// the result.
|
// the result.
|
||||||
// So, we can normalize original score by dividing powf(2, min(b.l(),a.l())) * 255 * 2.
|
// So, we can normalize original score by dividing powf(2, min(b.l(),a.l())) * 255 * 2.
|
||||||
|
|
||||||
/* static */
|
/* static */ float Correction::RankingAlgorithm::calcNormalizedScore(const int *before,
|
||||||
float Correction::RankingAlgorithm::calcNormalizedScore(const int *before, const int beforeLength,
|
const int beforeLength, const int *after, const int afterLength, const int score) {
|
||||||
const int *after, const int afterLength, const int score) {
|
|
||||||
if (0 == beforeLength || 0 == afterLength) {
|
if (0 == beforeLength || 0 == afterLength) {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,7 @@ class Correction {
|
||||||
// Non virtual inline destructor -- never inherit this class
|
// Non virtual inline destructor -- never inherit this class
|
||||||
~Correction() {}
|
~Correction() {}
|
||||||
void resetCorrection();
|
void resetCorrection();
|
||||||
void initCorrection(
|
void initCorrection(const ProximityInfo *pi, const int inputSize, const int maxWordLength);
|
||||||
const ProximityInfo *pi, const int inputSize, const int maxWordLength);
|
|
||||||
void initCorrectionState(const int rootPos, const int childCount, const bool traverseAll);
|
void initCorrectionState(const int rootPos, const int childCount, const bool traverseAll);
|
||||||
|
|
||||||
// TODO: remove
|
// TODO: remove
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2010, The Android Open Source Project
|
* Copyright (C) 2010 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2012, The Android Open Source Project
|
* Copyright (C) 2012 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2012, The Android Open Source Project
|
* Copyright (C) 2012 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -28,8 +28,8 @@ class SuggestInterface {
|
||||||
virtual int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs,
|
virtual int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs,
|
||||||
int *inputYs, int *times, int *pointerIds, int *codes, int inputSize, int commitPoint,
|
int *inputYs, int *times, int *pointerIds, int *codes, int inputSize, int commitPoint,
|
||||||
int *outWords, int *frequencies, int *outputIndices, int *outputTypes) const = 0;
|
int *outWords, int *frequencies, int *outputIndices, int *outputTypes) const = 0;
|
||||||
SuggestInterface() {};
|
SuggestInterface() {}
|
||||||
virtual ~SuggestInterface() {};
|
virtual ~SuggestInterface() {}
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(SuggestInterface);
|
DISALLOW_COPY_AND_ASSIGN(SuggestInterface);
|
||||||
};
|
};
|
||||||
|
|
|
@ -365,7 +365,7 @@ void UnigramDictionary::getSuggestionCandidates(const bool useFullEditDistance,
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnigramDictionary::onTerminal(const int probability,
|
void UnigramDictionary::onTerminal(const int probability,
|
||||||
const TerminalAttributes& terminalAttributes, Correction *correction,
|
const TerminalAttributes &terminalAttributes, Correction *correction,
|
||||||
WordsPriorityQueuePool *queuePool, const bool addToMasterQueue,
|
WordsPriorityQueuePool *queuePool, const bool addToMasterQueue,
|
||||||
const int currentWordIndex) const {
|
const int currentWordIndex) const {
|
||||||
const int inputIndex = correction->getInputIndex();
|
const int inputIndex = correction->getInputIndex();
|
||||||
|
@ -390,8 +390,7 @@ void UnigramDictionary::onTerminal(const int probability,
|
||||||
|
|
||||||
const int shortcutProbability = finalProbability > 0 ? finalProbability - 1 : 0;
|
const int shortcutProbability = finalProbability > 0 ? finalProbability - 1 : 0;
|
||||||
// Please note that the shortcut candidates will be added to the master queue only.
|
// Please note that the shortcut candidates will be added to the master queue only.
|
||||||
TerminalAttributes::ShortcutIterator iterator =
|
TerminalAttributes::ShortcutIterator iterator = terminalAttributes.getShortcutIterator();
|
||||||
terminalAttributes.getShortcutIterator();
|
|
||||||
while (iterator.hasNextShortcutTarget()) {
|
while (iterator.hasNextShortcutTarget()) {
|
||||||
// TODO: addWord only supports weak ordering, meaning we have no means
|
// 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.
|
// to control the order of the shortcuts relative to one another or to the word.
|
||||||
|
|
|
@ -59,12 +59,11 @@ class UnigramDictionary {
|
||||||
WordsPriorityQueuePool *queuePool) const;
|
WordsPriorityQueuePool *queuePool) const;
|
||||||
int getDigraphReplacement(const int *codes, const int i, const int codesSize,
|
int getDigraphReplacement(const int *codes, const int i, const int codesSize,
|
||||||
const digraph_t *const digraphs, const unsigned int digraphsSize) const;
|
const digraph_t *const digraphs, const unsigned int digraphsSize) const;
|
||||||
void getWordWithDigraphSuggestionsRec(ProximityInfo *proximityInfo,
|
void getWordWithDigraphSuggestionsRec(ProximityInfo *proximityInfo, const int *xcoordinates,
|
||||||
const int *xcoordinates, const int *ycoordinates, const int *codesBuffer,
|
const int *ycoordinates, const int *codesBuffer, int *xCoordinatesBuffer,
|
||||||
int *xCoordinatesBuffer, int *yCoordinatesBuffer, const int codesBufferSize,
|
int *yCoordinatesBuffer, const int codesBufferSize, const std::map<int, int> *bigramMap,
|
||||||
const std::map<int, int> *bigramMap, const uint8_t *bigramFilter,
|
const uint8_t *bigramFilter, const bool useFullEditDistance, const int *codesSrc,
|
||||||
const bool useFullEditDistance, const int *codesSrc, const int codesRemain,
|
const int codesRemain, const int currentDepth, int *codesDest, Correction *correction,
|
||||||
const int currentDepth, int *codesDest, Correction *correction,
|
|
||||||
WordsPriorityQueuePool *queuePool, const digraph_t *const digraphs,
|
WordsPriorityQueuePool *queuePool, const digraph_t *const digraphs,
|
||||||
const unsigned int digraphsSize) const;
|
const unsigned int digraphsSize) const;
|
||||||
void initSuggestions(ProximityInfo *proximityInfo, const int *xcoordinates,
|
void initSuggestions(ProximityInfo *proximityInfo, const int *xcoordinates,
|
||||||
|
@ -79,12 +78,11 @@ class UnigramDictionary {
|
||||||
const std::map<int, int> *bigramMap, const uint8_t *bigramFilter,
|
const std::map<int, int> *bigramMap, const uint8_t *bigramFilter,
|
||||||
Correction *correction, WordsPriorityQueuePool *queuePool, const bool doAutoCompletion,
|
Correction *correction, WordsPriorityQueuePool *queuePool, const bool doAutoCompletion,
|
||||||
const int maxErrors, const int currentWordIndex) const;
|
const int maxErrors, const int currentWordIndex) const;
|
||||||
void getSplitMultipleWordsSuggestions(ProximityInfo *proximityInfo,
|
void getSplitMultipleWordsSuggestions(ProximityInfo *proximityInfo, const int *xcoordinates,
|
||||||
const int *xcoordinates, const int *ycoordinates, const int *codes,
|
const int *ycoordinates, const int *codes, const bool useFullEditDistance,
|
||||||
const bool useFullEditDistance, const int inputSize,
|
const int inputSize, Correction *correction, WordsPriorityQueuePool *queuePool,
|
||||||
Correction *correction, WordsPriorityQueuePool *queuePool,
|
|
||||||
const bool hasAutoCorrectionCandidate) const;
|
const bool hasAutoCorrectionCandidate) const;
|
||||||
void onTerminal(const int freq, const TerminalAttributes& terminalAttributes,
|
void onTerminal(const int freq, const TerminalAttributes &terminalAttributes,
|
||||||
Correction *correction, WordsPriorityQueuePool *queuePool, const bool addToMasterQueue,
|
Correction *correction, WordsPriorityQueuePool *queuePool, const bool addToMasterQueue,
|
||||||
const int currentWordIndex) const;
|
const int currentWordIndex) const;
|
||||||
// Process a node by considering proximity, missing and excessive character
|
// Process a node by considering proximity, missing and excessive character
|
||||||
|
@ -96,14 +94,13 @@ class UnigramDictionary {
|
||||||
Correction *correction, int *word) const;
|
Correction *correction, int *word) const;
|
||||||
int getMostFrequentWordLikeInner(const int *const inWord, const int inputSize,
|
int getMostFrequentWordLikeInner(const int *const inWord, const int inputSize,
|
||||||
int *outWord) const;
|
int *outWord) const;
|
||||||
int getSubStringSuggestion(
|
int getSubStringSuggestion(ProximityInfo *proximityInfo, const int *xcoordinates,
|
||||||
ProximityInfo *proximityInfo, const int *xcoordinates, const int *ycoordinates,
|
const int *ycoordinates, const int *codes, const bool useFullEditDistance,
|
||||||
const int *codes, const bool useFullEditDistance, Correction *correction,
|
Correction *correction, WordsPriorityQueuePool *queuePool, const int inputSize,
|
||||||
WordsPriorityQueuePool *queuePool, const int inputSize,
|
|
||||||
const bool hasAutoCorrectionCandidate, const int currentWordIndex,
|
const bool hasAutoCorrectionCandidate, const int currentWordIndex,
|
||||||
const int inputWordStartPos, const int inputWordLength,
|
const int inputWordStartPos, const int inputWordLength, const int outputWordStartPos,
|
||||||
const int outputWordStartPos, const bool isSpaceProximity, int *freqArray,
|
const bool isSpaceProximity, int *freqArray, int *wordLengthArray, int *outputWord,
|
||||||
int *wordLengthArray, int *outputWord, int *outputWordLength) const;
|
int *outputWordLength) const;
|
||||||
void getMultiWordsSuggestionRec(ProximityInfo *proximityInfo, const int *xcoordinates,
|
void getMultiWordsSuggestionRec(ProximityInfo *proximityInfo, const int *xcoordinates,
|
||||||
const int *ycoordinates, const int *codes, const bool useFullEditDistance,
|
const int *ycoordinates, const int *codes, const bool useFullEditDistance,
|
||||||
const int inputSize, Correction *correction, WordsPriorityQueuePool *queuePool,
|
const int inputSize, Correction *correction, WordsPriorityQueuePool *queuePool,
|
||||||
|
|
|
@ -122,7 +122,7 @@ class WordsPriorityQueue {
|
||||||
AK_FORCE_INLINE float getHighestNormalizedScore(const int *before, const int beforeLength,
|
AK_FORCE_INLINE float getHighestNormalizedScore(const int *before, const int beforeLength,
|
||||||
int **outWord, int *outScore, int *outLength) {
|
int **outWord, int *outScore, int *outLength) {
|
||||||
if (!mHighestSuggestedWord) {
|
if (!mHighestSuggestedWord) {
|
||||||
return 0.0;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
return getNormalizedScore(mHighestSuggestedWord, before, beforeLength, outWord, outScore,
|
return getNormalizedScore(mHighestSuggestedWord, before, beforeLength, outWord, outScore,
|
||||||
outLength);
|
outLength);
|
||||||
|
|
Loading…
Reference in New Issue