88155
|
1 ;;; sisheng.el --- sisheng input method for Chinese pinyin transliteration
|
|
2
|
|
3 ;; Copyright (C) 2004 Free Software Foundation, Inc.
|
|
4
|
|
5 ;; Author: Werner LEMBERG <wl@gnu.org>
|
|
6
|
|
7 ;; Keywords: multilingual, input method, Chinese, pinyin, sisheng
|
|
8
|
|
9 ;; This program is free software; you can redistribute it and/or modify
|
|
10 ;; it under the terms of the GNU General Public License as published by
|
|
11 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
12 ;; any later version.
|
|
13
|
|
14 ;; This program is distributed in the hope that it will be useful,
|
|
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 ;; GNU General Public License for more details.
|
|
18
|
|
19 ;; You should have received a copy of the GNU General Public License
|
|
20 ;; along with GNU Emacs; see the file COPYING. If not, write to
|
|
21 ;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
22 ;; Boston, MA 02110-1301, USA.
|
|
23
|
|
24 ;;; Commentary:
|
|
25
|
|
26 ;;; Code:
|
|
27
|
|
28 (require 'quail)
|
|
29
|
|
30 (defconst sisheng-regexp
|
|
31 "[��朝�笛�]\\|端�")
|
|
32
|
|
33 ;; First element is the key,
|
|
34 ;; second element is the vowel used for the input sequence,
|
|
35 ;; last four elements are the resulting tones.
|
|
36 ;;
|
|
37 (defconst sisheng-vowel-table
|
|
38 '(("�" "a" "�" "叩" "�" "�")
|
|
39 ("�" "e" "�" "辿" "�" "竪")
|
|
40 ("朝" "i" "朝" "鱈" "�" "狸")
|
|
41 ("�" "o" "�" "坦" "�" "嘆")
|
|
42 ("笛" "u" "笛" "炭" "�" "湛")
|
|
43 ("�" "v" "�" "�" "�" "�")
|
|
44 ("端�" "ve" "端�" "端辿" "端�" "端竪")))
|
|
45
|
|
46
|
|
47 ;; All possible syllables in Mandarin Chinese, presented in the first
|
|
48 ;; tone. Note that make-sisheng-rules always constructs rules for all
|
|
49 ;; four tones even if some of those tones aren't used in Mandarin.
|
|
50 ;;
|
|
51 (defconst sisheng-syllable-table
|
|
52 '("�" "�i" "�n" "�ng" "�o"
|
|
53
|
|
54 "b�" "b�i" "b�n" "b�ng" "b�o"
|
|
55 "b�i" "b�n" "b�ng"
|
|
56 "b朝" "bi�n" "bi�o" "bi�" "b朝n" "b朝ng"
|
|
57 "b�"
|
|
58 "b笛"
|
|
59
|
|
60 "c�" "c�i" "c�n" "c�ng" "c�o"
|
|
61 "c�" "c�n" "c�ng"
|
|
62 "c朝"
|
|
63 "c�ng" "c�u"
|
|
64 "c笛" "cu�n" "cu朝" "c笛n" "cu�"
|
|
65
|
|
66 "ch�" "ch�i" "ch�n" "ch�ng" "ch�o"
|
|
67 "ch�" "ch�n" "ch�ng"
|
|
68 "ch朝"
|
|
69 "ch�ng" "ch�u"
|
|
70 "ch笛" "chu�" "chu�i" "chu�n" "chu�ng" "chu朝" "ch笛n" "chu�"
|
|
71
|
|
72 "d�" "d�i" "d�n" "d�ng" "d�o"
|
|
73 "d�" "d�i" "d�n" "d�ng"
|
|
74 "d朝" "di�n" "di�o" "di�" "d朝ng" "di笛"
|
|
75 "d�ng" "d�u"
|
|
76 "d笛" "du�n" "du朝" "d笛n" "du�"
|
|
77
|
|
78 "�" "�i" "�n" "�ng" "�r"
|
|
79
|
|
80 "f�" "f�n" "f�ng"
|
|
81 "f�i" "f�n" "f�ng"
|
|
82 "fi�o"
|
|
83 "f�" "f�u"
|
|
84 "f笛"
|
|
85
|
|
86 "g�" "g�i" "g�n" "g�ng" "g�o"
|
|
87 "g�" "g�i" "g�n" "g�ng"
|
|
88 "g�ng" "g�u"
|
|
89 "g笛" "gu�" "gu�i" "gu�n" "gu�ng" "gu朝" "g笛n" "gu�"
|
|
90
|
|
91 "h�" "h�i" "h�n" "h�ng" "h�o"
|
|
92 "h�" "h�i" "h�n" "h�ng"
|
|
93 "h�ng" "h�u"
|
|
94 "h笛" "hu�" "hu�i" "hu�n" "hu�ng" "hu朝" "h笛n" "hu�"
|
|
95
|
|
96 "j朝" "ji�" "ji�n" "ji�ng" "ji�o" "ji�" "j朝n" "j朝ng" "ji�ng" "ji笛"
|
|
97 "j笛" "ju�n" "ju�" "j笛n"
|
|
98
|
|
99 "k�" "k�i" "k�n" "k�ng" "k�o"
|
|
100 "k�" "k�i" "k�n" "k�ng"
|
|
101 "k�ng" "k�u"
|
|
102 "k笛" "ku�" "ku�i" "ku�n" "ku�ng" "ku朝" "k笛n" "ku�"
|
|
103
|
|
104 "l�" "l�i" "l�n" "l�ng" "l�o"
|
|
105 "l�" "l�i" "l�ng"
|
|
106 "l朝" "li�" "li�n" "li�ng" "li�o" "li�" "l朝n" "l朝ng" "li笛"
|
|
107 "l�ng" "l�u"
|
|
108 "l笛" "lu�n" "l笛n" "lu�"
|
|
109 "l�" "l端�"
|
|
110
|
|
111 "m�" "m�i" "m�n" "m�ng" "m�o"
|
|
112 "m�" "m�i" "m�n" "m�ng"
|
|
113 "m朝" "mi�n" "mi�o" "mi�" "m朝n" "m朝ng" "mi笛"
|
|
114 "m�" "m�u"
|
|
115 "m笛"
|
|
116
|
|
117 "n�" "n�i" "n�n" "n�ng" "n�o"
|
|
118 "n�" "n�i" "n�n" "n�ng"
|
|
119 "n朝" "ni�n" "ni�ng" "ni�o" "ni�" "n朝n" "n朝ng" "ni笛"
|
|
120 "n�ng" "n�u"
|
|
121 "n笛" "nu�n" "nu�"
|
|
122 "n�" "n端�"
|
|
123
|
|
124 "�" "�u"
|
|
125
|
|
126 "p�" "p�i" "p�n" "p�ng" "p�o"
|
|
127 "p�i" "p�n" "p�ng"
|
|
128 "p朝" "pi�n" "pi�o" "pi�" "p朝n" "p朝ng"
|
|
129 "p�" "p�u"
|
|
130 "p笛"
|
|
131
|
|
132 "q朝" "qi�" "qi�n" "qi�ng" "qi�o" "qi�" "q朝n" "q朝ng" "qi�ng" "qi笛"
|
|
133 "q笛" "qu�n" "qu�" "q笛n"
|
|
134
|
|
135 "r�n" "r�ng" "r�o"
|
|
136 "r�" "r�n" "r�ng"
|
|
137 "r朝"
|
|
138 "r�ng" "r�u"
|
|
139 "r笛" "ru�" "ru�n" "ru朝" "r笛n" "ru�"
|
|
140
|
|
141 "s�" "s�i" "s�n" "s�ng" "s�o"
|
|
142 "s�" "s�n" "s�ng"
|
|
143 "s朝"
|
|
144 "s�ng" "s�u"
|
|
145 "s笛" "su�n" "su朝" "s笛n" "su�"
|
|
146
|
|
147 "sh�" "sh�i" "sh�n" "sh�ng" "sh�o"
|
|
148 "sh�" "sh�i" "sh�n" "sh�ng"
|
|
149 "sh朝"
|
|
150 "sh�u"
|
|
151 "sh笛" "shu�" "shu�i" "shu�n" "shu�ng" "shu朝" "sh笛n" "shu�"
|
|
152
|
|
153 "t�" "t�i" "t�n" "t�ng" "t�o"
|
|
154 "t�" "t�i" "t�ng"
|
|
155 "t朝" "ti�n" "ti�o" "ti�" "t朝ng"
|
|
156 "t�ng" "t�u"
|
|
157 "t笛" "tu�n" "tu朝" "t笛n" "tu�"
|
|
158
|
|
159 "w�" "w�i" "w�n" "w�ng"
|
|
160 "w�i" "w�n" "w�ng"
|
|
161 "w�"
|
|
162 "w笛"
|
|
163
|
|
164 "x朝" "xi�" "xi�n" "xi�ng" "xi�o" "xi�" "x朝n" "x朝ng" "xi�ng" "xi笛"
|
|
165 "x笛" "xu�n" "xu�" "x笛n"
|
|
166
|
|
167 "y�" "y�n" "y�ng" "y�o"
|
|
168 "y�"
|
|
169 "y朝" "y朝n" "y朝ng"
|
|
170 "y�" "y�ng" "y�u"
|
|
171 "y笛" "yu�n" "yu�" "y笛n"
|
|
172
|
|
173 "z�" "z�i" "z�n" "z�ng" "z�o"
|
|
174 "z�" "z�i" "z�n" "z�ng"
|
|
175 "z朝"
|
|
176 "z�ng" "z�u"
|
|
177 "z笛" "zu�n" "zu朝" "z笛n" "zu�"
|
|
178
|
|
179 "zh�" "zh�i" "zh�n" "zh�ng" "zh�o"
|
|
180 "zh�" "zh�i" "zh�n" "zh�ng"
|
|
181 "zh朝"
|
|
182 "zh�ng" "zh�u"
|
|
183 "zh笛" "zhu�" "zhu�i" "zhu�n" "zhu�ng" "zhu朝" "zh笛n" "zhu�"))
|
|
184
|
|
185 ;; This function converts e.g.
|
|
186 ;;
|
|
187 ;; "zhu�"
|
|
188 ;;
|
|
189 ;; into
|
|
190 ;;
|
|
191 ;; (("zhuo4" ["zhu嘆"])
|
|
192 ;; ("zhuo3" ["zhu�"])
|
|
193 ;; ("zhuo2" ["zhu坦"])
|
|
194 ;; ("zhuo1" ["zhu�"]))
|
|
195 ;;
|
|
196 (defun quail-make-sisheng-rules (syllable)
|
|
197 (let ((case-fold-search t)
|
|
198 vowel-match
|
|
199 vowel-list
|
|
200 input-vowel
|
|
201 base-key
|
|
202 key
|
|
203 value
|
|
204 key-value-list
|
|
205 (i 1))
|
|
206 (string-match sisheng-regexp syllable)
|
|
207 (setq vowel-match (downcase (match-string 0 syllable)))
|
|
208 (setq vowel-list
|
|
209 (cdr (assoc-string vowel-match sisheng-vowel-table)))
|
|
210 (setq input-vowel (car vowel-list))
|
|
211 (setq base-key (replace-match input-vowel nil nil syllable))
|
|
212 (while (<= i 4)
|
|
213 (setq key (concat base-key (number-to-string i)))
|
|
214 (setq value (vector (replace-match (nth i vowel-list) nil nil syllable)))
|
|
215 (push (list key value) key-value-list)
|
|
216 (setq i (1+ i)))
|
|
217 key-value-list))
|
|
218
|
|
219 ;; Set up sisheng input method.
|
|
220 ;;
|
|
221 (quail-define-package
|
|
222 "chinese-sisheng" ; name
|
|
223 "Chinese" ; language
|
|
224 "�" ; title
|
|
225 t ; guidance
|
|
226 "S狸sh�ng input method for p朝ny朝n transliteration of Chinese.
|
|
227
|
|
228 Examples: shuang1 -> shu�ng
|
|
229 Lv3 -> L�
|
|
230 AN4 -> �N
|
|
231
|
|
232 Use the fifth (unstressed) tone for syllables containing `端'
|
|
233 without a tone mark.
|
|
234
|
|
235 Example: nve5 -> n端e
|
|
236 " ; docstring
|
|
237 nil ; translation-keys
|
|
238 t ; forget-last-selection
|
|
239 nil ; deterministic
|
|
240 nil ; kbd-translate
|
|
241 nil ; show-layout
|
|
242 nil ; create-decode-map
|
|
243 nil ; maximum-shortest
|
|
244 nil ; overlay-plist
|
|
245 nil ; update-translation-function
|
|
246 nil ; conversion-keys
|
|
247 t ; simple
|
|
248 )
|
|
249
|
|
250 ;; Call quail-make-sisheng-rules for all syllables in sisheng-syllable-table.
|
|
251 ;;
|
|
252 (let ((case-table-save (current-case-table))
|
|
253 sisheng-list)
|
|
254 (set-case-table (standard-case-table))
|
|
255 (dolist (syllable sisheng-syllable-table)
|
|
256 (setq sisheng-list
|
|
257 (append (quail-make-sisheng-rules syllable)
|
|
258 sisheng-list)))
|
|
259
|
|
260 (dolist (syllable sisheng-syllable-table)
|
|
261 (setq sisheng-list
|
|
262 (append (quail-make-sisheng-rules (upcase-initials syllable))
|
|
263 sisheng-list)))
|
|
264
|
|
265 (dolist (syllable sisheng-syllable-table)
|
|
266 (setq sisheng-list
|
|
267 (append (quail-make-sisheng-rules (upcase syllable))
|
|
268 sisheng-list)))
|
|
269
|
|
270 (eval `(quail-define-rules
|
|
271 ,@sisheng-list
|
|
272
|
|
273 ("lv5" ["l端"])
|
|
274 ("lve5" ["l端e"])
|
|
275 ("nv5" ["n端"])
|
|
276 ("nve5" ["n端e"])
|
|
277
|
|
278 ("Lv5" ["L端"])
|
|
279 ("Lve5" ["L端e"])
|
|
280 ("Nv5" ["N端"])
|
|
281 ("Nve5" ["N端e"])
|
|
282
|
|
283 ("LV5" ["L�"])
|
|
284 ("LVE5" ["L�E"])
|
|
285 ("NV5" ["N�"])
|
|
286 ("NVE5" ["N�E"])))
|
|
287 (set-case-table case-table-save))
|
|
288
|
|
289 ;; Local Variables:
|
|
290 ;; coding: utf-8
|
|
291 ;; End:
|
|
292
|
|
293 ;;; arch-tag: 1fa6ba5f-6747-44bc-bf12-30628ad3e8ad
|