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