KeyHander // Comment updates.
This commit is contained in:
parent
d8fd398625
commit
bbf551290c
|
@ -115,12 +115,12 @@ class KeyHandler: NSObject {
|
||||||
// MARK: - Functions dealing with Megrez.
|
// MARK: - Functions dealing with Megrez.
|
||||||
|
|
||||||
func walk() {
|
func walk() {
|
||||||
// Retrieve the most likely trellis, i.e. a Maximum Likelihood Estimation
|
// Retrieve the most likely grid, i.e. a Maximum Likelihood Estimation
|
||||||
// of the best possible Mandarin characters given the input syllables,
|
// of the best possible Mandarin characters given the input syllables,
|
||||||
// using the Viterbi algorithm implemented in the Gramambular library
|
// using the Viterbi algorithm implemented in the Megrez library
|
||||||
let walker = Megrez.Walker(grid: _builder.grid())
|
let walker = Megrez.Walker(grid: _builder.grid())
|
||||||
|
|
||||||
// the reverse walk traces the trellis from the end
|
// the reverse walk traces the grid from the end
|
||||||
let walked: [Megrez.NodeAnchor] = walker.reverseWalk(at: _builder.grid().width())
|
let walked: [Megrez.NodeAnchor] = walker.reverseWalk(at: _builder.grid().width())
|
||||||
|
|
||||||
// then we use ".reversed()" to reverse the nodes so that we get the forward-walked nodes
|
// then we use ".reversed()" to reverse the nodes so that we get the forward-walked nodes
|
||||||
|
|
|
@ -56,7 +56,7 @@ extension KeyHandler {
|
||||||
|
|
||||||
// MARK: Caps Lock processing.
|
// MARK: Caps Lock processing.
|
||||||
|
|
||||||
// If Caps Lock is ON, temporarily disable bopomofo.
|
// If Caps Lock is ON, temporarily disable phonetic reading.
|
||||||
// Note: Alphanumerical mode processing.
|
// Note: Alphanumerical mode processing.
|
||||||
if input.isBackSpace || input.isEnter || input.isAbsorbedArrowKey || input.isExtraChooseCandidateKey
|
if input.isBackSpace || input.isEnter || input.isAbsorbedArrowKey || input.isExtraChooseCandidateKey
|
||||||
|| input.isExtraChooseCandidateKeyReverse || input.isCursorForward || input.isCursorBackward
|
|| input.isExtraChooseCandidateKeyReverse || input.isCursorForward || input.isCursorBackward
|
||||||
|
@ -171,10 +171,10 @@ extension KeyHandler {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// ... and insert it into the lattice grid...
|
// ... and insert it into the grid...
|
||||||
insertReadingToBuilderAtCursor(reading: reading)
|
insertReadingToBuilderAtCursor(reading: reading)
|
||||||
|
|
||||||
// ... then walk the lattice grid...
|
// ... then walk the grid...
|
||||||
let poppedText = popOverflowComposingTextAndWalk()
|
let poppedText = popOverflowComposingTextAndWalk()
|
||||||
|
|
||||||
// ... get and tweak override model suggestion if possible...
|
// ... get and tweak override model suggestion if possible...
|
||||||
|
@ -218,7 +218,7 @@ extension KeyHandler {
|
||||||
return true // Telling the client that the key is consumed.
|
return true // Telling the client that the key is consumed.
|
||||||
}
|
}
|
||||||
|
|
||||||
// The only possibility for this to be true is that the Bopomofo reading
|
// The only possibility for this to be true is that the Phonetic reading
|
||||||
// already has a tone marker but the last key is *not* a tone marker key. An
|
// already has a tone marker but the last key is *not* a tone marker key. An
|
||||||
// example is the sequence "6u" with the Standard layout, which produces "ㄧˊ"
|
// example is the sequence "6u" with the Standard layout, which produces "ㄧˊ"
|
||||||
// but does not compose. Only sequences such as "ㄧˊ", "ˊㄧˊ", "ˊㄧˇ", or "ˊㄧ "
|
// but does not compose. Only sequences such as "ㄧˊ", "ˊㄧˊ", "ˊㄧˇ", or "ˊㄧ "
|
||||||
|
|
Loading…
Reference in New Issue