Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17fce9e3 authored by Tom Ouyang's avatar Tom Ouyang Committed by Android Git Automerger
Browse files

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

* commit 'fd02ec10':
  Always consider corrections of intentional omissions (e.g., apostrophe)
parents ba4677fe fd02ec10
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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,
+2 −2
Original line number Diff line number Diff line
@@ -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);
+8 −1
Original line number Diff line number Diff line
@@ -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)) {