Repo // 函數->函式。

This commit is contained in:
ShikiSuen 2022-06-18 14:47:21 +08:00
parent ece3f72ee5
commit 6d4adea6ed
13 changed files with 51 additions and 51 deletions

View File

@ -57,7 +57,7 @@ extension String {
} }
} }
// MARK: - // MARK: -
// Ref: https://stackoverflow.com/a/32581409/4162914 // Ref: https://stackoverflow.com/a/32581409/4162914
extension Float { extension Float {
@ -67,7 +67,7 @@ extension Float {
} }
} }
// MARK: - // MARK: -
// Ref: https://stackoverflow.com/a/41581695/4162914 // Ref: https://stackoverflow.com/a/41581695/4162914
precedencegroup ExponentiationPrecedence { precedencegroup ExponentiationPrecedence {

View File

@ -25,7 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
/// 調 /// 調
/// Megrez Tekkon /// Megrez Tekkon
/// composer compositor /// composer compositor
import Cocoa import Cocoa
@ -57,7 +57,7 @@ class KeyHandler {
var currentLM: vChewing.LMInstantiator = .init() // var currentLM: vChewing.LMInstantiator = .init() //
var currentUOM: vChewing.LMUserOverride = .init() // var currentUOM: vChewing.LMUserOverride = .init() //
var walkedAnchors: [Megrez.NodeAnchor] = [] // var walkedAnchors: [Megrez.NodeAnchor] = [] //
/// (ctlInputMethod)便 /// (ctlInputMethod)便
var delegate: KeyHandlerDelegate? var delegate: KeyHandlerDelegate?
/// InputMode /// InputMode
@ -111,7 +111,7 @@ class KeyHandler {
/// ///
/// Viterbi /// Viterbi
/// ///
/// ///
func walk() { func walk() {
walkedAnchors = compositor.walk() walkedAnchors = compositor.walk()
@ -153,7 +153,7 @@ class KeyHandler {
/// ///
/// - Parameter key: /// - Parameter key:
/// - Returns: /// - Returns:
/// nil /// nil
func buildAssociatePhraseArray(withKey key: String) -> [String] { func buildAssociatePhraseArray(withKey key: String) -> [String] {
var arrResult: [String] = [] var arrResult: [String] = []
if currentLM.hasAssociatedPhrasesForKey(key) { if currentLM.hasAssociatedPhrasesForKey(key) {
@ -347,7 +347,7 @@ class KeyHandler {
composer.clear() composer.clear()
} }
/// Ruby /// Ruby
/// - Parameters: /// - Parameters:
/// - target: /// - target:
/// - newSeparator: /// - newSeparator:

View File

@ -150,7 +150,7 @@ extension KeyHandler {
// inputValidityCheck() charCode UniChar // inputValidityCheck() charCode UniChar
// keyConsumedByReading // keyConsumedByReading
// composer.receiveKey() String UniChar // composer.receiveKey() String UniChar
if !skipPhoneticHandling && composer.inputValidityCheck(key: charCode) { if !skipPhoneticHandling && composer.inputValidityCheck(key: charCode) {
composer.receiveKey(fromCharCode: charCode) composer.receiveKey(fromCharCode: charCode)
keyConsumedByReading = true keyConsumedByReading = true
@ -397,7 +397,7 @@ extension KeyHandler {
} else { } else {
// commit buffer ESC // commit buffer ESC
// Enter 使 commit buffer // Enter 使 commit buffer
// bool _ = // bool _ =
_ = handleEnter(state: state, stateCallback: stateCallback, errorCallback: errorCallback) _ = handleEnter(state: state, stateCallback: stateCallback, errorCallback: errorCallback)
stateCallback(InputState.SymbolTable(node: SymbolNode.root, isTypingVertical: input.isTypingVertical)) stateCallback(InputState.SymbolTable(node: SymbolNode.root, isTypingVertical: input.isTypingVertical))
return true return true

View File

@ -24,11 +24,11 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
/// 調調 /// 調調
import Cocoa import Cocoa
// MARK: - § 調 (Functions Interact With States). // MARK: - § 調 (Functions Interact With States).
extension KeyHandler { extension KeyHandler {
// MARK: - State Building // MARK: - State Building
@ -168,11 +168,11 @@ extension KeyHandler {
/// ///
/// ///
/// buildAssociatePhraseStateWithKey /// buildAssociatePhraseStateWithKey
/// 使 /// 使
/// Core buildAssociatePhraseArray /// Core buildAssociatePhraseArray
/// String Swift /// String Swift
/// nil /// nil
/// ///
/// ///
/// - Parameters: /// - Parameters:
/// - key: /// - key:
@ -760,7 +760,7 @@ extension KeyHandler {
return true return true
} }
// //
let candidates = buildCandidate(state: state).candidates let candidates = buildCandidate(state: state).candidates
guard !candidates.isEmpty else { guard !candidates.isEmpty else {
IME.prtDebugIntel("3378A6DF") IME.prtDebugIntel("3378A6DF")
@ -796,7 +796,7 @@ extension KeyHandler {
/// 2 使 /// 2 使
/// ///
/// ///
/// 使 /// 使
/// (Shift+)Tab () /// (Shift+)Tab ()
/// Shift(+CMD)+Space Tab /// Shift(+CMD)+Space Tab
if candidates[0] == currentValue { if candidates[0] == currentValue {

View File

@ -152,7 +152,7 @@ public struct Tekkon {
ensureType() ensureType()
} }
/// ///
mutating func ensureType() { mutating func ensureType() {
if Tekkon.allowedConsonants.contains(value) { if Tekkon.allowedConsonants.contains(value) {
type = .consonant type = .consonant
@ -228,7 +228,7 @@ public struct Tekkon {
consonant.value + semivowel.value + vowel.value + intonation.value consonant.value + semivowel.value + vowel.value + intonation.value
} }
/// value / /// value /
/// 調 /// 調
/// - Parameters: /// - Parameters:
/// - isHanyuPinyin: /// - isHanyuPinyin:
@ -251,7 +251,7 @@ public struct Tekkon {
} }
} }
// macOS InputMethod Kit 使 // macOS InputMethod Kit 使
/// - Parameters: /// - Parameters:
/// - isHanyuPinyin: /// - isHanyuPinyin:
public func getInlineCompositionForIMK(isHanyuPinyin: Bool = false) -> String { public func getInlineCompositionForIMK(isHanyuPinyin: Bool = false) -> String {
@ -285,7 +285,7 @@ public struct Tekkon {
!vowel.isEmpty || !semivowel.isEmpty || !consonant.isEmpty !vowel.isEmpty || !semivowel.isEmpty || !consonant.isEmpty
} }
// MARK: // MARK:
/// @input /// @input
/// @arrange .ofDachen /// @arrange .ofDachen
@ -309,7 +309,7 @@ public struct Tekkon {
// MARK: - Public Functions // MARK: - Public Functions
/// ///
/// ///
/// parser /// parser
/// - Parameters: /// - Parameters:
@ -344,7 +344,7 @@ public struct Tekkon {
} }
/// String /// String
/// UniChar /// UniChar
/// ///
/// 調 /// 調
/// - Parameters: /// - Parameters:
@ -370,7 +370,7 @@ public struct Tekkon {
} }
/// UniChar /// UniChar
/// UniChar String /// UniChar String
/// ///
/// 調 /// 調
/// - Parameters: /// - Parameters:
@ -475,7 +475,7 @@ public struct Tekkon {
} }
} }
/// 調調 /// 調調
/// - Parameters: /// - Parameters:
/// - withNothingElse: 調 /// - withNothingElse: 調
public func hasToneMarker(withNothingElse: Bool = false) -> Bool { public func hasToneMarker(withNothingElse: Bool = false) -> Bool {
@ -494,11 +494,11 @@ public struct Tekkon {
// MARK: - Parser Processings // MARK: - Parser Processings
// //
/// String /// String
/// ///
/// ///
/// - Parameters: /// - Parameters:
/// - key: String /// - key: String
mutating func translate(key: String = "") -> String { mutating func translate(key: String = "") -> String {
@ -522,14 +522,14 @@ public struct Tekkon {
case .ofFakeSeigyou: case .ofFakeSeigyou:
return Tekkon.mapFakeSeigyou[key] ?? "" return Tekkon.mapFakeSeigyou[key] ?? ""
case .ofHanyuPinyin, .ofSecondaryPinyin, .ofYalePinyin, .ofHualuoPinyin, .ofUniversalPinyin: case .ofHanyuPinyin, .ofSecondaryPinyin, .ofYalePinyin, .ofHualuoPinyin, .ofUniversalPinyin:
break // break //
} }
return "" return ""
} }
/// ///
/// ///
/// ///
/// - Parameters: /// - Parameters:
/// - key: String /// - key: String
mutating func handleETen26(key: String = "") -> String { mutating func handleETen26(key: String = "") -> String {
@ -612,7 +612,7 @@ public struct Tekkon {
/// ///
/// ///
/// ///
/// - Parameters: /// - Parameters:
/// - key: String /// - key: String
mutating func handleHsu(key: String = "") -> String { mutating func handleHsu(key: String = "") -> String {
@ -735,7 +735,7 @@ public struct Tekkon {
/// ///
/// ///
/// ///
/// - Parameters: /// - Parameters:
/// - key: String /// - key: String
mutating func handleDachen26(key: String = "") -> String { mutating func handleDachen26(key: String = "") -> String {

View File

@ -88,7 +88,7 @@ public enum IME {
// MARK: - Initializing Language Models. // MARK: - Initializing Language Models.
static func initLangModels(userOnly: Bool) { static func initLangModels(userOnly: Bool) {
// mgrLangModel loadUserPhrases dataFolderPath // mgrLangModel loadUserPhrases dataFolderPath
// //
// //
mgrLangModel.loadUserAssociatesData() mgrLangModel.loadUserAssociatesData()

View File

@ -61,7 +61,7 @@ extension vChewing {
/// files are modified. It does not keep the reference of the data pathes but /// files are modified. It does not keep the reference of the data pathes but
/// you have to pass the paths when you ask it to load. /// you have to pass the paths when you ask it to load.
public class LMInstantiator: Megrez.LanguageModel { public class LMInstantiator: Megrez.LanguageModel {
// //
public var isPhraseReplacementEnabled = false public var isPhraseReplacementEnabled = false
public var isCNSEnabled = false public var isCNSEnabled = false
public var isSymbolEnabled = false public var isSymbolEnabled = false
@ -100,10 +100,10 @@ extension vChewing {
var lmReplacements = LMReplacments() var lmReplacements = LMReplacments()
var lmAssociates = LMAssociates() var lmAssociates = LMAssociates()
// //
override init() {} override init() {}
// 調 // 調
public var isLanguageModelLoaded: Bool { lmCore.isLoaded() } public var isLanguageModelLoaded: Bool { lmCore.isLoaded() }
public func loadLanguageModel(path: String) { public func loadLanguageModel(path: String) {

View File

@ -132,12 +132,12 @@ extension vChewing {
/// 使 strData /// 使 strData
/// ///
/// ///
/// - parameters: /// - parameters:
/// - precedingKey: /// - precedingKey:
/// - key: /// - key:
public func bigramsForKeys(precedingKey: String, key: String) -> [Megrez.Bigram] { public func bigramsForKeys(precedingKey: String, key: String) -> [Megrez.Bigram] {
// Swift // Swift
// [Megrez.Bigram]() // [Megrez.Bigram]()
precedingKey == key ? [Megrez.Bigram]() : [Megrez.Bigram]() precedingKey == key ? [Megrez.Bigram]() : [Megrez.Bigram]()
} }

View File

@ -126,12 +126,12 @@ extension vChewing {
/// 使 UTF8 /// 使 UTF8
/// ///
/// ///
/// - parameters: /// - parameters:
/// - precedingKey: /// - precedingKey:
/// - key: /// - key:
public func bigramsForKeys(precedingKey: String, key: String) -> [Megrez.Bigram] { public func bigramsForKeys(precedingKey: String, key: String) -> [Megrez.Bigram] {
// Swift // Swift
// [Megrez.Bigram]() // [Megrez.Bigram]()
precedingKey == key ? [Megrez.Bigram]() : [Megrez.Bigram]() precedingKey == key ? [Megrez.Bigram]() : [Megrez.Bigram]()
} }
@ -167,7 +167,7 @@ extension vChewing {
rangeMap[cnvPhonabetToASCII(key)] != nil rangeMap[cnvPhonabetToASCII(key)] != nil
} }
/// ///
/// ///
/// 使 plist /// 使 plist
/// ///
@ -190,7 +190,7 @@ extension vChewing {
return strOutput return strOutput
} }
/// ///
/// ///
/// ASCII /// ASCII
/// - parameters: /// - parameters:

View File

@ -29,7 +29,7 @@ import Cocoa
/// mgrLangModel /// mgrLangModel
/// mgrLangModel /// mgrLangModel
/// ///
/// mgrLangModel /// mgrLangModel
private var gLangModelCHS = vChewing.LMInstantiator() private var gLangModelCHS = vChewing.LMInstantiator()
private var gLangModelCHT = vChewing.LMInstantiator() private var gLangModelCHT = vChewing.LMInstantiator()
@ -37,7 +37,7 @@ private var gUserOverrideModelCHS = vChewing.LMUserOverride()
private var gUserOverrideModelCHT = vChewing.LMUserOverride() private var gUserOverrideModelCHT = vChewing.LMUserOverride()
enum mgrLangModel { enum mgrLangModel {
/// fileprivate /// fileprivate
public static var lmCHS: vChewing.LMInstantiator { gLangModelCHS } public static var lmCHS: vChewing.LMInstantiator { gLangModelCHS }
public static var lmCHT: vChewing.LMInstantiator { gLangModelCHT } public static var lmCHT: vChewing.LMInstantiator { gLangModelCHT }
public static var uomCHS: vChewing.LMUserOverride { gUserOverrideModelCHS } public static var uomCHS: vChewing.LMUserOverride { gUserOverrideModelCHS }
@ -295,7 +295,7 @@ enum mgrLangModel {
// The above "&" mutates the "isFolder" value to the real one received by the "folderExist". // The above "&" mutates the "isFolder" value to the real one received by the "folderExist".
// //
// //
var folderPath = folderPath // Convert the incoming constant to a variable. var folderPath = folderPath // Convert the incoming constant to a variable.
if isFolder.boolValue { if isFolder.boolValue {
folderPath?.ensureTrailingSlash() folderPath?.ensureTrailingSlash()
@ -351,7 +351,7 @@ enum mgrLangModel {
return true return true
} }
// MARK: - 使 mgrPrefs // MARK: - 使 mgrPrefs
// mgrPrefs // mgrPrefs

View File

@ -68,7 +68,7 @@ extension Megrez {
joinSeparator = separator joinSeparator = separator
} }
/// ///
public func clear() { public func clear() {
mutCursorIndex = 0 mutCursorIndex = 0
mutReadings.removeAll() mutReadings.removeAll()
@ -115,7 +115,7 @@ extension Megrez {
/// ///
/// ///
/// ///
/// ///
@discardableResult public func removeHeadReadings(count: Int) -> Bool { @discardableResult public func removeHeadReadings(count: Int) -> Bool {
let count = abs(count) // let count = abs(count) //
if count > length { if count > length {

View File

@ -24,11 +24,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
extension Megrez { extension Megrez {
/// 使 /// 使
open class LanguageModel { open class LanguageModel {
public init() {} public init() {}
// Swift // Swift
/// ///
open func unigramsFor(key: String) -> [Megrez.Unigram] { open func unigramsFor(key: String) -> [Megrez.Unigram] {

View File

@ -49,7 +49,7 @@ extension Megrez {
hasher.combine(score) hasher.combine(score)
} }
// //
public static func compareScore(a: Unigram, b: Unigram) -> Bool { public static func compareScore(a: Unigram, b: Unigram) -> Bool {
a.score > b.score a.score > b.score
} }