mirror of
https://github.com/mii443/AzooKeyKanaKanjiConverter.git
synced 2025-12-03 02:58:27 +00:00
feat: support roman version of pruning
This commit is contained in:
@@ -52,9 +52,21 @@ struct TypoCorrectionGenerator {
|
||||
stablePrefix.append(contentsOf: item.string)
|
||||
case .roman2kana:
|
||||
// TODO: impl
|
||||
break loop
|
||||
var stableIndex = item.string.endIndex
|
||||
for suffix in Roman2Kana.unstableSuffixes {
|
||||
if item.string.hasSuffix(suffix) {
|
||||
stableIndex = min(stableIndex, item.string.endIndex - suffix.count)
|
||||
}
|
||||
}
|
||||
if stableIndex == item.string.endIndex {
|
||||
stablePrefix.append(contentsOf: item.string)
|
||||
} else {
|
||||
// 全体が安定でない場合は、そこでbreakする
|
||||
stablePrefix.append(contentsOf: item.string[0 ..< stableIndex])
|
||||
break loop
|
||||
}
|
||||
}
|
||||
// 安定なprefixが
|
||||
// 安定なprefixがtargetをprefixに持つ場合、このstack内のアイテムについてもunreachableであることが分かるので、除去する
|
||||
if stablePrefix.hasPrefix(target) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -10,6 +10,11 @@ import Foundation
|
||||
import SwiftUtils
|
||||
|
||||
enum Roman2Kana {
|
||||
static let unstableSuffixes: Set<[Character]> = hiraganaChanges.keys.flatMapSet { characters in
|
||||
characters.indices.map { i in
|
||||
Array(characters[...i])
|
||||
}
|
||||
}
|
||||
static let katakanaChanges: [String: String] = Dictionary(uniqueKeysWithValues: hiraganaChanges.map { (String($0.key), String($0.value).toKatakana()) })
|
||||
static let hiraganaChanges: [[Character]: [Character]] = Dictionary(uniqueKeysWithValues: [
|
||||
"a": "あ",
|
||||
|
||||
Reference in New Issue
Block a user