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

Example: "thts" -> "that's"

Bug: 8721815
Change-Id: I8c1efbf651d2569ba3600516cc7447d46bf30fa4
main
Tom Ouyang 2013-04-25 11:59:31 -07:00
parent df3ca0420b
commit fd02ec10f0
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)) {