am 9ee90955: Move methods for scoring from Traversal to Scoring.
* commit '9ee90955287d616158ad4cf099c4772f58c16942': Move methods for scoring from Traversal to Scoring.main
commit
b8f7aa23ba
|
@ -43,6 +43,9 @@ class Scoring {
|
||||||
const int doubleLetterTerminalIndex,
|
const int doubleLetterTerminalIndex,
|
||||||
const DoubleLetterLevel doubleLetterLevel) const = 0;
|
const DoubleLetterLevel doubleLetterLevel) const = 0;
|
||||||
virtual bool doesAutoCorrectValidWord() const = 0;
|
virtual bool doesAutoCorrectValidWord() const = 0;
|
||||||
|
virtual bool autoCorrectsToMultiWordSuggestionIfTop() const = 0;
|
||||||
|
virtual bool sameAsTyped(const DicTraverseSession *const traverseSession,
|
||||||
|
const DicNode *const dicNode) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Scoring() {}
|
Scoring() {}
|
||||||
|
|
|
@ -41,11 +41,8 @@ class Traversal {
|
||||||
const DicNode *const dicNode) const = 0;
|
const DicNode *const dicNode) const = 0;
|
||||||
virtual ProximityType getProximityType(const DicTraverseSession *const traverseSession,
|
virtual ProximityType getProximityType(const DicTraverseSession *const traverseSession,
|
||||||
const DicNode *const dicNode, const DicNode *const childDicNode) const = 0;
|
const DicNode *const dicNode, const DicNode *const childDicNode) const = 0;
|
||||||
virtual bool sameAsTyped(const DicTraverseSession *const traverseSession,
|
|
||||||
const DicNode *const dicNode) const = 0;
|
|
||||||
virtual bool needsToTraverseAllUserInput() const = 0;
|
virtual bool needsToTraverseAllUserInput() const = 0;
|
||||||
virtual float getMaxSpatialDistance() const = 0;
|
virtual float getMaxSpatialDistance() const = 0;
|
||||||
virtual bool autoCorrectsToMultiWordSuggestionIfTop() const = 0;
|
|
||||||
virtual int getDefaultExpandDicNodeSize() const = 0;
|
virtual int getDefaultExpandDicNodeSize() const = 0;
|
||||||
virtual int getMaxCacheSize(const int inputSize) const = 0;
|
virtual int getMaxCacheSize(const int inputSize) const = 0;
|
||||||
virtual bool isPossibleOmissionChildNode(const DicTraverseSession *const traverseSession,
|
virtual bool isPossibleOmissionChildNode(const DicTraverseSession *const traverseSession,
|
||||||
|
|
|
@ -158,7 +158,7 @@ int Suggest::outputSuggestions(DicTraverseSession *traverseSession, int *frequen
|
||||||
// traverseSession->isPartiallyCommited() always returns false because we never auto partial
|
// traverseSession->isPartiallyCommited() always returns false because we never auto partial
|
||||||
// commit for now.
|
// commit for now.
|
||||||
const bool forceCommitMultiWords = (terminalSize > 0) ?
|
const bool forceCommitMultiWords = (terminalSize > 0) ?
|
||||||
TRAVERSAL->autoCorrectsToMultiWordSuggestionIfTop()
|
SCORING->autoCorrectsToMultiWordSuggestionIfTop()
|
||||||
&& (traverseSession->isPartiallyCommited()
|
&& (traverseSession->isPartiallyCommited()
|
||||||
|| (traverseSession->getInputSize()
|
|| (traverseSession->getInputSize()
|
||||||
>= MIN_LEN_FOR_MULTI_WORD_AUTOCORRECT
|
>= MIN_LEN_FOR_MULTI_WORD_AUTOCORRECT
|
||||||
|
@ -234,7 +234,7 @@ int Suggest::outputSuggestions(DicTraverseSession *traverseSession, int *frequen
|
||||||
->getShortcutPositionOfPtNode(terminalDicNode->getPtNodePos()));
|
->getShortcutPositionOfPtNode(terminalDicNode->getPtNodePos()));
|
||||||
// Shortcut is not supported for multiple words suggestions.
|
// Shortcut is not supported for multiple words suggestions.
|
||||||
// TODO: Check shortcuts during traversal for multiple words suggestions.
|
// TODO: Check shortcuts during traversal for multiple words suggestions.
|
||||||
const bool sameAsTyped = TRAVERSAL->sameAsTyped(traverseSession, terminalDicNode);
|
const bool sameAsTyped = SCORING->sameAsTyped(traverseSession, terminalDicNode);
|
||||||
const int shortcutBaseScore = SCORING->doesAutoCorrectValidWord() ?
|
const int shortcutBaseScore = SCORING->doesAutoCorrectValidWord() ?
|
||||||
SCORING->calculateFinalScore(compoundDistance, traverseSession->getInputSize(),
|
SCORING->calculateFinalScore(compoundDistance, traverseSession->getInputSize(),
|
||||||
true /* forceCommit */) : finalScore;
|
true /* forceCommit */) : finalScore;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "suggest/core/policy/scoring.h"
|
#include "suggest/core/policy/scoring.h"
|
||||||
|
#include "suggest/core/session/dic_traverse_session.h"
|
||||||
#include "suggest/policyimpl/typing/scoring_params.h"
|
#include "suggest/policyimpl/typing/scoring_params.h"
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
@ -71,6 +72,16 @@ class TypingScoring : public Scoring {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AK_FORCE_INLINE bool autoCorrectsToMultiWordSuggestionIfTop() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
AK_FORCE_INLINE bool sameAsTyped(
|
||||||
|
const DicTraverseSession *const traverseSession, const DicNode *const dicNode) const {
|
||||||
|
return traverseSession->getProximityInfoState(0)->sameAsTyped(
|
||||||
|
dicNode->getOutputWordBuf(), dicNode->getNodeCodePointCount());
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(TypingScoring);
|
DISALLOW_COPY_AND_ASSIGN(TypingScoring);
|
||||||
static const TypingScoring sInstance;
|
static const TypingScoring sInstance;
|
||||||
|
|
|
@ -137,20 +137,10 @@ class TypingTraversal : public Traversal {
|
||||||
return ScoringParams::MAX_SPATIAL_DISTANCE;
|
return ScoringParams::MAX_SPATIAL_DISTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
AK_FORCE_INLINE bool autoCorrectsToMultiWordSuggestionIfTop() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
AK_FORCE_INLINE int getDefaultExpandDicNodeSize() const {
|
AK_FORCE_INLINE int getDefaultExpandDicNodeSize() const {
|
||||||
return DicNodeVector::DEFAULT_NODES_SIZE_FOR_OPTIMIZATION;
|
return DicNodeVector::DEFAULT_NODES_SIZE_FOR_OPTIMIZATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
AK_FORCE_INLINE bool sameAsTyped(
|
|
||||||
const DicTraverseSession *const traverseSession, const DicNode *const dicNode) const {
|
|
||||||
return traverseSession->getProximityInfoState(0)->sameAsTyped(
|
|
||||||
dicNode->getOutputWordBuf(), dicNode->getNodeCodePointCount());
|
|
||||||
}
|
|
||||||
|
|
||||||
AK_FORCE_INLINE int getMaxCacheSize(const int inputSize) const {
|
AK_FORCE_INLINE int getMaxCacheSize(const int inputSize) const {
|
||||||
return (inputSize <= 1) ? ScoringParams::MAX_CACHE_DIC_NODE_SIZE_FOR_SINGLE_POINT
|
return (inputSize <= 1) ? ScoringParams::MAX_CACHE_DIC_NODE_SIZE_FOR_SINGLE_POINT
|
||||||
: ScoringParams::MAX_CACHE_DIC_NODE_SIZE;
|
: ScoringParams::MAX_CACHE_DIC_NODE_SIZE;
|
||||||
|
|
Loading…
Reference in New Issue