KeyHandler // Simplify findHighestScore().
This commit is contained in:
parent
f0a33c08ea
commit
5a62eea6fb
|
@ -294,7 +294,7 @@ class KeyHandler {
|
||||||
compositor.grid.overrideNodeScoreForSelectedCandidate(
|
compositor.grid.overrideNodeScoreForSelectedCandidate(
|
||||||
location: min(actualCandidateCursorIndex + (mgrPrefs.useRearCursorMode ? 1 : 0), compositorLength),
|
location: min(actualCandidateCursorIndex + (mgrPrefs.useRearCursorMode ? 1 : 0), compositorLength),
|
||||||
value: overrideValue,
|
value: overrideValue,
|
||||||
overridingScore: findHighestScore(nodes: rawAnchorsOfNodes, epsilon: kEpsilon)
|
overridingScore: findHighestScore(nodeAnchors: rawAnchorsOfNodes, epsilon: kEpsilon)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
IME.prtDebugIntel("UOM: Blank suggestion retrieved, dismissing.")
|
IME.prtDebugIntel("UOM: Blank suggestion retrieved, dismissing.")
|
||||||
|
@ -306,14 +306,8 @@ class KeyHandler {
|
||||||
/// - nodes: 給定的節錨陣列。
|
/// - nodes: 給定的節錨陣列。
|
||||||
/// - epsilon: 半衰模組的衰減指數。
|
/// - epsilon: 半衰模組的衰減指數。
|
||||||
/// - Returns: 尋獲的最高權重數值。
|
/// - Returns: 尋獲的最高權重數值。
|
||||||
func findHighestScore(nodes: [Megrez.NodeAnchor], epsilon: Double) -> Double {
|
func findHighestScore(nodeAnchors: [Megrez.NodeAnchor], epsilon: Double) -> Double {
|
||||||
var highestScore: Double = 0
|
return nodeAnchors.compactMap(\.node?.highestUnigramScore).max() ?? 0 + epsilon
|
||||||
for currentAnchor in nodes {
|
|
||||||
if let theNode = currentAnchor.node {
|
|
||||||
highestScore = max(theNode.highestUnigramScore, highestScore)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return highestScore + epsilon
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Extracted methods and functions (Tekkon).
|
// MARK: - Extracted methods and functions (Tekkon).
|
||||||
|
|
Loading…
Reference in New Issue