aboutsummaryrefslogtreecommitdiffstats
path: root/native/src/correction_state.h
diff options
context:
space:
mode:
Diffstat (limited to 'native/src/correction_state.h')
-rw-r--r--native/src/correction_state.h118
1 files changed, 20 insertions, 98 deletions
diff --git a/native/src/correction_state.h b/native/src/correction_state.h
index 7ea5aa37d..1fe02b853 100644
--- a/native/src/correction_state.h
+++ b/native/src/correction_state.h
@@ -23,110 +23,32 @@
namespace latinime {
-class ProximityInfo;
-
class CorrectionState {
-
public:
- typedef enum {
- TRAVERSE_ALL_ON_TERMINAL,
- TRAVERSE_ALL_NOT_ON_TERMINAL,
- UNRELATED,
- ON_TERMINAL,
- NOT_ON_TERMINAL
- } CorrectionStateType;
-
- CorrectionState(const int typedLetterMultiplier, const int fullWordMultiplier);
- void initCorrectionState(
- const ProximityInfo *pi, const int inputLength, const int maxWordLength);
- void setCorrectionParams(const int skipPos, const int excessivePos, const int transposedPos,
- const int spaceProximityPos, const int missingSpacePos);
- void checkState();
- void initProcessState(const int matchCount, const int inputIndex, const int outputIndex,
- const bool traverseAllNodes, const int diffs);
- void getProcessState(int *matchedCount, int *inputIndex, int *outputIndex,
- bool *traverseAllNodes, int *diffs);
- int getOutputIndex();
- int getInputIndex();
- bool needsToTraverseAll();
-
- virtual ~CorrectionState();
- int getSpaceProximityPos() const {
- return mSpaceProximityPos;
- }
- int getMissingSpacePos() const {
- return mMissingSpacePos;
- }
-
- int getSkipPos() const {
- return mSkipPos;
- }
-
- int getExcessivePos() const {
- return mExcessivePos;
- }
+ int mParentIndex;
+ int mMatchedCount;
+ int mChildCount;
+ int mInputIndex;
+ int mDiffs;
+ int mSiblingPos;
+ bool mTraverseAll;
- int getTransposedPos() const {
- return mTransposedPos;
+ inline void init(const int rootPos, const int childCount, const bool traverseAll) {
+ set(-1, 0, childCount, 0, 0, rootPos, traverseAll);
}
- bool needsToPrune() const;
-
- int getFreqForSplitTwoWords(const int firstFreq, const int secondFreq);
- int getFinalFreq(const int freq, unsigned short **word, int* wordLength);
-
- CorrectionStateType processCharAndCalcState(const int32_t c, const bool isTerminal);
-
- int getDiffs() const {
- return mDiffs;
- }
private:
- void charMatched();
- void incrementInputIndex();
- void incrementOutputIndex();
- void startTraverseAll();
-
- // TODO: remove
-
- void incrementDiffs() {
- ++mDiffs;
+ inline void set(const int parentIndex, const int matchedCount, const int childCount,
+ const int inputIndex, const int diffs, const int siblingPos,
+ const bool traverseAll) {
+ mParentIndex = parentIndex;
+ mMatchedCount = matchedCount;
+ mChildCount = childCount;
+ mInputIndex = inputIndex;
+ mDiffs = diffs;
+ mSiblingPos = siblingPos;
+ mTraverseAll = traverseAll;
}
-
- const int TYPED_LETTER_MULTIPLIER;
- const int FULL_WORD_MULTIPLIER;
-
- const ProximityInfo *mProximityInfo;
-
- int mMaxEditDistance;
- int mMaxDepth;
- int mInputLength;
- int mSkipPos;
- int mSkippedOutputIndex;
- int mExcessivePos;
- int mTransposedPos;
- int mSpaceProximityPos;
- int mMissingSpacePos;
-
- int mMatchedCharCount;
- int mInputIndex;
- int mOutputIndex;
- int mTerminalInputIndex;
- int mTerminalOutputIndex;
- int mDiffs;
- bool mTraverseAllNodes;
- unsigned short mWord[MAX_WORD_LENGTH_INTERNAL];
-
- inline bool isQuote(const unsigned short c);
- inline CorrectionStateType processSkipChar(const int32_t c, const bool isTerminal);
-
- class RankingAlgorithm {
- public:
- static int calculateFinalFreq(const int inputIndex, const int depth,
- const int matchCount, const int freq, const bool sameLength,
- const CorrectionState* correctionState);
- static int calcFreqForSplitTwoWords(const int firstFreq, const int secondFreq,
- const CorrectionState* correctionState);
- };
};
} // namespace latinime
-#endif // LATINIME_CORRECTION_INFO_H
+#endif // LATINIME_CORRECTION_STATE_H