Skip to content

v1.7.0

Choose a tag to compare

@ShikiSuen ShikiSuen released this 11 Oct 17:18

What's Changed

  • Refactor the basic data type from String to Unicode.Scalar. by @ShikiSuen in #82
  • Add Chopper and PinyinTrie. by @ShikiSuen in #83

差異總結(v1.6.0 → v1.7.0)

重大變更(可能造成不相容)

  • 公開 API 改以 Unicode.Scalar 為核心型別:
    • Tekkon.allowedConsonants / allowedSemivowels / allowedVowels / allowedIntonations / allowedPhonabets 改為 [Unicode.Scalar](原為 [String])。
    • Tekkon.PhonabetUnicode.Scalar 儲存值;新增 init(_ input: Unicode.Scalar)valuescalarValue 計算。
    • 多數內部處理與對外方法改以 Unicode.Scalar 參數(如 translatehandleETen26/…/handleAlvinLiureceiveKey 的部分多載),原以 String 傳入注音符號的路徑有所調整。
  • Tekkon.Composer 多數屬性改為 public internal(set)consonantsemivowelvowelintonationromajiBufferparser 等對外唯讀,需改用對應方法變更狀態。
  • 移除或取代舊有以 String 作為單個注音輸入的介面:改用 receiveKey(fromPhonabet: Unicode.Scalar?) 等新介面。

新功能與能力

  • 新增 ChopperPinyinTrie#83):
    • PinyinTrie:提供 chop(…) 字首切分與 deductChoppedPinyinToZhuyin(…) 由拼音切片推導注音候選,支援類似智能簡拼切分的能力。
  • 注音/拼音處理的資料流更一致,拼音模式下的簡拼切分與候選推導更容易擴充。

修正

  • 修正 deductChoppedPinyinToZhuyin() 的處理問題。
  • 修正一處並行/併發相關問題。
  • 移除未使用的 parentID

重構與維護性提升

  • 大幅重構核心型別由 StringUnicode.Scalar#82),降低字串切割與比較成本,避免多字元誤用。
  • 整理並合併 Chopper 相關 API 至單一檔案,結構更清晰。
  • 更新程式碼格式化與靜態檢查設定:移除有問題的 SwiftLint 設定、更新 SwiftFormat 設定。

授權與文件

  • 授權自 MIT-NTL 變更為 LGPL v3.0 or later,新增 CUSTOM_LGPLv3_EXCEPTION.md,README 同步更新並標明可商業雙授權選項。
  • LICENSE 檔更新,README 說明更清楚(包括開發者與多語版本註記)。

建置與環境

  • Swift Tools 版本由 5.3 提升至 5.7(Package.swift)。
  • 其他平台需求不變(macOS 10.11+)。

測試

  • 測試重構與精簡:大量舊的鍵位測試檔移除(KeyTest_*.swift),新增與整併為:
    • Tests/TekkonTests/TekkonTests_Arrangements.swift
    • Tests/TekkonTests/TekkonTests_Basic.swift
    • Tests/TekkonTests/TekkonTests_Pinyin.swift(原 BasicTests.swift 更名)
    • Tests/TestAssets_Tekkon/Tekkon_TestData.swift(集中測資)
  • 總測資結構更集中,維護成本降低。

雜項

  • 更新版權年份。
  • .editorconfig.gitignore 等輕微調整。

升級指引摘要

  • 若外部程式碼使用到公開常數陣列或依賴 String 型別的注音單元,需改以 Unicode.Scalar 處理。
  • 直接寫入 Composer 的欄位需改用對應的輸入路徑(receiveKey/receiveSequence 等),或依新唯讀規則調整。
  • 若有自建的拼音切分與注音推導,建議改用 PinyinTriechopdeductChoppedPinyinToZhuyin

Full Changelog: v1.6.0...v1.7.0