LMCoreEX // Auto-parse pinyin key to phonabet key.
This commit is contained in:
parent
5b4ca64505
commit
91eff4deb7
|
@ -91,7 +91,8 @@ extension vChewing {
|
||||||
let neta = strData[$0].split(separator: " ")
|
let neta = strData[$0].split(separator: " ")
|
||||||
if neta.count >= 2, String(neta[0]).first != "#" {
|
if neta.count >= 2, String(neta[0]).first != "#" {
|
||||||
if !neta[0].isEmpty, !neta[1].isEmpty {
|
if !neta[0].isEmpty, !neta[1].isEmpty {
|
||||||
let theKey = shouldReverse ? String(neta[1]) : String(neta[0])
|
var theKey = shouldReverse ? String(neta[1]) : String(neta[0])
|
||||||
|
theKey.cnvPinyinToPhonabet()
|
||||||
let theValue = $0
|
let theValue = $0
|
||||||
rangeMap[theKey, default: []].append(theValue)
|
rangeMap[theKey, default: []].append(theValue)
|
||||||
}
|
}
|
||||||
|
@ -191,3 +192,19 @@ extension String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - 拼音轉注音
|
||||||
|
|
||||||
|
extension String {
|
||||||
|
fileprivate mutating func cnvPinyinToPhonabet() {
|
||||||
|
if contains("_") { return }
|
||||||
|
for key in Tekkon.mapHanyuPinyin.keys {
|
||||||
|
guard let value = Tekkon.mapHanyuPinyin[key] else { continue }
|
||||||
|
self = replacingOccurrences(of: key, with: value)
|
||||||
|
}
|
||||||
|
for key in Tekkon.mapArayuruPinyinIntonation.keys {
|
||||||
|
guard let value = Tekkon.mapArayuruPinyinIntonation[key] else { continue }
|
||||||
|
self = replacingOccurrences(of: key, with: value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue