Skip to content

Commit

Permalink
Fix malfunctioned cnvHanyuPinyinToPhona(). (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShikiSuen authored Jul 19, 2022
1 parent 649890d commit 37bfb9e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sources/Tekkon/TekkonSyllableComposer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -893,14 +893,14 @@ public struct Tekkon {
/// 該函式用來將漢語拼音轉為注音。
/// - Parameter target: 要轉換的漢語拼音內容,要求必須帶有 12345 數字標調。
/// - Returns: 轉換結果。
static func cnvPinyinToPhonabet(target: String) -> String {
static func cnvHanyuPinyinToPhona(target: String) -> String {
if target.contains("_") { return target }
var result = target
for key in Tekkon.mapHanyuPinyin.keys {
for key in Tekkon.mapHanyuPinyin.keys.sorted(by: { $0.count > $1.count }) {
guard let value = Tekkon.mapHanyuPinyin[key] else { continue }
result = result.replacingOccurrences(of: key, with: value)
}
for key in Tekkon.mapArayuruPinyinIntonation.keys {
for key in Tekkon.mapArayuruPinyinIntonation.keys.sorted(by: { $0.count > $1.count }) {
guard let value = Tekkon.mapArayuruPinyinIntonation[key] else { continue }
result = result.replacingOccurrences(of: key, with: value)
}
Expand Down
1 change: 1 addition & 0 deletions Tests/TekkonTests/TekkonTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ final class TekkonTests: XCTestCase {
// Testing tool functions
XCTAssertEqual(Tekkon.restoreToneOneInZhuyinKey(target: "ㄉㄧㄠ"), "ㄉㄧㄠ1")
XCTAssertEqual(Tekkon.cnvZhuyinChainToTextbookReading(target: "ㄊㄧㄥ-ㄓㄜ˙"), "ㄊㄧㄥ-˙ㄓㄜ")
XCTAssertEqual(Tekkon.cnvHanyuPinyinToPhona(target: "jing3-gao4"), "ㄐㄧㄥˇ-ㄍㄠˋ")
}

func testHanyuinyinKeyReceivingAndCompositions() throws {
Expand Down

0 comments on commit 37bfb9e

Please sign in to comment.