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

* commit 'fd02ec10f0a0374096e88fa30a0e126d6ff11c72':
  Always consider corrections of intentional omissions (e.g., apostrophe)
main
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 bool allowsErrorCorrections(const DicNode *const dicNode) const = 0;
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,
const DicNode *const dicNode) const = 0;
virtual bool isSpaceOmissionTerminal(const DicTraverseSession *const traverseSession,

View File

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

View File

@ -43,10 +43,17 @@ class TypingTraversal : public Traversal {
}
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) {
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();
// TODO: Don't refer to isCompletion?
if (dicNode->isCompletion(inputSize)) {