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