KeyHandler // Documentation fix (continued).
This commit is contained in:
parent
5448d20936
commit
449ab61a1b
|
@ -244,11 +244,10 @@ class KeyHandler {
|
||||||
/// 這個過程不會傷到子陣列內部的排序。
|
/// 這個過程不會傷到子陣列內部的排序。
|
||||||
if arrAnchors.isEmpty { return arrCandidates }
|
if arrAnchors.isEmpty { return arrCandidates }
|
||||||
|
|
||||||
// sort the nodes, so that longer nodes (representing longer phrases)
|
// 讓更長的節錨排序靠前。
|
||||||
// are placed at the top of the candidate list
|
|
||||||
arrAnchors = arrAnchors.stableSort { $0.keyLength > $1.keyLength }
|
arrAnchors = arrAnchors.stableSort { $0.keyLength > $1.keyLength }
|
||||||
|
|
||||||
// then use the Swift trick to retrieve the candidates for each node at/crossing the cursor
|
// 將節錨內的候選字詞資料拓印到輸出陣列內。
|
||||||
for currentNodeAnchor in arrAnchors {
|
for currentNodeAnchor in arrAnchors {
|
||||||
if let currentNode = currentNodeAnchor.node {
|
if let currentNode = currentNodeAnchor.node {
|
||||||
for currentCandidate in currentNode.candidates {
|
for currentCandidate in currentNode.candidates {
|
||||||
|
@ -259,6 +258,7 @@ class KeyHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 決定是否根據半衰記憶模組的建議來調整候選字詞的順序。
|
||||||
if mgrPrefs.fetchSuggestionsFromUserOverrideModel, !mgrPrefs.useSCPCTypingMode, !fixOrder {
|
if mgrPrefs.fetchSuggestionsFromUserOverrideModel, !mgrPrefs.useSCPCTypingMode, !fixOrder {
|
||||||
let arrSuggestedUnigrams: [Megrez.Unigram] = fetchSuggestedCandidates().stableSort { $0.score > $1.score }
|
let arrSuggestedUnigrams: [Megrez.Unigram] = fetchSuggestedCandidates().stableSort { $0.score > $1.score }
|
||||||
let arrSuggestedCandidates: [String] = arrSuggestedUnigrams.map(\.keyValue.value)
|
let arrSuggestedCandidates: [String] = arrSuggestedUnigrams.map(\.keyValue.value)
|
||||||
|
|
|
@ -35,7 +35,7 @@ extension KeyHandler {
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - input: 輸入訊號。
|
/// - input: 輸入訊號。
|
||||||
/// - state: 給定狀態(通常為當前狀態)。
|
/// - state: 給定狀態(通常為當前狀態)。
|
||||||
/// - stateCallback: 狀態回呼,交給對應的型別內的專有函數來處理。
|
/// - stateCallback: 狀態回呼,交給對應的型別內的專有函式來處理。
|
||||||
/// - errorCallback: 錯誤回呼。
|
/// - errorCallback: 錯誤回呼。
|
||||||
/// - Returns: 告知 IMK「該按鍵是否已經被輸入法攔截處理」。
|
/// - Returns: 告知 IMK「該按鍵是否已經被輸入法攔截處理」。
|
||||||
func handleCandidate(
|
func handleCandidate(
|
||||||
|
|
|
@ -36,7 +36,7 @@ extension KeyHandler {
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - input: 輸入訊號。
|
/// - input: 輸入訊號。
|
||||||
/// - state: 給定狀態(通常為當前狀態)。
|
/// - state: 給定狀態(通常為當前狀態)。
|
||||||
/// - stateCallback: 狀態回呼,交給對應的型別內的專有函數來處理。
|
/// - stateCallback: 狀態回呼,交給對應的型別內的專有函式來處理。
|
||||||
/// - errorCallback: 錯誤回呼。
|
/// - errorCallback: 錯誤回呼。
|
||||||
/// - Returns: 告知 IMK「該按鍵是否已經被輸入法攔截處理」。
|
/// - Returns: 告知 IMK「該按鍵是否已經被輸入法攔截處理」。
|
||||||
func handle(
|
func handle(
|
||||||
|
|
Loading…
Reference in New Issue