Minor improvements on automata for Korean 3set-like IMEs

This commit is contained in:
minjaesong
2021-11-16 09:29:58 +09:00
parent 9344faa878
commit bbb7a4d7be
4 changed files with 49 additions and 29 deletions

View File

@@ -454,22 +454,24 @@ return Object.freeze({"n":"신세벌식 P2","v":"one","c":"CuriousTo\uA75Bvald",
else if (2 == bufIndex && "\u11B8" == states.buf[2] && isJongseongDigraphB(s)) {
states.buf[2] = jongseongDigraphsB[s]
}
// key inputs that bufIndex collides (end compose and accept incoming char as a new char state)
// sending out assembled syllable and accepting new hangul character
else if (states.buf[bufIndex] !== undefined) {
let oldstr = bufAssemble(1)
reset()
states.buf[bufIndex] = s
// console.log(`sending bufout: 1,${oldstr} ${bufDebugStringify(states.buf)}`)
return ["1", oldstr + bufAssemble()]
return ["1", oldstr + bufAssemble(1)]
}
else {
let bufferEmpty = isBufferEmpty(states.buf)
states.buf[bufIndex] = s
// head of the word after the non-hangul
if (bufferEmpty) {
// console.log(`assem0: ${bufDebugStringify(states.buf)} -> 0,${bufAssemble()}`)
return ["0", bufAssemble()]
return ["0", bufAssemble(1)]
}
// not head of the word
else {
// console.log(`assem1: ${bufDebugStringify(states.buf)} -> 1,${bufAssemble()}`)
return ["1", bufAssemble()]
@@ -477,14 +479,16 @@ return Object.freeze({"n":"신세벌식 P2","v":"one","c":"CuriousTo\uA75Bvald",
}
// console.log(`assem-digraph: ${bufDebugStringify(states.buf)} -> 1,${bufAssemble()}`)
return ["1", bufAssemble()]
return ["1", bufAssemble(1)]
}
// sending out assembled syllable and accepting new non-hangul character
else if (isBufferNotEmpty(states.buf)) {
let oldstr = bufAssemble(1)
reset()
// console.log(`sending1 out: 1,${oldstr}${s}`)
return ["1", oldstr + s]
}
// non-hangul
else {
// console.log(`sending0 out: 0,${s}`)
return ["0", s]
@@ -512,7 +516,7 @@ return Object.freeze({"n":"신세벌식 P2","v":"one","c":"CuriousTo\uA75Bvald",
// let newbufstr = bufDebugStringify(states.buf)
// console.log(`popping assembly: ${oldbufstr} -> 1,${newbufstr}`)
return bufAssemble()
return bufAssemble(1)
},
"end":()=>{
// console.log(`end composing`)