diff --git a/Sources/Tekkon/Tekkon_Constants.swift b/Sources/Tekkon/Tekkon_Constants.swift index 42fbee0..0d40fe3 100644 --- a/Sources/Tekkon/Tekkon_Constants.swift +++ b/Sources/Tekkon/Tekkon_Constants.swift @@ -34,109 +34,111 @@ public enum Tekkon { allowedConsonants + allowedSemivowels + allowedVowels + allowedIntonations } - /// 原始轉換對照表資料貯存專用佇列(數字標調格式) - static let arrPhonaToHanyuPinyin: [[String]] = [ // 排序很重要。先處理最長的,再處理短的。不然會出亂子。 - [" ", "1"], ["ˊ", "2"], ["ˇ", "3"], ["ˋ", "4"], ["˙", "5"], - - ["ㄅㄧㄝ", "bie"], ["ㄅㄧㄠ", "biao"], ["ㄅㄧㄢ", "bian"], ["ㄅㄧㄣ", "bin"], ["ㄅㄧㄥ", "bing"], ["ㄆㄧㄚ", "pia"], ["ㄆㄧㄝ", "pie"], - ["ㄆㄧㄠ", "piao"], ["ㄆㄧㄢ", "pian"], ["ㄆㄧㄣ", "pin"], ["ㄆㄧㄥ", "ping"], ["ㄇㄧㄝ", "mie"], ["ㄇㄧㄠ", "miao"], ["ㄇㄧㄡ", "miu"], - ["ㄇㄧㄢ", "mian"], ["ㄇㄧㄣ", "min"], ["ㄇㄧㄥ", "ming"], ["ㄈㄧㄠ", "fiao"], ["ㄈㄨㄥ", "fong"], ["ㄉㄧㄚ", "dia"], ["ㄉㄧㄝ", "die"], - ["ㄉㄧㄠ", "diao"], ["ㄉㄧㄡ", "diu"], ["ㄉㄧㄢ", "dian"], ["ㄉㄧㄥ", "ding"], ["ㄉㄨㄛ", "duo"], ["ㄉㄨㄟ", "dui"], ["ㄉㄨㄢ", "duan"], - ["ㄉㄨㄣ", "dun"], ["ㄉㄨㄥ", "dong"], ["ㄊㄧㄝ", "tie"], ["ㄊㄧㄠ", "tiao"], ["ㄊㄧㄢ", "tian"], ["ㄊㄧㄥ", "ting"], ["ㄊㄨㄛ", "tuo"], - ["ㄊㄨㄟ", "tui"], ["ㄊㄨㄢ", "tuan"], ["ㄊㄨㄣ", "tun"], ["ㄊㄨㄥ", "tong"], ["ㄋㄧㄝ", "nie"], ["ㄋㄧㄠ", "niao"], ["ㄋㄧㄡ", "niu"], - ["ㄋㄧㄢ", "nian"], ["ㄋㄧㄣ", "nin"], ["ㄋㄧㄤ", "niang"], ["ㄋㄧㄥ", "ning"], ["ㄋㄨㄛ", "nuo"], ["ㄋㄨㄟ", "nui"], - ["ㄋㄨㄢ", "nuan"], ["ㄋㄨㄣ", "nun"], ["ㄋㄨㄥ", "nong"], ["ㄋㄩㄝ", "nve"], ["ㄌㄧㄚ", "lia"], ["ㄌㄧㄝ", "lie"], ["ㄌㄧㄠ", "liao"], - ["ㄌㄧㄡ", "liu"], ["ㄌㄧㄢ", "lian"], ["ㄌㄧㄣ", "lin"], ["ㄌㄧㄤ", "liang"], ["ㄌㄧㄥ", "ling"], ["ㄌㄨㄛ", "luo"], - ["ㄌㄨㄢ", "luan"], ["ㄌㄨㄣ", "lun"], ["ㄌㄨㄥ", "long"], ["ㄌㄩㄝ", "lve"], ["ㄌㄩㄢ", "lvan"], ["ㄍㄧㄠ", "giao"], ["ㄍㄧㄣ", "gin"], - ["ㄍㄨㄚ", "gua"], ["ㄍㄨㄛ", "guo"], ["ㄍㄨㄜ", "gue"], ["ㄍㄨㄞ", "guai"], ["ㄍㄨㄟ", "gui"], ["ㄍㄨㄢ", "guan"], ["ㄍㄨㄣ", "gun"], - ["ㄍㄨㄤ", "guang"], ["ㄍㄨㄥ", "gong"], ["ㄎㄧㄡ", "kiu"], ["ㄎㄧㄤ", "kiang"], ["ㄎㄨㄚ", "kua"], ["ㄎㄨㄛ", "kuo"], - ["ㄎㄨㄞ", "kuai"], ["ㄎㄨㄟ", "kui"], ["ㄎㄨㄢ", "kuan"], ["ㄎㄨㄣ", "kun"], ["ㄎㄨㄤ", "kuang"], ["ㄎㄨㄥ", "kong"], - ["ㄏㄨㄚ", "hua"], ["ㄏㄨㄛ", "huo"], ["ㄏㄨㄞ", "huai"], ["ㄏㄨㄟ", "hui"], ["ㄏㄨㄢ", "huan"], ["ㄏㄨㄣ", "hun"], ["ㄏㄨㄤ", "huang"], - ["ㄏㄨㄥ", "hong"], ["ㄐㄧㄚ", "jia"], ["ㄐㄧㄝ", "jie"], ["ㄐㄧㄠ", "jiao"], ["ㄐㄧㄡ", "jiu"], ["ㄐㄧㄢ", "jian"], ["ㄐㄧㄣ", "jin"], - ["ㄐㄧㄤ", "jiang"], ["ㄐㄧㄥ", "jing"], ["ㄐㄩㄝ", "jue"], ["ㄐㄩㄢ", "juan"], ["ㄐㄩㄣ", "jun"], ["ㄐㄩㄥ", "jiong"], - ["ㄑㄧㄚ", "qia"], ["ㄑㄧㄝ", "qie"], ["ㄑㄧㄠ", "qiao"], ["ㄑㄧㄡ", "qiu"], ["ㄑㄧㄢ", "qian"], ["ㄑㄧㄣ", "qin"], ["ㄑㄧㄤ", "qiang"], - ["ㄑㄧㄥ", "qing"], ["ㄑㄩㄝ", "que"], ["ㄑㄩㄢ", "quan"], ["ㄑㄩㄣ", "qun"], ["ㄑㄩㄥ", "qiong"], ["ㄒㄧㄚ", "xia"], ["ㄒㄧㄝ", "xie"], - ["ㄒㄧㄠ", "xiao"], ["ㄒㄧㄡ", "xiu"], ["ㄒㄧㄢ", "xian"], ["ㄒㄧㄣ", "xin"], ["ㄒㄧㄤ", "xiang"], ["ㄒㄧㄥ", "xing"], - ["ㄒㄩㄝ", "xue"], ["ㄒㄩㄢ", "xuan"], ["ㄒㄩㄣ", "xun"], ["ㄒㄩㄥ", "xiong"], ["ㄓㄨㄚ", "zhua"], ["ㄓㄨㄛ", "zhuo"], - ["ㄓㄨㄞ", "zhuai"], ["ㄓㄨㄟ", "zhui"], ["ㄓㄨㄢ", "zhuan"], ["ㄓㄨㄣ", "zhun"], ["ㄓㄨㄤ", "zhuang"], ["ㄓㄨㄥ", "zhong"], - ["ㄔㄨㄚ", "chua"], ["ㄔㄨㄛ", "chuo"], ["ㄔㄨㄞ", "chuai"], ["ㄔㄨㄟ", "chui"], ["ㄔㄨㄢ", "chuan"], ["ㄔㄨㄣ", "chun"], - ["ㄔㄨㄤ", "chuang"], ["ㄔㄨㄥ", "chong"], ["ㄕㄨㄚ", "shua"], ["ㄕㄨㄛ", "shuo"], ["ㄕㄨㄞ", "shuai"], ["ㄕㄨㄟ", "shui"], - ["ㄕㄨㄢ", "shuan"], ["ㄕㄨㄣ", "shun"], ["ㄕㄨㄤ", "shuang"], ["ㄖㄨㄛ", "ruo"], ["ㄖㄨㄟ", "rui"], ["ㄖㄨㄢ", "ruan"], - ["ㄖㄨㄣ", "run"], ["ㄖㄨㄥ", "rong"], ["ㄗㄨㄛ", "zuo"], ["ㄗㄨㄟ", "zui"], ["ㄗㄨㄢ", "zuan"], ["ㄗㄨㄣ", "zun"], ["ㄗㄨㄥ", "zong"], - ["ㄘㄨㄛ", "cuo"], ["ㄘㄨㄟ", "cui"], ["ㄘㄨㄢ", "cuan"], ["ㄘㄨㄣ", "cun"], ["ㄘㄨㄥ", "cong"], ["ㄙㄨㄛ", "suo"], ["ㄙㄨㄟ", "sui"], - ["ㄙㄨㄢ", "suan"], ["ㄙㄨㄣ", "sun"], ["ㄙㄨㄥ", "song"], ["ㄅㄧㄤ", "biang"], ["ㄉㄨㄤ", "duang"], - - ["ㄅㄚ", "ba"], ["ㄅㄛ", "bo"], ["ㄅㄞ", "bai"], ["ㄅㄟ", "bei"], ["ㄅㄠ", "bao"], ["ㄅㄢ", "ban"], ["ㄅㄣ", "ben"], - ["ㄅㄤ", "bang"], ["ㄅㄥ", "beng"], ["ㄅㄧ", "bi"], ["ㄅㄨ", "bu"], ["ㄆㄚ", "pa"], ["ㄆㄛ", "po"], ["ㄆㄞ", "pai"], - ["ㄆㄟ", "pei"], ["ㄆㄠ", "pao"], ["ㄆㄡ", "pou"], ["ㄆㄢ", "pan"], ["ㄆㄣ", "pen"], ["ㄆㄤ", "pang"], ["ㄆㄥ", "peng"], - ["ㄆㄧ", "pi"], ["ㄆㄨ", "pu"], ["ㄇㄚ", "ma"], ["ㄇㄛ", "mo"], ["ㄇㄜ", "me"], ["ㄇㄞ", "mai"], ["ㄇㄟ", "mei"], ["ㄇㄠ", "mao"], - ["ㄇㄡ", "mou"], ["ㄇㄢ", "man"], ["ㄇㄣ", "men"], ["ㄇㄤ", "mang"], ["ㄇㄥ", "meng"], ["ㄇㄧ", "mi"], ["ㄇㄨ", "mu"], - ["ㄈㄚ", "fa"], ["ㄈㄛ", "fo"], ["ㄈㄟ", "fei"], ["ㄈㄡ", "fou"], ["ㄈㄢ", "fan"], ["ㄈㄣ", "fen"], ["ㄈㄤ", "fang"], - ["ㄈㄥ", "feng"], ["ㄈㄨ", "fu"], ["ㄉㄚ", "da"], ["ㄉㄜ", "de"], ["ㄉㄞ", "dai"], ["ㄉㄟ", "dei"], ["ㄉㄠ", "dao"], - ["ㄉㄡ", "dou"], ["ㄉㄢ", "dan"], ["ㄉㄣ", "den"], ["ㄉㄤ", "dang"], ["ㄉㄥ", "deng"], ["ㄉㄧ", "di"], ["ㄉㄨ", "du"], - ["ㄊㄚ", "ta"], ["ㄊㄜ", "te"], ["ㄊㄞ", "tai"], ["ㄊㄠ", "tao"], ["ㄊㄡ", "tou"], ["ㄊㄢ", "tan"], ["ㄊㄤ", "tang"], - ["ㄊㄥ", "teng"], ["ㄊㄧ", "ti"], ["ㄊㄨ", "tu"], ["ㄋㄚ", "na"], ["ㄋㄜ", "ne"], ["ㄋㄞ", "nai"], ["ㄋㄟ", "nei"], - ["ㄋㄠ", "nao"], ["ㄋㄡ", "nou"], ["ㄋㄢ", "nan"], ["ㄋㄣ", "nen"], ["ㄋㄤ", "nang"], ["ㄋㄥ", "neng"], ["ㄋㄧ", "ni"], - ["ㄋㄨ", "nu"], ["ㄋㄩ", "nv"], ["ㄌㄚ", "la"], ["ㄌㄛ", "lo"], ["ㄌㄜ", "le"], ["ㄌㄞ", "lai"], ["ㄌㄟ", "lei"], ["ㄌㄠ", "lao"], - ["ㄌㄡ", "lou"], ["ㄌㄢ", "lan"], ["ㄌㄤ", "lang"], ["ㄌㄥ", "leng"], ["ㄌㄧ", "li"], ["ㄌㄨ", "lu"], ["ㄌㄩ", "lv"], - ["ㄍㄚ", "ga"], ["ㄍㄜ", "ge"], ["ㄍㄞ", "gai"], ["ㄍㄟ", "gei"], ["ㄍㄠ", "gao"], ["ㄍㄡ", "gou"], ["ㄍㄢ", "gan"], - ["ㄍㄣ", "gen"], ["ㄍㄤ", "gang"], ["ㄍㄥ", "geng"], ["ㄍㄧ", "gi"], ["ㄍㄨ", "gu"], ["ㄎㄚ", "ka"], ["ㄎㄜ", "ke"], - ["ㄎㄞ", "kai"], ["ㄎㄠ", "kao"], ["ㄎㄡ", "kou"], ["ㄎㄢ", "kan"], ["ㄎㄣ", "ken"], ["ㄎㄤ", "kang"], ["ㄎㄥ", "keng"], - ["ㄎㄨ", "ku"], ["ㄏㄚ", "ha"], ["ㄏㄜ", "he"], ["ㄏㄞ", "hai"], ["ㄏㄟ", "hei"], ["ㄏㄠ", "hao"], ["ㄏㄡ", "hou"], - ["ㄏㄢ", "han"], ["ㄏㄣ", "hen"], ["ㄏㄤ", "hang"], ["ㄏㄥ", "heng"], ["ㄏㄨ", "hu"], ["ㄐㄧ", "ji"], ["ㄐㄩ", "ju"], - ["ㄑㄧ", "qi"], ["ㄑㄩ", "qu"], ["ㄒㄧ", "xi"], ["ㄒㄩ", "xu"], ["ㄓㄚ", "zha"], ["ㄓㄜ", "zhe"], ["ㄓㄞ", "zhai"], - ["ㄓㄟ", "zhei"], ["ㄓㄠ", "zhao"], ["ㄓㄡ", "zhou"], ["ㄓㄢ", "zhan"], ["ㄓㄣ", "zhen"], ["ㄓㄤ", "zhang"], ["ㄓㄥ", "zheng"], - ["ㄓㄨ", "zhu"], ["ㄔㄚ", "cha"], ["ㄔㄜ", "che"], ["ㄔㄞ", "chai"], ["ㄔㄠ", "chao"], ["ㄔㄡ", "chou"], ["ㄔㄢ", "chan"], - ["ㄔㄣ", "chen"], ["ㄔㄤ", "chang"], ["ㄔㄥ", "cheng"], ["ㄔㄨ", "chu"], ["ㄕㄚ", "sha"], ["ㄕㄜ", "she"], ["ㄕㄞ", "shai"], - ["ㄕㄟ", "shei"], ["ㄕㄠ", "shao"], ["ㄕㄡ", "shou"], ["ㄕㄢ", "shan"], ["ㄕㄣ", "shen"], ["ㄕㄤ", "shang"], ["ㄕㄥ", "sheng"], - ["ㄕㄨ", "shu"], ["ㄖㄜ", "re"], ["ㄖㄠ", "rao"], ["ㄖㄡ", "rou"], ["ㄖㄢ", "ran"], ["ㄖㄣ", "ren"], ["ㄖㄤ", "rang"], - ["ㄖㄥ", "reng"], ["ㄖㄨ", "ru"], ["ㄗㄚ", "za"], ["ㄗㄜ", "ze"], ["ㄗㄞ", "zai"], ["ㄗㄟ", "zei"], ["ㄗㄠ", "zao"], - ["ㄗㄡ", "zou"], ["ㄗㄢ", "zan"], ["ㄗㄣ", "zen"], ["ㄗㄤ", "zang"], ["ㄗㄥ", "zeng"], ["ㄗㄨ", "zu"], ["ㄘㄚ", "ca"], - ["ㄘㄜ", "ce"], ["ㄘㄞ", "cai"], ["ㄘㄟ", "cei"], ["ㄘㄠ", "cao"], ["ㄘㄡ", "cou"], ["ㄘㄢ", "can"], ["ㄘㄣ", "cen"], - ["ㄘㄤ", "cang"], ["ㄘㄥ", "ceng"], ["ㄘㄨ", "cu"], ["ㄙㄚ", "sa"], ["ㄙㄜ", "se"], ["ㄙㄞ", "sai"], ["ㄙㄟ", "sei"], - ["ㄙㄠ", "sao"], ["ㄙㄡ", "sou"], ["ㄙㄢ", "san"], ["ㄙㄣ", "sen"], ["ㄙㄤ", "sang"], ["ㄙㄥ", "seng"], ["ㄙㄨ", "su"], - ["ㄧㄚ", "ya"], ["ㄧㄛ", "yo"], ["ㄧㄝ", "ye"], ["ㄧㄞ", "yai"], ["ㄧㄠ", "yao"], ["ㄧㄡ", "you"], ["ㄧㄢ", "yan"], - ["ㄧㄣ", "yin"], ["ㄧㄤ", "yang"], ["ㄧㄥ", "ying"], ["ㄨㄚ", "wa"], ["ㄨㄛ", "wo"], ["ㄨㄞ", "wai"], ["ㄨㄟ", "wei"], - ["ㄨㄢ", "wan"], ["ㄨㄣ", "wen"], ["ㄨㄤ", "wang"], ["ㄨㄥ", "weng"], ["ㄩㄝ", "yue"], ["ㄩㄢ", "yuan"], ["ㄩㄣ", "yun"], - ["ㄩㄥ", "yong"], - - ["ㄅ", "b"], ["ㄆ", "p"], ["ㄇ", "m"], ["ㄈ", "f"], ["ㄉ", "d"], ["ㄊ", "t"], ["ㄋ", "n"], - ["ㄌ", "l"], ["ㄍ", "g"], ["ㄎ", "k"], ["ㄏ", "h"], ["ㄐ", "j"], ["ㄑ", "q"], ["ㄒ", "x"], ["ㄓ", "zhi"], ["ㄔ", "chi"], - ["ㄕ", "shi"], ["ㄖ", "ri"], ["ㄗ", "zi"], ["ㄘ", "ci"], ["ㄙ", "si"], ["ㄚ", "a"], ["ㄛ", "o"], ["ㄜ", "e"], ["ㄝ", "eh"], - ["ㄞ", "ai"], ["ㄟ", "ei"], ["ㄠ", "ao"], ["ㄡ", "ou"], ["ㄢ", "an"], ["ㄣ", "en"], ["ㄤ", "ang"], ["ㄥ", "eng"], - ["ㄦ", "er"], ["ㄧ", "yi"], ["ㄨ", "wu"], ["ㄩ", "yu"], + /// 原始轉換對照表資料貯存專用佇列(數字標調格式)。 + /// 排序很重要。先處理最長的,再處理短的。不然會出亂子。 + static let arrPhonaToHanyuPinyin: [(String, String)] = [ + (" ", "1"), ("ˊ", "2"), ("ˇ", "3"), ("ˋ", "4"), ("˙", "5"), + + ("ㄅㄧㄝ", "bie"), ("ㄅㄧㄠ", "biao"), ("ㄅㄧㄢ", "bian"), ("ㄅㄧㄣ", "bin"), ("ㄅㄧㄥ", "bing"), ("ㄆㄧㄚ", "pia"), ("ㄆㄧㄝ", "pie"), + ("ㄆㄧㄠ", "piao"), ("ㄆㄧㄢ", "pian"), ("ㄆㄧㄣ", "pin"), ("ㄆㄧㄥ", "ping"), ("ㄇㄧㄝ", "mie"), ("ㄇㄧㄠ", "miao"), ("ㄇㄧㄡ", "miu"), + ("ㄇㄧㄢ", "mian"), ("ㄇㄧㄣ", "min"), ("ㄇㄧㄥ", "ming"), ("ㄈㄧㄠ", "fiao"), ("ㄈㄨㄥ", "fong"), ("ㄉㄧㄚ", "dia"), ("ㄉㄧㄝ", "die"), + ("ㄉㄧㄠ", "diao"), ("ㄉㄧㄡ", "diu"), ("ㄉㄧㄢ", "dian"), ("ㄉㄧㄥ", "ding"), ("ㄉㄨㄛ", "duo"), ("ㄉㄨㄟ", "dui"), ("ㄉㄨㄢ", "duan"), + ("ㄉㄨㄣ", "dun"), ("ㄉㄨㄥ", "dong"), ("ㄊㄧㄝ", "tie"), ("ㄊㄧㄠ", "tiao"), ("ㄊㄧㄢ", "tian"), ("ㄊㄧㄥ", "ting"), ("ㄊㄨㄛ", "tuo"), + ("ㄊㄨㄟ", "tui"), ("ㄊㄨㄢ", "tuan"), ("ㄊㄨㄣ", "tun"), ("ㄊㄨㄥ", "tong"), ("ㄋㄧㄝ", "nie"), ("ㄋㄧㄠ", "niao"), ("ㄋㄧㄡ", "niu"), + ("ㄋㄧㄢ", "nian"), ("ㄋㄧㄣ", "nin"), ("ㄋㄧㄤ", "niang"), ("ㄋㄧㄥ", "ning"), ("ㄋㄨㄛ", "nuo"), ("ㄋㄨㄟ", "nui"), + ("ㄋㄨㄢ", "nuan"), ("ㄋㄨㄣ", "nun"), ("ㄋㄨㄥ", "nong"), ("ㄋㄩㄝ", "nve"), ("ㄌㄧㄚ", "lia"), ("ㄌㄧㄝ", "lie"), ("ㄌㄧㄠ", "liao"), + ("ㄌㄧㄡ", "liu"), ("ㄌㄧㄢ", "lian"), ("ㄌㄧㄣ", "lin"), ("ㄌㄧㄤ", "liang"), ("ㄌㄧㄥ", "ling"), ("ㄌㄨㄛ", "luo"), + ("ㄌㄨㄢ", "luan"), ("ㄌㄨㄣ", "lun"), ("ㄌㄨㄥ", "long"), ("ㄌㄩㄝ", "lve"), ("ㄌㄩㄢ", "lvan"), ("ㄍㄧㄠ", "giao"), ("ㄍㄧㄣ", "gin"), + ("ㄍㄨㄚ", "gua"), ("ㄍㄨㄛ", "guo"), ("ㄍㄨㄜ", "gue"), ("ㄍㄨㄞ", "guai"), ("ㄍㄨㄟ", "gui"), ("ㄍㄨㄢ", "guan"), ("ㄍㄨㄣ", "gun"), + ("ㄍㄨㄤ", "guang"), ("ㄍㄨㄥ", "gong"), ("ㄎㄧㄡ", "kiu"), ("ㄎㄧㄤ", "kiang"), ("ㄎㄨㄚ", "kua"), ("ㄎㄨㄛ", "kuo"), + ("ㄎㄨㄞ", "kuai"), ("ㄎㄨㄟ", "kui"), ("ㄎㄨㄢ", "kuan"), ("ㄎㄨㄣ", "kun"), ("ㄎㄨㄤ", "kuang"), ("ㄎㄨㄥ", "kong"), + ("ㄏㄨㄚ", "hua"), ("ㄏㄨㄛ", "huo"), ("ㄏㄨㄞ", "huai"), ("ㄏㄨㄟ", "hui"), ("ㄏㄨㄢ", "huan"), ("ㄏㄨㄣ", "hun"), ("ㄏㄨㄤ", "huang"), + ("ㄏㄨㄥ", "hong"), ("ㄐㄧㄚ", "jia"), ("ㄐㄧㄝ", "jie"), ("ㄐㄧㄠ", "jiao"), ("ㄐㄧㄡ", "jiu"), ("ㄐㄧㄢ", "jian"), ("ㄐㄧㄣ", "jin"), + ("ㄐㄧㄤ", "jiang"), ("ㄐㄧㄥ", "jing"), ("ㄐㄩㄝ", "jue"), ("ㄐㄩㄢ", "juan"), ("ㄐㄩㄣ", "jun"), ("ㄐㄩㄥ", "jiong"), + ("ㄑㄧㄚ", "qia"), ("ㄑㄧㄝ", "qie"), ("ㄑㄧㄠ", "qiao"), ("ㄑㄧㄡ", "qiu"), ("ㄑㄧㄢ", "qian"), ("ㄑㄧㄣ", "qin"), ("ㄑㄧㄤ", "qiang"), + ("ㄑㄧㄥ", "qing"), ("ㄑㄩㄝ", "que"), ("ㄑㄩㄢ", "quan"), ("ㄑㄩㄣ", "qun"), ("ㄑㄩㄥ", "qiong"), ("ㄒㄧㄚ", "xia"), ("ㄒㄧㄝ", "xie"), + ("ㄒㄧㄠ", "xiao"), ("ㄒㄧㄡ", "xiu"), ("ㄒㄧㄢ", "xian"), ("ㄒㄧㄣ", "xin"), ("ㄒㄧㄤ", "xiang"), ("ㄒㄧㄥ", "xing"), + ("ㄒㄩㄝ", "xue"), ("ㄒㄩㄢ", "xuan"), ("ㄒㄩㄣ", "xun"), ("ㄒㄩㄥ", "xiong"), ("ㄓㄨㄚ", "zhua"), ("ㄓㄨㄛ", "zhuo"), + ("ㄓㄨㄞ", "zhuai"), ("ㄓㄨㄟ", "zhui"), ("ㄓㄨㄢ", "zhuan"), ("ㄓㄨㄣ", "zhun"), ("ㄓㄨㄤ", "zhuang"), ("ㄓㄨㄥ", "zhong"), + ("ㄔㄨㄚ", "chua"), ("ㄔㄨㄛ", "chuo"), ("ㄔㄨㄞ", "chuai"), ("ㄔㄨㄟ", "chui"), ("ㄔㄨㄢ", "chuan"), ("ㄔㄨㄣ", "chun"), + ("ㄔㄨㄤ", "chuang"), ("ㄔㄨㄥ", "chong"), ("ㄕㄨㄚ", "shua"), ("ㄕㄨㄛ", "shuo"), ("ㄕㄨㄞ", "shuai"), ("ㄕㄨㄟ", "shui"), + ("ㄕㄨㄢ", "shuan"), ("ㄕㄨㄣ", "shun"), ("ㄕㄨㄤ", "shuang"), ("ㄖㄨㄛ", "ruo"), ("ㄖㄨㄟ", "rui"), ("ㄖㄨㄢ", "ruan"), + ("ㄖㄨㄣ", "run"), ("ㄖㄨㄥ", "rong"), ("ㄗㄨㄛ", "zuo"), ("ㄗㄨㄟ", "zui"), ("ㄗㄨㄢ", "zuan"), ("ㄗㄨㄣ", "zun"), ("ㄗㄨㄥ", "zong"), + ("ㄘㄨㄛ", "cuo"), ("ㄘㄨㄟ", "cui"), ("ㄘㄨㄢ", "cuan"), ("ㄘㄨㄣ", "cun"), ("ㄘㄨㄥ", "cong"), ("ㄙㄨㄛ", "suo"), ("ㄙㄨㄟ", "sui"), + ("ㄙㄨㄢ", "suan"), ("ㄙㄨㄣ", "sun"), ("ㄙㄨㄥ", "song"), ("ㄅㄧㄤ", "biang"), ("ㄉㄨㄤ", "duang"), + + ("ㄅㄚ", "ba"), ("ㄅㄛ", "bo"), ("ㄅㄞ", "bai"), ("ㄅㄟ", "bei"), ("ㄅㄠ", "bao"), ("ㄅㄢ", "ban"), ("ㄅㄣ", "ben"), + ("ㄅㄤ", "bang"), ("ㄅㄥ", "beng"), ("ㄅㄧ", "bi"), ("ㄅㄨ", "bu"), ("ㄆㄚ", "pa"), ("ㄆㄛ", "po"), ("ㄆㄞ", "pai"), + ("ㄆㄟ", "pei"), ("ㄆㄠ", "pao"), ("ㄆㄡ", "pou"), ("ㄆㄢ", "pan"), ("ㄆㄣ", "pen"), ("ㄆㄤ", "pang"), ("ㄆㄥ", "peng"), + ("ㄆㄧ", "pi"), ("ㄆㄨ", "pu"), ("ㄇㄚ", "ma"), ("ㄇㄛ", "mo"), ("ㄇㄜ", "me"), ("ㄇㄞ", "mai"), ("ㄇㄟ", "mei"), ("ㄇㄠ", "mao"), + ("ㄇㄡ", "mou"), ("ㄇㄢ", "man"), ("ㄇㄣ", "men"), ("ㄇㄤ", "mang"), ("ㄇㄥ", "meng"), ("ㄇㄧ", "mi"), ("ㄇㄨ", "mu"), + ("ㄈㄚ", "fa"), ("ㄈㄛ", "fo"), ("ㄈㄟ", "fei"), ("ㄈㄡ", "fou"), ("ㄈㄢ", "fan"), ("ㄈㄣ", "fen"), ("ㄈㄤ", "fang"), + ("ㄈㄥ", "feng"), ("ㄈㄨ", "fu"), ("ㄉㄚ", "da"), ("ㄉㄜ", "de"), ("ㄉㄞ", "dai"), ("ㄉㄟ", "dei"), ("ㄉㄠ", "dao"), + ("ㄉㄡ", "dou"), ("ㄉㄢ", "dan"), ("ㄉㄣ", "den"), ("ㄉㄤ", "dang"), ("ㄉㄥ", "deng"), ("ㄉㄧ", "di"), ("ㄉㄨ", "du"), + ("ㄊㄚ", "ta"), ("ㄊㄜ", "te"), ("ㄊㄞ", "tai"), ("ㄊㄠ", "tao"), ("ㄊㄡ", "tou"), ("ㄊㄢ", "tan"), ("ㄊㄤ", "tang"), + ("ㄊㄥ", "teng"), ("ㄊㄧ", "ti"), ("ㄊㄨ", "tu"), ("ㄋㄚ", "na"), ("ㄋㄜ", "ne"), ("ㄋㄞ", "nai"), ("ㄋㄟ", "nei"), + ("ㄋㄠ", "nao"), ("ㄋㄡ", "nou"), ("ㄋㄢ", "nan"), ("ㄋㄣ", "nen"), ("ㄋㄤ", "nang"), ("ㄋㄥ", "neng"), ("ㄋㄧ", "ni"), + ("ㄋㄨ", "nu"), ("ㄋㄩ", "nv"), ("ㄌㄚ", "la"), ("ㄌㄛ", "lo"), ("ㄌㄜ", "le"), ("ㄌㄞ", "lai"), ("ㄌㄟ", "lei"), ("ㄌㄠ", "lao"), + ("ㄌㄡ", "lou"), ("ㄌㄢ", "lan"), ("ㄌㄤ", "lang"), ("ㄌㄥ", "leng"), ("ㄌㄧ", "li"), ("ㄌㄨ", "lu"), ("ㄌㄩ", "lv"), + ("ㄍㄚ", "ga"), ("ㄍㄜ", "ge"), ("ㄍㄞ", "gai"), ("ㄍㄟ", "gei"), ("ㄍㄠ", "gao"), ("ㄍㄡ", "gou"), ("ㄍㄢ", "gan"), + ("ㄍㄣ", "gen"), ("ㄍㄤ", "gang"), ("ㄍㄥ", "geng"), ("ㄍㄧ", "gi"), ("ㄍㄨ", "gu"), ("ㄎㄚ", "ka"), ("ㄎㄜ", "ke"), + ("ㄎㄞ", "kai"), ("ㄎㄠ", "kao"), ("ㄎㄡ", "kou"), ("ㄎㄢ", "kan"), ("ㄎㄣ", "ken"), ("ㄎㄤ", "kang"), ("ㄎㄥ", "keng"), + ("ㄎㄨ", "ku"), ("ㄏㄚ", "ha"), ("ㄏㄜ", "he"), ("ㄏㄞ", "hai"), ("ㄏㄟ", "hei"), ("ㄏㄠ", "hao"), ("ㄏㄡ", "hou"), + ("ㄏㄢ", "han"), ("ㄏㄣ", "hen"), ("ㄏㄤ", "hang"), ("ㄏㄥ", "heng"), ("ㄏㄨ", "hu"), ("ㄐㄧ", "ji"), ("ㄐㄩ", "ju"), + ("ㄑㄧ", "qi"), ("ㄑㄩ", "qu"), ("ㄒㄧ", "xi"), ("ㄒㄩ", "xu"), ("ㄓㄚ", "zha"), ("ㄓㄜ", "zhe"), ("ㄓㄞ", "zhai"), + ("ㄓㄟ", "zhei"), ("ㄓㄠ", "zhao"), ("ㄓㄡ", "zhou"), ("ㄓㄢ", "zhan"), ("ㄓㄣ", "zhen"), ("ㄓㄤ", "zhang"), ("ㄓㄥ", "zheng"), + ("ㄓㄨ", "zhu"), ("ㄔㄚ", "cha"), ("ㄔㄜ", "che"), ("ㄔㄞ", "chai"), ("ㄔㄠ", "chao"), ("ㄔㄡ", "chou"), ("ㄔㄢ", "chan"), + ("ㄔㄣ", "chen"), ("ㄔㄤ", "chang"), ("ㄔㄥ", "cheng"), ("ㄔㄨ", "chu"), ("ㄕㄚ", "sha"), ("ㄕㄜ", "she"), ("ㄕㄞ", "shai"), + ("ㄕㄟ", "shei"), ("ㄕㄠ", "shao"), ("ㄕㄡ", "shou"), ("ㄕㄢ", "shan"), ("ㄕㄣ", "shen"), ("ㄕㄤ", "shang"), ("ㄕㄥ", "sheng"), + ("ㄕㄨ", "shu"), ("ㄖㄜ", "re"), ("ㄖㄠ", "rao"), ("ㄖㄡ", "rou"), ("ㄖㄢ", "ran"), ("ㄖㄣ", "ren"), ("ㄖㄤ", "rang"), + ("ㄖㄥ", "reng"), ("ㄖㄨ", "ru"), ("ㄗㄚ", "za"), ("ㄗㄜ", "ze"), ("ㄗㄞ", "zai"), ("ㄗㄟ", "zei"), ("ㄗㄠ", "zao"), + ("ㄗㄡ", "zou"), ("ㄗㄢ", "zan"), ("ㄗㄣ", "zen"), ("ㄗㄤ", "zang"), ("ㄗㄥ", "zeng"), ("ㄗㄨ", "zu"), ("ㄘㄚ", "ca"), + ("ㄘㄜ", "ce"), ("ㄘㄞ", "cai"), ("ㄘㄟ", "cei"), ("ㄘㄠ", "cao"), ("ㄘㄡ", "cou"), ("ㄘㄢ", "can"), ("ㄘㄣ", "cen"), + ("ㄘㄤ", "cang"), ("ㄘㄥ", "ceng"), ("ㄘㄨ", "cu"), ("ㄙㄚ", "sa"), ("ㄙㄜ", "se"), ("ㄙㄞ", "sai"), ("ㄙㄟ", "sei"), + ("ㄙㄠ", "sao"), ("ㄙㄡ", "sou"), ("ㄙㄢ", "san"), ("ㄙㄣ", "sen"), ("ㄙㄤ", "sang"), ("ㄙㄥ", "seng"), ("ㄙㄨ", "su"), + ("ㄧㄚ", "ya"), ("ㄧㄛ", "yo"), ("ㄧㄝ", "ye"), ("ㄧㄞ", "yai"), ("ㄧㄠ", "yao"), ("ㄧㄡ", "you"), ("ㄧㄢ", "yan"), + ("ㄧㄣ", "yin"), ("ㄧㄤ", "yang"), ("ㄧㄥ", "ying"), ("ㄨㄚ", "wa"), ("ㄨㄛ", "wo"), ("ㄨㄞ", "wai"), ("ㄨㄟ", "wei"), + ("ㄨㄢ", "wan"), ("ㄨㄣ", "wen"), ("ㄨㄤ", "wang"), ("ㄨㄥ", "weng"), ("ㄩㄝ", "yue"), ("ㄩㄢ", "yuan"), ("ㄩㄣ", "yun"), + ("ㄩㄥ", "yong"), + + ("ㄅ", "b"), ("ㄆ", "p"), ("ㄇ", "m"), ("ㄈ", "f"), ("ㄉ", "d"), ("ㄊ", "t"), ("ㄋ", "n"), + ("ㄌ", "l"), ("ㄍ", "g"), ("ㄎ", "k"), ("ㄏ", "h"), ("ㄐ", "j"), ("ㄑ", "q"), ("ㄒ", "x"), ("ㄓ", "zhi"), ("ㄔ", "chi"), + ("ㄕ", "shi"), ("ㄖ", "ri"), ("ㄗ", "zi"), ("ㄘ", "ci"), ("ㄙ", "si"), ("ㄚ", "a"), ("ㄛ", "o"), ("ㄜ", "e"), ("ㄝ", "eh"), + ("ㄞ", "ai"), ("ㄟ", "ei"), ("ㄠ", "ao"), ("ㄡ", "ou"), ("ㄢ", "an"), ("ㄣ", "en"), ("ㄤ", "ang"), ("ㄥ", "eng"), + ("ㄦ", "er"), ("ㄧ", "yi"), ("ㄨ", "wu"), ("ㄩ", "yu"), ] - /// 漢語拼音韻母轉換對照表資料貯存專用佇列 - static let arrHanyuPinyinTextbookStyleConversionTable: [[String]] = [ // 排序很重要。先處理最長的,再處理短的。不然會出亂子。 - ["iang1", "iāng"], ["iang2", "iáng"], ["iang3", "iǎng"], ["iang4", "iàng"], ["iong1", "iōng"], ["iong2", "ióng"], - ["iong3", "iǒng"], ["iong4", "iòng"], ["uang1", "uāng"], ["uang2", "uáng"], ["uang3", "uǎng"], ["uang4", "uàng"], - ["uang5", "uang"], - - ["ang1", "āng"], ["ang2", "áng"], ["ang3", "ǎng"], ["ang4", "àng"], ["ang5", "ang"], ["eng1", "ēng"], - ["eng2", "éng"], ["eng3", "ěng"], ["eng4", "èng"], ["ian1", "iān"], ["ian2", "ián"], ["ian3", "iǎn"], - ["ian4", "iàn"], ["iao1", "iāo"], ["iao2", "iáo"], ["iao3", "iǎo"], ["iao4", "iào"], ["ing1", "īng"], - ["ing2", "íng"], ["ing3", "ǐng"], ["ing4", "ìng"], ["ong1", "ōng"], ["ong2", "óng"], ["ong3", "ǒng"], - ["ong4", "òng"], ["uai1", "uāi"], ["uai2", "uái"], ["uai3", "uǎi"], ["uai4", "uài"], ["uan1", "uān"], - ["uan2", "uán"], ["uan3", "uǎn"], ["uan4", "uàn"], ["van2", "üán"], ["van3", "üǎn"], - - ["ai1", "āi"], ["ai2", "ái"], ["ai3", "ǎi"], ["ai4", "ài"], ["ai5", "ai"], ["an1", "ān"], ["an2", "án"], - ["an3", "ǎn"], ["an4", "àn"], ["ao1", "āo"], ["ao2", "áo"], ["ao3", "ǎo"], ["ao4", "ào"], ["ao5", "ao"], - ["eh2", "ế"], ["eh3", "êˇ"], ["eh4", "ề"], ["eh5", "ê"], ["ei1", "ēi"], ["ei2", "éi"], ["ei3", "ěi"], - ["ei4", "èi"], ["ei5", "ei"], ["en1", "ēn"], ["en2", "én"], ["en3", "ěn"], ["en4", "èn"], ["en5", "en"], - ["er1", "ēr"], ["er2", "ér"], ["er3", "ěr"], ["er4", "èr"], ["er5", "er"], ["ia1", "iā"], ["ia2", "iá"], - ["ia3", "iǎ"], ["ia4", "ià"], ["ie1", "iē"], ["ie2", "ié"], ["ie3", "iě"], ["ie4", "iè"], ["ie5", "ie"], - ["in1", "īn"], ["in2", "ín"], ["in3", "ǐn"], ["in4", "ìn"], ["iu1", "iū"], ["iu2", "iú"], ["iu3", "iǔ"], - ["iu4", "iù"], ["ou1", "ōu"], ["ou2", "óu"], ["ou3", "ǒu"], ["ou4", "òu"], ["ou5", "ou"], ["ua1", "uā"], - ["ua2", "uá"], ["ua3", "uǎ"], ["ua4", "uà"], ["ue1", "uē"], ["ue2", "ué"], ["ue3", "uě"], ["ue4", "uè"], - ["ui1", "uī"], ["ui2", "uí"], ["ui3", "uǐ"], ["ui4", "uì"], ["un1", "ūn"], ["un2", "ún"], ["un3", "ǔn"], - ["un4", "ùn"], ["uo1", "uō"], ["uo2", "uó"], ["uo3", "uǒ"], ["uo4", "uò"], ["uo5", "uo"], ["ve1", "üē"], - ["ve3", "üě"], ["ve4", "üè"], - - ["a1", "ā"], ["a2", "á"], ["a3", "ǎ"], ["a4", "à"], ["a5", "a"], ["e1", "ē"], ["e2", "é"], ["e3", "ě"], - ["e4", "è"], ["e5", "e"], ["i1", "ī"], ["i2", "í"], ["i3", "ǐ"], ["i4", "ì"], ["i5", "i"], ["o1", "ō"], - ["o2", "ó"], ["o3", "ǒ"], ["o4", "ò"], ["o5", "o"], ["u1", "ū"], ["u2", "ú"], ["u3", "ǔ"], ["u4", "ù"], - ["v1", "ǖ"], ["v2", "ǘ"], ["v3", "ǚ"], ["v4", "ǜ"], + /// 漢語拼音韻母轉換對照表資料貯存專用佇列。 + /// 排序很重要。先處理最長的,再處理短的。不然會出亂子。 + static let arrHanyuPinyinTextbookStyleConversionTable: [(String, String)] = [ + ("iang1", "iāng"), ("iang2", "iáng"), ("iang3", "iǎng"), ("iang4", "iàng"), ("iong1", "iōng"), ("iong2", "ióng"), + ("iong3", "iǒng"), ("iong4", "iòng"), ("uang1", "uāng"), ("uang2", "uáng"), ("uang3", "uǎng"), ("uang4", "uàng"), + ("uang5", "uang"), + + ("ang1", "āng"), ("ang2", "áng"), ("ang3", "ǎng"), ("ang4", "àng"), ("ang5", "ang"), ("eng1", "ēng"), + ("eng2", "éng"), ("eng3", "ěng"), ("eng4", "èng"), ("ian1", "iān"), ("ian2", "ián"), ("ian3", "iǎn"), + ("ian4", "iàn"), ("iao1", "iāo"), ("iao2", "iáo"), ("iao3", "iǎo"), ("iao4", "iào"), ("ing1", "īng"), + ("ing2", "íng"), ("ing3", "ǐng"), ("ing4", "ìng"), ("ong1", "ōng"), ("ong2", "óng"), ("ong3", "ǒng"), + ("ong4", "òng"), ("uai1", "uāi"), ("uai2", "uái"), ("uai3", "uǎi"), ("uai4", "uài"), ("uan1", "uān"), + ("uan2", "uán"), ("uan3", "uǎn"), ("uan4", "uàn"), ("van2", "üán"), ("van3", "üǎn"), + + ("ai1", "āi"), ("ai2", "ái"), ("ai3", "ǎi"), ("ai4", "ài"), ("ai5", "ai"), ("an1", "ān"), ("an2", "án"), + ("an3", "ǎn"), ("an4", "àn"), ("ao1", "āo"), ("ao2", "áo"), ("ao3", "ǎo"), ("ao4", "ào"), ("ao5", "ao"), + ("eh2", "ế"), ("eh3", "êˇ"), ("eh4", "ề"), ("eh5", "ê"), ("ei1", "ēi"), ("ei2", "éi"), ("ei3", "ěi"), + ("ei4", "èi"), ("ei5", "ei"), ("en1", "ēn"), ("en2", "én"), ("en3", "ěn"), ("en4", "èn"), ("en5", "en"), + ("er1", "ēr"), ("er2", "ér"), ("er3", "ěr"), ("er4", "èr"), ("er5", "er"), ("ia1", "iā"), ("ia2", "iá"), + ("ia3", "iǎ"), ("ia4", "ià"), ("ie1", "iē"), ("ie2", "ié"), ("ie3", "iě"), ("ie4", "iè"), ("ie5", "ie"), + ("in1", "īn"), ("in2", "ín"), ("in3", "ǐn"), ("in4", "ìn"), ("iu1", "iū"), ("iu2", "iú"), ("iu3", "iǔ"), + ("iu4", "iù"), ("ou1", "ōu"), ("ou2", "óu"), ("ou3", "ǒu"), ("ou4", "òu"), ("ou5", "ou"), ("ua1", "uā"), + ("ua2", "uá"), ("ua3", "uǎ"), ("ua4", "uà"), ("ue1", "uē"), ("ue2", "ué"), ("ue3", "uě"), ("ue4", "uè"), + ("ui1", "uī"), ("ui2", "uí"), ("ui3", "uǐ"), ("ui4", "uì"), ("un1", "ūn"), ("un2", "ún"), ("un3", "ǔn"), + ("un4", "ùn"), ("uo1", "uō"), ("uo2", "uó"), ("uo3", "uǒ"), ("uo4", "uò"), ("uo5", "uo"), ("ve1", "üē"), + ("ve3", "üě"), ("ve4", "üè"), + + ("a1", "ā"), ("a2", "á"), ("a3", "ǎ"), ("a4", "à"), ("a5", "a"), ("e1", "ē"), ("e2", "é"), ("e3", "ě"), + ("e4", "è"), ("e5", "e"), ("i1", "ī"), ("i2", "í"), ("i3", "ǐ"), ("i4", "ì"), ("i5", "i"), ("o1", "ō"), + ("o2", "ó"), ("o3", "ǒ"), ("o4", "ò"), ("o5", "o"), ("u1", "ū"), ("u2", "ú"), ("u3", "ǔ"), ("u4", "ù"), + ("v1", "ǖ"), ("v2", "ǘ"), ("v3", "ǚ"), ("v4", "ǜ"), ] // MARK: - Maps for Keyboard-to-Pinyin parsers diff --git a/Sources/Tekkon/Tekkon_Utilities.swift b/Sources/Tekkon/Tekkon_Utilities.swift index 61b501d..a446a3c 100644 --- a/Sources/Tekkon/Tekkon_Utilities.swift +++ b/Sources/Tekkon/Tekkon_Utilities.swift @@ -15,7 +15,7 @@ public extension Tekkon { static func cnvPhonaToHanyuPinyin(targetJoined: String) -> String { var targetConverted = targetJoined for pair in arrPhonaToHanyuPinyin { - targetConverted = targetConverted.swapping(pair[0], with: pair[1]) + targetConverted = targetConverted.swapping(pair.0, with: pair.1) } return targetConverted } @@ -26,7 +26,7 @@ public extension Tekkon { static func cnvHanyuPinyinToTextbookStyle(targetJoined: String) -> String { var targetConverted = targetJoined for pair in arrHanyuPinyinTextbookStyleConversionTable { - targetConverted = targetConverted.swapping(pair[0], with: pair[1]) + targetConverted = targetConverted.swapping(pair.0, with: pair.1) } return targetConverted }