From 7754a2992597f89b1759449c2a32f99802614019 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 21 Jun 2022 00:33:17 +0800 Subject: [PATCH] KeyHandler // Re-enable UOM. --- .../ControllerModules/KeyHandler_Core.swift | 62 +++++++++---------- .../KeyHandler_HandleInput.swift | 2 +- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Source/Modules/ControllerModules/KeyHandler_Core.swift b/Source/Modules/ControllerModules/KeyHandler_Core.swift index 1e9aae79..62319c43 100644 --- a/Source/Modules/ControllerModules/KeyHandler_Core.swift +++ b/Source/Modules/ControllerModules/KeyHandler_Core.swift @@ -170,37 +170,37 @@ class KeyHandler { func fixNode(value: String, respectCursorPushing: Bool = true) { let cursorIndex = min(actualCandidateCursorIndex + (mgrPrefs.useRearCursorMode ? 1 : 0), compositorLength) compositor.grid.fixNodeSelectedCandidate(location: cursorIndex, value: value) - // // 因半衰模組失能,故禁用之。 - // let selectedNode: Megrez.NodeAnchor = compositor.grid.fixNodeSelectedCandidate( - // location: cursorIndex, value: value - // ) - // // 不要針對逐字選字模式啟用臨時半衰記憶模型。 - // if !mgrPrefs.useSCPCTypingMode { - // // 所有讀音數與字符數不匹配的情況均不得塞入半衰記憶模組。 - // var addToUserOverrideModel = true - // if selectedNode.spanningLength != value.count { - // IME.prtDebugIntel("UOM: SpanningLength != value.count, dismissing.") - // addToUserOverrideModel = false - // } - // if addToUserOverrideModel { - // if let theNode = selectedNode.node { - // // 威注音的 SymbolLM 的 Score 是 -12,符合該條件的內容不得塞入半衰記憶模組。 - // if theNode.scoreFor(candidate: value) <= -12 { - // IME.prtDebugIntel("UOM: Score <= -12, dismissing.") - // addToUserOverrideModel = false - // } - // } - // } - // if addToUserOverrideModel { - // IME.prtDebugIntel("UOM: Start Observation.") - // // 令半衰記憶模組觀測給定的 trigram。 - // // 這個過程會讓半衰引擎根據當前上下文生成 trigram 索引鍵。 - // currentUOM.observe( - // walkedAnchors: walkedAnchors, cursorIndex: cursorIndex, candidate: value, - // timestamp: NSDate().timeIntervalSince1970 - // ) - // } - // } + // 開始讓半衰模組觀察目前的狀況。 + let selectedNode: Megrez.NodeAnchor = compositor.grid.fixNodeSelectedCandidate( + location: cursorIndex, value: value + ) + // 不要針對逐字選字模式啟用臨時半衰記憶模型。 + if !mgrPrefs.useSCPCTypingMode { + // 所有讀音數與字符數不匹配的情況均不得塞入半衰記憶模組。 + var addToUserOverrideModel = true + if selectedNode.spanningLength != value.count { + IME.prtDebugIntel("UOM: SpanningLength != value.count, dismissing.") + addToUserOverrideModel = false + } + if addToUserOverrideModel { + if let theNode = selectedNode.node { + // 威注音的 SymbolLM 的 Score 是 -12,符合該條件的內容不得塞入半衰記憶模組。 + if theNode.scoreFor(candidate: value) <= -12 { + IME.prtDebugIntel("UOM: Score <= -12, dismissing.") + addToUserOverrideModel = false + } + } + } + if addToUserOverrideModel { + IME.prtDebugIntel("UOM: Start Observation.") + // 令半衰記憶模組觀測給定的 trigram。 + // 這個過程會讓半衰引擎根據當前上下文生成 trigram 索引鍵。 + currentUOM.observe( + walkedAnchors: walkedAnchors, cursorIndex: cursorIndex, candidate: value, + timestamp: NSDate().timeIntervalSince1970 + ) + } + } walk() /// 若偏好設定內啟用了相關選項,則會在選字之後始終將游標推送至選字厚的節錨的前方。 diff --git a/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift b/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift index 00c916fb..df006cfb 100644 --- a/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift +++ b/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift @@ -195,7 +195,7 @@ extension KeyHandler { let textToCommit = popOverflowComposingTextAndWalk // 看看半衰記憶模組是否會對目前的狀態給出自動選字建議 - // dealWithOverrideModelSuggestions() // 暫時禁用,因為無法使其生效。 + dealWithOverrideModelSuggestions() // 將組字器內超出最大動態爬軌範圍的節錨都標記為「已經手動選字過」,減少之後的爬軌運算負擔。 markNodesFixedIfNecessary()