Repo // walkedNodes -> walkedAnchors.
This commit is contained in:
parent
067ceebf71
commit
465d0a9845
|
@ -196,7 +196,7 @@ class KeyHandler {
|
|||
// // 令半衰記憶模組觀測給定的 trigram。
|
||||
// // 這個過程會讓半衰引擎根據當前上下文生成 trigram 索引鍵。
|
||||
// currentUOM.observe(
|
||||
// walkedNodes: walkedAnchors, cursorIndex: cursorIndex, candidate: value,
|
||||
// walkedAnchors: walkedAnchors, cursorIndex: cursorIndex, candidate: value,
|
||||
// timestamp: NSDate().timeIntervalSince1970
|
||||
// )
|
||||
// }
|
||||
|
@ -268,7 +268,7 @@ class KeyHandler {
|
|||
mgrPrefs.useSCPCTypingMode
|
||||
? ""
|
||||
: currentUOM.suggest(
|
||||
walkedNodes: walkedAnchors, cursorIndex: compositorCursorIndex,
|
||||
walkedAnchors: walkedAnchors, cursorIndex: compositorCursorIndex,
|
||||
timestamp: NSDate().timeIntervalSince1970
|
||||
)
|
||||
|
||||
|
|
|
@ -78,12 +78,12 @@ extension vChewing {
|
|||
}
|
||||
|
||||
public func observe(
|
||||
walkedNodes: [Megrez.NodeAnchor],
|
||||
walkedAnchors: [Megrez.NodeAnchor],
|
||||
cursorIndex: Int,
|
||||
candidate: String,
|
||||
timestamp: Double
|
||||
) {
|
||||
let key = convertKeyFrom(walkedNodes: walkedNodes, cursorIndex: cursorIndex)
|
||||
let key = convertKeyFrom(walkedAnchors: walkedAnchors, cursorIndex: cursorIndex)
|
||||
|
||||
guard mutLRUMap[key] != nil else {
|
||||
let observation: Observation = .init()
|
||||
|
@ -108,11 +108,11 @@ extension vChewing {
|
|||
}
|
||||
|
||||
public func suggest(
|
||||
walkedNodes: [Megrez.NodeAnchor],
|
||||
walkedAnchors: [Megrez.NodeAnchor],
|
||||
cursorIndex: Int,
|
||||
timestamp: Double
|
||||
) -> String {
|
||||
let key = convertKeyFrom(walkedNodes: walkedNodes, cursorIndex: cursorIndex)
|
||||
let key = convertKeyFrom(walkedAnchors: walkedAnchors, cursorIndex: cursorIndex)
|
||||
guard let koPair = mutLRUMap[key] else {
|
||||
IME.prtDebugIntel("UOM: mutLRUMap[key] is nil, throwing blank suggestion for key: \(key).")
|
||||
return ""
|
||||
|
@ -161,12 +161,12 @@ extension vChewing {
|
|||
}
|
||||
|
||||
func convertKeyFrom(
|
||||
walkedNodes: [Megrez.NodeAnchor], cursorIndex: Int
|
||||
walkedAnchors: [Megrez.NodeAnchor], cursorIndex: Int
|
||||
) -> String {
|
||||
let arrEndingPunctuation = [",", "。", "!", "?", "」", "』", "”", "’"]
|
||||
var arrNodes: [Megrez.NodeAnchor] = []
|
||||
var intLength = 0
|
||||
for theNodeAnchor in walkedNodes {
|
||||
for theNodeAnchor in walkedAnchors {
|
||||
arrNodes.append(theNodeAnchor)
|
||||
intLength += theNodeAnchor.spanningLength
|
||||
if intLength >= cursorIndex {
|
||||
|
|
Loading…
Reference in New Issue