am fd02ec10: Always consider corrections of intentional omissions (e.g., apostrophe)

* commit 'fd02ec10f0a0374096e88fa30a0e126d6ff11c72':
  Always consider corrections of intentional omissions (e.g., apostrophe)
This commit is contained in:
Tom Ouyang 2013-04-25 21:19:03 -07:00 committed by Android Git Automerger
commit 17fce9e345
3 changed files with 12 additions and 4 deletions

View file

@ -28,7 +28,8 @@ class Traversal {
virtual int getMaxPointerCount() const = 0; virtual int getMaxPointerCount() const = 0;
virtual bool allowsErrorCorrections(const DicNode *const dicNode) const = 0; virtual bool allowsErrorCorrections(const DicNode *const dicNode) const = 0;
virtual bool isOmission(const DicTraverseSession *const traverseSession, virtual bool isOmission(const DicTraverseSession *const traverseSession,
const DicNode *const dicNode, const DicNode *const childDicNode) const = 0; const DicNode *const dicNode, const DicNode *const childDicNode,
const bool allowsErrorCorrections) const = 0;
virtual bool isSpaceSubstitutionTerminal(const DicTraverseSession *const traverseSession, virtual bool isSpaceSubstitutionTerminal(const DicTraverseSession *const traverseSession,
const DicNode *const dicNode) const = 0; const DicNode *const dicNode) const = 0;
virtual bool isSpaceOmissionTerminal(const DicTraverseSession *const traverseSession, virtual bool isSpaceOmissionTerminal(const DicTraverseSession *const traverseSession,

View file

@ -296,8 +296,8 @@ void Suggest::expandCurrentDicNodes(DicTraverseSession *traverseSession) const {
correctionDicNode.advanceDigraphIndex(); correctionDicNode.advanceDigraphIndex();
processDicNodeAsDigraph(traverseSession, &correctionDicNode); processDicNodeAsDigraph(traverseSession, &correctionDicNode);
} }
if (allowsErrorCorrections if (TRAVERSAL->isOmission(traverseSession, &dicNode, childDicNode,
&& TRAVERSAL->isOmission(traverseSession, &dicNode, childDicNode)) { allowsErrorCorrections)) {
// TODO: (Gesture) Change weight between omission and substitution errors // TODO: (Gesture) Change weight between omission and substitution errors
// TODO: (Gesture) Terminal node should not be handled as omission // TODO: (Gesture) Terminal node should not be handled as omission
correctionDicNode.initByCopy(childDicNode); correctionDicNode.initByCopy(childDicNode);

View file

@ -43,10 +43,17 @@ class TypingTraversal : public Traversal {
} }
AK_FORCE_INLINE bool isOmission(const DicTraverseSession *const traverseSession, AK_FORCE_INLINE bool isOmission(const DicTraverseSession *const traverseSession,
const DicNode *const dicNode, const DicNode *const childDicNode) const { const DicNode *const dicNode, const DicNode *const childDicNode,
const bool allowsErrorCorrections) const {
if (!CORRECT_OMISSION) { if (!CORRECT_OMISSION) {
return false; return false;
} }
// Note: Always consider intentional omissions (like apostrophes) since they are common.
const bool canConsiderOmission =
allowsErrorCorrections || childDicNode->canBeIntentionalOmission();
if (!canConsiderOmission) {
return false;
}
const int inputSize = traverseSession->getInputSize(); const int inputSize = traverseSession->getInputSize();
// TODO: Don't refer to isCompletion? // TODO: Don't refer to isCompletion?
if (dicNode->isCompletion(inputSize)) { if (dicNode->isCompletion(inputSize)) {