From 4c7ed0dc7b1b3ad87c74859b2e1ee3246acb47f0 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 19 Jul 2022 19:05:06 +0800 Subject: [PATCH] LMCoreEX // Use new Tekkon functions to handle key conversions. --- .../LangModelRelated/SubLMs/lmCoreEX.swift | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/Source/Modules/LangModelRelated/SubLMs/lmCoreEX.swift b/Source/Modules/LangModelRelated/SubLMs/lmCoreEX.swift index 6a91e82a..eb049aea 100644 --- a/Source/Modules/LangModelRelated/SubLMs/lmCoreEX.swift +++ b/Source/Modules/LangModelRelated/SubLMs/lmCoreEX.swift @@ -91,10 +91,9 @@ extension vChewing { let neta = strData[$0].split(separator: " ") if neta.count >= 2, String(neta[0]).first != "#" { if !neta[0].isEmpty, !neta[1].isEmpty { - var theKey = shouldReverse ? String(neta[1]) : String(neta[0]) - theKey.cnvPinyinToPhonabet() + let theKey = shouldReverse ? String(neta[1]) : String(neta[0]) let theValue = $0 - rangeMap[theKey, default: []].append(theValue) + rangeMap[Tekkon.cnvHanyuPinyinToPhona(target: theKey), default: []].append(theValue) } } } @@ -192,19 +191,3 @@ 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) - } - } -}