more cangjie improvements

This commit is contained in:
minjaesong
2021-10-28 10:32:31 +09:00
parent b15d03f882
commit 18e59ed46b
3 changed files with 14 additions and 10 deletions

View File

@@ -2,13 +2,14 @@ hi,的
hi,我 hi,我
hi,得 hi,得
ao,是 ao,是
klg,在 kg,在
od,他 od,他
mn,到 mn,到
vo,以 vo,以
yu,就 yu,就
mr,可 mr,可
of,你 of,你
op,您
ml,而 ml,而
sl,那 sl,那
hl,所 hl,所

View File

@@ -2,13 +2,14 @@ hi,的
hi,我 hi,我
hi,得 hi,得
ao,是 ao,是
klg,在 kg,在
od,他 od,他
mn,到 mn,到
vo,以 vo,以
yu,就 yu,就
mr,可 mr,可
of,你 of,你
op,您
ml,而 ml,而
sl,那 sl,那
hl,所 hl,所

View File

@@ -27,13 +27,15 @@ class IMEDictionary(private val filename: String) {
private fun loadDict() { private fun loadDict() {
val reader = FileReader(File("assets/keylayout/", filename)) val reader = FileReader(File("assets/keylayout/", filename))
reader.forEachLine { reader.forEachLine {
val (key, value) = it.split(',') if (it.contains(',')) {
if (candidates.containsKey(key)) { val (key, value) = it.split(',')
candidates[key] += ",$value" if (candidates.containsKey(key)) {
} candidates[key] += ",$value"
else { }
candidates[key] = value else {
keys.add(key) candidates[key] = value
keys.add(key)
}
} }
} }
@@ -55,7 +57,7 @@ class IMEDictionary(private val filename: String) {
var index = keys.searchForInterval(key) { it }.second var index = keys.searchForInterval(key) { it }.second
val allRelevantKeys = ArrayList<String>() // oh, oha, ohag, ohbt, ohby, ... val allRelevantKeys = ArrayList<String>() // oh, oha, ohag, ohbt, ohby, ...
for (i in 0 until 10) { for (i in 0 until 400) { // lookahead for length-first sorting, longest lookahead possible is around 300, so I'll give it 400
if (index + 1 >= keys.size) break if (index + 1 >= keys.size) break
val keysym = keys[index + i] val keysym = keys[index + i]
if (!keysym.startsWith(key)) break if (!keysym.startsWith(key)) break