1 ;;; sisheng.el --- sisheng input method for Chinese pinyin transliteration -*- coding: ctext -*-
3 ;; Copyright (C) 2004, 2006 Free Software Foundation, Inc.
5 ;; Author: Werner LEMBERG <wl@gnu.org>
7 ;; Keywords: multilingual, input method, Chinese, pinyin, sisheng
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)
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.
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.
24 ;;; Synched up with: FSF 22.0.50.6
28 ;;; XEmacs change: use ctext as coding system for compatibility with 21.4
34 (defconst sisheng-regexp
35 "[
\e-Dàºïòþ
\e$(A(5
\e(B]\\|
\e-Aü
\e-Dº")
\e-A
37 ;; First element is the key,
38 ;; second element is the vowel used for the input sequence,
39 ;; last four elements are the resulting tones.
41 (defconst sisheng-vowel-table
42 '(("
\e-Dà" "a" "à" "
\e-Aá" "
\e$(A(#
\e(B" "à")
43 ("
\e-Dº" "e" "º" "
\e-Aé" "
\e-Bì" "
\e-Aè")
44 ("
\e-Dï" "i" "ï" "
\e-Aí" "
\e$(A(+
\e(B" "ì")
45 ("
\e-Dò" "o" "ò" "
\e-Aó" "
\e$(A(/
\e(B" "ò")
46 ("
\e-Dþ" "u" "þ" "
\e-Aú" "
\e$(A(3
\e(B" "ù")
47 ("
\e$(A(5
\e(B" "v" "
\e$(A(5
\e(B" "
\e$(A(6
\e(B" "
\e$(A(7
\e(B" "
\e$(A(8
\e(B")
48 ("ü
\e-Dº" "ve" "
\e-Aü
\e-Dº" "
\e-Aüé" "ü
\e-Bì" "
\e-Aüè")))
51 ;; All possible syllables in Mandarin Chinese, presented in the first
52 ;; tone. Note that make-sisheng-rules always constructs rules for all
53 ;; four tones even if some of those tones aren't used in Mandarin.
55 (defconst sisheng-syllable-table
56 '("
\e-Dà" "ài" "àn" "àng" "ào"
\e-A
58 "b
\e-Dà" "bài" "bàn" "bàng" "bào"
\e-A
59 "b
\e-Dºi" "bºn" "bºng"
\e-A
60 "b
\e-Dï" "biàn" "biào" "biº" "bïn" "bïng"
\e-A
64 "c
\e-Dà" "cài" "càn" "càng" "cào"
\e-A
65 "c
\e-Dº" "cºn" "cºng"
\e-A
68 "c
\e-Dþ" "cuàn" "cuï" "cþn" "cuò"
\e-A
70 "ch
\e-Dà" "chài" "chàn" "chàng" "chào"
\e-A
71 "ch
\e-Dº" "chºn" "chºng"
\e-A
73 "ch
\e-Dòng" "chòu"
\e-A
74 "ch
\e-Dþ" "chuà" "chuài" "chuàn" "chuàng" "chuï" "chþn" "chuò"
\e-A
76 "d
\e-Dà" "dài" "dàn" "dàng" "dào"
\e-A
77 "d
\e-Dº" "dºi" "dºn" "dºng"
\e-A
78 "d
\e-Dï" "diàn" "diào" "diº" "dïng" "diþ"
\e-A
80 "d
\e-Dþ" "duàn" "duï" "dþn" "duò"
\e-A
82 "
\e-Dº" "ºi" "ºn" "ºng" "ºr"
\e-A
84 "f
\e-Dà" "fàn" "fàng"
\e-A
85 "f
\e-Dºi" "fºn" "fºng"
\e-A
90 "g
\e-Dà" "gài" "gàn" "gàng" "gào"
\e-A
91 "g
\e-Dº" "gºi" "gºn" "gºng"
\e-A
93 "g
\e-Dþ" "guà" "guài" "guàn" "guàng" "guï" "gþn" "guò"
\e-A
95 "h
\e-Dà" "hài" "hàn" "hàng" "hào"
\e-A
96 "h
\e-Dº" "hºi" "hºn" "hºng"
\e-A
98 "h
\e-Dþ" "huà" "huài" "huàn" "huàng" "huï" "hþn" "huò"
\e-A
100 "j
\e-Dï" "jià" "jiàn" "jiàng" "jiào" "jiº" "jïn" "jïng" "jiòng" "jiþ"
\e-A
101 "j
\e-Dþ" "juàn" "juº" "jþn"
\e-A
103 "k
\e-Dà" "kài" "kàn" "kàng" "kào"
\e-A
104 "k
\e-Dº" "kºi" "kºn" "kºng"
\e-A
106 "k
\e-Dþ" "kuà" "kuài" "kuàn" "kuàng" "kuï" "kþn" "kuò"
\e-A
108 "l
\e-Dà" "lài" "làn" "làng" "lào"
\e-A
109 "l
\e-Dº" "lºi" "lºng"
\e-A
110 "l
\e-Dï" "lià" "liàn" "liàng" "liào" "liº" "lïn" "lïng" "liþ"
\e-A
112 "l
\e-Dþ" "luàn" "lþn" "luò"
\e-A
113 "l
\e$(A(5
\e(B" "lü
\e-Dº"
\e-A
115 "m
\e-Dà" "mài" "màn" "màng" "mào"
\e-A
116 "m
\e-Dº" "mºi" "mºn" "mºng"
\e-A
117 "m
\e-Dï" "miàn" "miào" "miº" "mïn" "mïng" "miþ"
\e-A
121 "n
\e-Dà" "nài" "nàn" "nàng" "nào"
\e-A
122 "n
\e-Dº" "nºi" "nºn" "nºng"
\e-A
123 "n
\e-Dï" "niàn" "niàng" "niào" "niº" "nïn" "nïng" "niþ"
\e-A
125 "n
\e-Dþ" "nuàn" "nuò"
\e-A
126 "n
\e$(A(5
\e(B" "nü
\e-Dº"
\e-A
130 "p
\e-Dà" "pài" "pàn" "pàng" "pào"
\e-A
131 "p
\e-Dºi" "pºn" "pºng"
\e-A
132 "p
\e-Dï" "piàn" "piào" "piº" "pïn" "pïng"
\e-A
136 "q
\e-Dï" "qià" "qiàn" "qiàng" "qiào" "qiº" "qïn" "qïng" "qiòng" "qiþ"
\e-A
137 "q
\e-Dþ" "quàn" "quº" "qþn"
\e-A
139 "r
\e-Dàn" "ràng" "rào"
\e-A
140 "r
\e-Dº" "rºn" "rºng"
\e-A
143 "r
\e-Dþ" "ruà" "ruàn" "ruï" "rþn" "ruò"
\e-A
145 "s
\e-Dà" "sài" "sàn" "sàng" "sào"
\e-A
146 "s
\e-Dº" "sºn" "sºng"
\e-A
149 "s
\e-Dþ" "suàn" "suï" "sþn" "suò"
\e-A
151 "sh
\e-Dà" "shài" "shàn" "shàng" "shào"
\e-A
152 "sh
\e-Dº" "shºi" "shºn" "shºng"
\e-A
155 "sh
\e-Dþ" "shuà" "shuài" "shuàn" "shuàng" "shuï" "shþn" "shuò"
\e-A
157 "t
\e-Dà" "tài" "tàn" "tàng" "tào"
\e-A
158 "t
\e-Dº" "tºi" "tºng"
\e-A
159 "t
\e-Dï" "tiàn" "tiào" "tiº" "tïng"
\e-A
161 "t
\e-Dþ" "tuàn" "tuï" "tþn" "tuò"
\e-A
163 "w
\e-Dà" "wài" "wàn" "wàng"
\e-A
164 "w
\e-Dºi" "wºn" "wºng"
\e-A
168 "x
\e-Dï" "xià" "xiàn" "xiàng" "xiào" "xiº" "xïn" "xïng" "xiòng" "xiþ"
\e-A
169 "x
\e-Dþ" "xuàn" "xuº" "xþn"
\e-A
171 "y
\e-Dà" "yàn" "yàng" "yào"
\e-A
173 "y
\e-Dï" "yïn" "yïng"
\e-A
174 "y
\e-Dò" "yòng" "yòu"
\e-A
175 "y
\e-Dþ" "yuàn" "yuº" "yþn"
\e-A
177 "z
\e-Dà" "zài" "zàn" "zàng" "zào"
\e-A
178 "z
\e-Dº" "zºi" "zºn" "zºng"
\e-A
181 "z
\e-Dþ" "zuàn" "zuï" "zþn" "zuò"
\e-A
183 "zh
\e-Dà" "zhài" "zhàn" "zhàng" "zhào"
\e-A
184 "zh
\e-Dº" "zhºi" "zhºn" "zhºng"
\e-A
186 "zh
\e-Dòng" "zhòu"
\e-A
187 "zh
\e-Dþ" "zhuà" "zhuài" "zhuàn" "zhuàng" "zhuï" "zhþn" "zhuò"))
\e-A
189 ;; This function converts e.g.
195 ;; (("zhuo4" ["zhuò"])
196 ;; ("zhuo3" ["zhu
\e$(A(/
\e(B"])
197 ;; ("zhuo2" ["zhuó"])
198 ;; ("zhuo1" ["zhu
\e-Dò"]))
\e-A
200 (defun quail-make-sisheng-rules (syllable)
201 (let ((case-fold-search t)
210 (string-match sisheng-regexp syllable)
211 (setq vowel-match (downcase (match-string 0 syllable)))
213 (cdr (assoc-string vowel-match sisheng-vowel-table)))
214 (setq input-vowel (car vowel-list))
215 (setq base-key (replace-match input-vowel nil nil syllable))
217 (setq key (concat base-key (number-to-string i)))
218 (setq value (vector (replace-match (nth i vowel-list) nil nil syllable)))
219 (push (list key value) key-value-list)
223 ;; Set up sisheng input method.
225 (quail-define-package
226 "chinese-sisheng" ; name
228 "
\e$(A(7
\e(B" ; title
230 "Sìsh
\e-Dºng input method for pïnyïn transliteration of Chinese.
\e-A
232 Examples: shuang1 -> shu
\e-Dàng
\e-A
236 Use the fifth (unstressed) tone for syllables containing `ü'
241 nil ; translation-keys
242 t ; forget-last-selection
246 nil ; create-decode-map
247 nil ; maximum-shortest
249 nil ; update-translation-function
250 nil ; conversion-keys
254 ;; Call quail-make-sisheng-rules for all syllables in sisheng-syllable-table.
256 (let ((case-table-save (current-case-table))
258 (set-case-table (standard-case-table))
259 (dolist (syllable sisheng-syllable-table)
261 (append (quail-make-sisheng-rules syllable)
264 (dolist (syllable sisheng-syllable-table)
266 (append (quail-make-sisheng-rules (upcase-initials syllable))
269 (dolist (syllable sisheng-syllable-table)
271 (append (quail-make-sisheng-rules (upcase syllable))
274 (eval `(quail-define-rules
291 (set-case-table case-table-save))
293 ;;; arch-tag: 1fa6ba5f-6747-44bc-bf12-30628ad3e8ad