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