Sync up with egg-980712.
[elisp/egg.git] / its / hankata.el
1 ;;; its/hankata.el --- Hnakaku Katakana Input in Egg Input Method Architecture
2
3 ;; Copyright (C) 1997, 1998 Mule Project,
4 ;; Powered by Electrotechnical Laboratory, JAPAN.
5 ;; Project Leader: Satoru Tomura <tomura@etl.go.jp>
6
7 ;; Author: Satoru Tomura <tomura@etl.go.jp>
8
9 ;; This file will be part of GNU Emacs (in future).
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Commentary:
27 ;;
28 ;; Symbol input is desined by jiro@math.keio.ac.jp (TANAKA Jiro)
29 ;; This file is based on the rules of its/kata.el in Mule-2.3 distribution.
30 ;;
31
32 ;;; Code:
33
34 (eval-when-compile
35   (require 'its)
36   (require 'cl))
37
38 (defvar its-han-kata-enable-double-n nil "*Enable \"nn\" input for \"\e$B%s\e(B\" ")
39 (defvar its-han-kata-enable-zenkaku-alphabet t "*Enable Zenkaku alphabet")
40 (defvar its-han-kata-period "\e(I!\e(B" "*\e$B%T%j%*%I\e(B")  ; ". " "\e$B!%\e(B"
41 (defvar its-han-kata-comma  "\e(I$\e(B" "*\e$B%3%s%^\e(B")    ; ", " "\e$B!$\e(B"
42 (defvar its-han-kata-open-bracket  "\e(I"\e(B" "*[")  ; "\e$B!N\e(B"
43 (defvar its-han-kata-close-bracket  "\e(I#\e(B" "*]") ; "\e$B!O\e(B"
44 (defvar its-han-kata-horizontal  "\e(I0\e(B" "*-")    ; "\e$B!]\e(B"
45
46 (define-its-state-machine its-han-kata-map
47   "roma-han-kata" "\e(I11\e(B" Japanese
48   "Map for Romaji-Hankaku-Katakana translation. (Japanese)"
49
50   (defconst its-hankaku-escape "~")  ;; Escape character to Hankaku inputs
51
52   (its-defrule-select-mode-temporally "q" downcase)
53
54 ;;; k      k
55 ;;; kk     \e$B%C\e(Bk
56 ;;; kka    \e$B%C%+\e(B
57 ;;;
58 ;;; kkk    \e$B%C\e(Bk DING!
59
60   (its-defrule "tch"  "\e(I/\e(B" -2)
61
62 ;;; \e$B!V%s!W$NF~NO\e(B
63
64   (dolist (q1 '("b" "m" "p"))
65     (its-defrule (concat "m" q1) "\e(I]\e(B" -1))
66
67   (its-defrule* "n"  "\e(I]\e(B")
68   (its-defrule  "n'" "\e(I]\e(B")
69   (its-defrule  "N"  "\e(I]\e(B")
70
71   (let ((small '"x" ))
72     (its-defrule (concat small "a") "\e(I'\e(B")
73     (its-defrule (concat small "i") "\e(I(\e(B")
74     (its-defrule (concat small "u") "\e(I)\e(B")
75     (its-defrule (concat small "e") "\e(I*\e(B")
76     (its-defrule (concat small "o") "\e(I+\e(B")
77     (its-defrule (concat small "ya") "\e(I,\e(B")
78     (its-defrule (concat small "yu") "\e(I-\e(B")
79     (its-defrule (concat small "yo") "\e(I.\e(B")
80     (its-defrule (concat small "tu") "\e(I/\e(B")
81     (its-defrule (concat small "tsu") "\e(I/\e(B")
82     (its-defrule (concat small "wa") "\e(I\\e(B")
83     )
84
85   (its-defrule   "a"    "\e(I1\e(B")
86   (its-defrule   "i"    "\e(I2\e(B")
87   (its-defrule   "u"    "\e(I3\e(B")
88   (its-defrule   "e"    "\e(I4\e(B")
89   (its-defrule   "o"    "\e(I5\e(B")
90
91   (dolist (k '(("ka"  "\e(I6\e(B") ("ki"  "\e(I7\e(B") ("ku"  "\e(I8\e(B") ("ke"  "\e(I9\e(B") ("ko"  "\e(I:\e(B")
92                ("kya" "\e(I7,\e(B") ("kyu"  "\e(I7-\e(B") ("kye"  "\e(I7*\e(B") ("kyo"  "\e(I7.\e(B")))
93     (its-defrule (car k) (cadr k))
94     (its-defrule (concat "k" (car k)) (concat "\e(I/\e(B" (cadr k))))
95   (its-defoutput "kk" "\e(I/\e(Bk")
96   (its-defoutput "kky" "\e(I/\e(Bky")
97
98   (dolist (s '(("sa"  "\e(I;\e(B") ("si"  "\e(I<\e(B") ("su"  "\e(I=\e(B") ("se"  "\e(I>\e(B") ("so"  "\e(I?\e(B")
99                ("sya"  "\e(I<,\e(B") ("syu"  "\e(I<-\e(B") ("sye"  "\e(I<*\e(B") ("syo"  "\e(I<.\e(B")
100                ("sha"  "\e(I<,\e(B") ("shi"  "\e(I<\e(B") ("shu"  "\e(I<-\e(B") ("she"  "\e(I<*\e(B")
101                ("sho"  "\e(I<.\e(B")))
102     (its-defrule (car s) (cadr s))
103     (its-defrule (concat "s" (car s)) (concat "\e(I/\e(B" (cadr s))))
104   (its-defoutput "ss" "\e(I/\e(Bs")
105   (its-defoutput "ssy" "\e(I/\e(Bsy")
106   (its-defoutput "ssh" "\e(I/\e(Bsh")
107
108   (dolist (T '(("ta"  "\e(I@\e(B") ("ti"  "\e(IA\e(B") ("tu"  "\e(IB\e(B") ("te"  "\e(IC\e(B") ("to"  "\e(ID\e(B")
109                ("tya"  "\e(IA,\e(B") ("tyi"  "\e(IC(\e(B") ("tyu"  "\e(IA-\e(B") ("tye"  "\e(IA*\e(B")
110                ("tyo"  "\e(IA.\e(B") ("tsu"  "\e(IB\e(B")))
111     (its-defrule (car T) (cadr T))
112     (its-defrule (concat "t" (car T)) (concat "\e(I/\e(B" (cadr T))))
113   (its-defoutput "tt" "\e(I/\e(Bt")
114   (its-defoutput "tty" "\e(I/\e(Bty")
115   (its-defoutput "tts" "\e(I/\e(Bts")
116
117   (dolist (c '(("cha"  "\e(IA,\e(B") ("chi"  "\e(IA\e(B") ("chu"  "\e(IA-\e(B")
118                ("che"  "\e(IA*\e(B") ("cho"  "\e(IA.\e(B")))
119     (its-defrule (car c) (cadr c))
120     (its-defrule (concat "c" (car c)) (concat "\e(I/\e(B" (cadr c))))
121   (its-defoutput "cc" "\e(I/\e(Bc")
122   (its-defoutput "cch" "\e(I/\e(Bch")
123
124   (dolist (h '(("ha"  "\e(IJ\e(B") ("hi"  "\e(IK\e(B") ("hu"  "\e(IL\e(B") ("he"  "\e(IM\e(B") ("ho"  "\e(IN\e(B")
125                ("hya"  "\e(IK,\e(B") ("hyu"  "\e(IK-\e(B") ("hye"  "\e(IK*\e(B") ("hyo"  "\e(IK.\e(B")))
126     (its-defrule (car h) (cadr h))
127     (its-defrule (concat "h" (car h)) (concat "\e(I/\e(B" (cadr h))))
128   (its-defoutput "hh" "\e(I/\e(Bh")
129   (its-defoutput "hhy" "\e(I/\e(Bhy")
130
131   (dolist (f '(("fa"  "\e(IL'\e(B") ("fi"  "\e(IL(\e(B") ("fu"  "\e(IL\e(B") ("fe"  "\e(IL*\e(B")
132                ("fo"  "\e(IL+\e(B")))
133     (its-defrule (car f) (cadr f))
134     (its-defrule (concat "f" (car f)) (concat "\e(I/\e(B" (cadr f))))
135   (its-defoutput "ff" "\e(I/\e(Bf")
136
137   (dolist (r '(("ra"  "\e(IW\e(B") ("ri"  "\e(IX\e(B") ("ru"  "\e(IY\e(B") ("re"  "\e(IZ\e(B") ("ro"  "\e(I[\e(B")
138                ("rya"  "\e(IX,\e(B") ("ryu"  "\e(IX-\e(B") ("rye"  "\e(IX*\e(B") ("ryo"  "\e(IX.\e(B")))
139     (its-defrule (car r) (cadr r))
140     (its-defrule (concat "r" (car r)) (concat "\e(I/\e(B" (cadr r))))
141   (its-defoutput "rr" "\e(I/\e(Br")
142   (its-defoutput "rry" "\e(I/\e(Bry")
143
144   (dolist (l '(("la"  "\e(IW\e(B") ("li"  "\e(IX\e(B") ("lu"  "\e(IY\e(B") ("le"  "\e(IZ\e(B") ("lo"  "\e(I[\e(B")
145                ("lya"  "\e(IX,\e(B") ("lyu"  "\e(IX-\e(B") ("lye"  "\e(IX*\e(B") ("lyo"  "\e(IX.\e(B")))
146     (its-defrule (car l) (cadr l))
147     (its-defrule (concat "l" (car l)) (concat "\e(I/\e(B" (cadr l))))
148   (its-defoutput "ll" "\e(I/\e(Bl")
149   (its-defoutput "lly" "\e(I/\e(Bly")
150
151   (dolist (g '(("ga"  "\e(I6^\e(B") ("gi"  "\e(I7^\e(B") ("gu"  "\e(I8^\e(B") ("ge"  "\e(I9^\e(B") ("go"  "\e(I:^\e(B")
152                ("gya"  "\e(I7^,\e(B") ("gyu"  "\e(I7^-\e(B") ("gye"  "\e(I7^*\e(B") ("gyo"  "\e(I7^.\e(B")))
153     (its-defrule (car g) (cadr g))
154     (its-defrule (concat "g" (car g)) (concat "\e(I/\e(B" (cadr g))))
155   (its-defoutput "gg" "\e(I/\e(Bg")
156   (its-defoutput "ggy" "\e(I/\e(Bgy")
157
158   (dolist (z '(("za"  "\e(I;^\e(B") ("zi"  "\e(I<^\e(B") ("zu"  "\e(I=^\e(B") ("ze"  "\e(I>^\e(B") ("zo"  "\e(I?^\e(B")
159                ("zya"  "\e(I<^,\e(B") ("zyu"  "\e(I<^-\e(B") ("zye"  "\e(I<^*\e(B") ("zyo"  "\e(I<^.\e(B")))
160     (its-defrule (car z) (cadr z))
161     (its-defrule (concat "z" (car z)) (concat "\e(I/\e(B" (cadr z))))
162   (its-defoutput "zz" "\e(I/\e(Bz")
163   (its-defoutput "zzy" "\e(I/\e(Bzy")
164
165   (dolist (j '(("ja"  "\e(I<^,\e(B") ("ji"  "\e(I<^\e(B") ("ju"  "\e(I<^-\e(B") ("je"  "\e(I<^*\e(B")
166                ("jo"  "\e(I<^.\e(B") ("jya"  "\e(I<^,\e(B") ("jyu"  "\e(I<^-\e(B") ("jye"  "\e(I<^*\e(B")
167                ("jyo"  "\e(I<^.\e(B")))
168     (its-defrule (car j) (cadr j))
169     (its-defrule (concat "j" (car j)) (concat "\e(I/\e(B" (cadr j))))
170   (its-defoutput "jj" "\e(I/\e(Bj")
171   (its-defoutput "jjy" "\e(I/\e(Bjy")
172
173   (dolist (d '(("da"  "\e(I@^\e(B") ("di"  "\e(IA^\e(B") ("du"  "\e(IB^\e(B") ("de"  "\e(IC^\e(B") ("do"  "\e(ID^\e(B")
174                ("dya"  "\e(IA^,\e(B") ("dyi"  "\e(IC^(\e(B") ("dyu"  "\e(IA^-\e(B") ("dye"  "\e(IA^*\e(B")
175                ("dyo"  "\e(IA^.\e(B")))
176     (its-defrule (car d) (cadr d))
177     (its-defrule (concat "d" (car d)) (concat "\e(I/\e(B" (cadr d))))
178   (its-defoutput "dd" "\e(I/\e(Bd")
179   (its-defoutput "ddy" "\e(I/\e(Bdy")
180
181   (dolist (b '(("ba"  "\e(IJ^\e(B") ("bi"  "\e(IK^\e(B") ("bu"  "\e(IL^\e(B") ("be"  "\e(IM^\e(B") ("bo"  "\e(IN^\e(B")
182                ("bya"  "\e(IK^,\e(B") ("byu"  "\e(IK^-\e(B") ("bye"  "\e(IK^*\e(B") ("byo"  "\e(IK^.\e(B")))
183     (its-defrule (car b) (cadr b))
184     (its-defrule (concat "b" (car b)) (concat "\e(I/\e(B" (cadr b))))
185   (its-defoutput "bb" "\e(I/\e(Bb")
186   (its-defoutput "bby" "\e(I/\e(Bby")
187
188   (dolist (p '(("pa"  "\e(IJ_\e(B") ("pi"  "\e(IK_\e(B") ("pu"  "\e(IL_\e(B") ("pe"  "\e(IM_\e(B") ("po"   "\e(IN_\e(B")
189                ("pya"  "\e(IK_,\e(B") ("pyu"  "\e(IK_-\e(B") ("pye"  "\e(IK_*\e(B") ("pyo"  "\e(IK_.\e(B")))
190     (its-defrule (car p) (cadr p))
191     (its-defrule (concat "p" (car p)) (concat "\e(I/\e(B" (cadr p))))
192   (its-defoutput "pp" "\e(I/\e(Bp")
193   (its-defoutput "ppy" "\e(I/\e(Bpy")
194
195   (dolist (v '(("va" "\e(I3^'\e(B") ("vi" "\e(I3^(\e(B") ("vu" "\e(I3^\e(B") ("ve" "\e(I3^*\e(B")
196                ("vo" "\e(I3^+\e(B")))
197     (its-defrule (car v) (cadr v))
198     (its-defrule (concat "v" (car v)) (concat "\e(I/\e(B" (cadr v))))
199   (its-defoutput "vv" "\e(I/\e(Bv")
200
201   (its-defrule   "ma"   "\e(IO\e(B")
202   (its-defrule   "mi"   "\e(IP\e(B")
203   (its-defrule   "mu"   "\e(IQ\e(B")
204   (its-defrule   "me"   "\e(IR\e(B")
205   (its-defrule   "mo"   "\e(IS\e(B")
206   (its-defrule   "mya"  "\e(IP,\e(B")
207   (its-defrule   "myu"  "\e(IP-\e(B")
208   (its-defrule   "mye"  "\e(IP*\e(B")
209   (its-defrule   "myo"  "\e(IP.\e(B")
210   (its-defrule   "ya"   "\e(IT\e(B")
211   (its-defrule   "yi"   "\e(I2\e(B")
212   (its-defrule   "yu"   "\e(IU\e(B")
213   (its-defrule   "yo"   "\e(IV\e(B")
214   (its-defrule   "ye"   "\e(I2*\e(B")
215   (its-defrule   "wa"   "\e(I\\e(B")
216   (its-defrule   "wi"   "\e(I(\e(B")
217   (its-defrule   "wu"   "\e(I3\e(B")
218   (its-defrule   "we"   "\e(I*\e(B")
219   (its-defrule   "wo"   "\e(I&\e(B")
220
221   (its-defrule   "kwa"  "\e(I8\\e(B")
222   (its-defrule   "kwi"  "\e(I8(\e(B")
223   (its-defrule   "kwu"  "\e(I8\e(B")
224   (its-defrule   "kwe"  "\e(I8*\e(B")
225   (its-defrule   "kwo"  "\e(I8+\e(B")
226   (its-defrule   "gwa"  "\e(I8^\\e(B")
227   (its-defrule   "gwi"  "\e(I8^(\e(B")
228   (its-defrule   "gwu"  "\e(I8^\e(B")
229   (its-defrule   "gwe"  "\e(I8^*\e(B")
230   (its-defrule   "gwo"  "\e(I8^+\e(B")
231   (its-defrule   "tsa"  "\e(IB'\e(B")
232   (its-defrule   "tsi"  "\e(IB(\e(B")
233   (its-defrule   "tse"  "\e(IB*\e(B")
234   (its-defrule   "tso"  "\e(IB+\e(B")
235
236   (its-defrule   "na"   "\e(IE\e(B")
237   (its-defrule   "ni"   "\e(IF\e(B")
238   (its-defrule   "nu"   "\e(IG\e(B")
239   (its-defrule   "ne"   "\e(IH\e(B")
240   (its-defrule   "no"   "\e(II\e(B")
241   (its-defrule   "nya"  "\e(IF,\e(B")
242   (its-defrule   "nyu"  "\e(IF-\e(B")
243   (its-defrule   "nye"  "\e(IF*\e(B")
244   (its-defrule   "nyo"  "\e(IF.\e(B")
245
246   (its-defrule   "xti"  "\e(IC(\e(B")
247   (its-defrule   "xdi"  "\e(IC^(\e(B")
248   (its-defrule   "xdu"  "\e(ID^)\e(B")
249   (its-defrule   "xde"  "\e(IC^*\e(B")
250   (its-defrule   "xdo"  "\e(ID^+\e(B")
251   (its-defrule   "xwi"  "\e(I3(\e(B")
252   (its-defrule   "xwe"  "\e(I3*\e(B")
253   (its-defrule   "xwo"  "\e(I3+\e(B")
254
255 ;;;
256 ;;; Symbol inputs
257 ;;;
258
259   (dolist (digit '( "1"  "2"  "3"  "4" "5"  "6"  "7"  "8"  "9"  "0" ))
260     (its-defrule (concat its-hankaku-escape digit)  digit))
261
262   (dolist (symbol '( " "  "!"  "@"  "#"  "$"  "%"  "^"  "&"  "*"  "("  ")"
263                      "-"  "="  "`"  "\\" "|"  "_"  "+"  "~" "["  "]"  "{"  "}"
264                      ":"  ";"  "\"" "'"  "<"  ">"  "?"  "/"  ","  "." ))
265     (its-defrule (concat its-hankaku-escape symbol) symbol))
266
267   (dolist (downcase '("a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n"
268                       "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"))
269     (its-defrule (concat its-hankaku-escape downcase) downcase))
270
271   (dolist (upcase    '("A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N"
272                        "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z"))
273     (its-defrule (concat its-hankaku-escape upcase) upcase)))
274
275 (define-its-state-machine-append its-han-kata-map
276   (if its-han-kata-enable-double-n
277       (its-defrule "nn" "\e(I]\e(B"))
278
279   (its-defrule "-" its-han-kata-horizontal)
280   (its-defrule "[" its-han-kata-open-bracket)
281   (its-defrule "]" its-han-kata-close-bracket)
282   (its-defrule "." its-han-kata-period)
283   (its-defrule "," its-han-kata-comma)
284   )
285
286 (provide 'its/hankata)
287 ;;; its/kata.el ends here.