980314 version
[elisp/egg.git] / its / hankata.el
diff --git a/its/hankata.el b/its/hankata.el
new file mode 100644 (file)
index 0000000..fc51124
--- /dev/null
@@ -0,0 +1,291 @@
+;;; its/hankata.el --- Hnakaku Katakana Input in Egg Input Method Architecture
+
+;; Copyright (C) 1997, 1998 Mule Project,
+;; Powered by Electrotechnical Laboratory, JAPAN.
+;; Project Leader: Satoru Tomura <tomura@etl.go.jp>
+
+;; Author: Satoru Tomura <tomura@etl.go.jp>
+
+;; This file will be part of GNU Emacs (in future).
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+;;
+;; Symbol input is desined by jiro@math.keio.ac.jp (TANAKA Jiro)
+;; This file is based on the rules of its/kata.el in Mule-2.3 distribution.
+;;
+
+;;; Code:
+
+(eval-when-compile
+  (require 'its)
+  (require 'cl))
+
+(defvar its-kata-enable-double-n nil "*Enable \"nn\" input for \"\e$B%s\e(B\" ")
+(defvar its-kata-enable-zenkaku-alphabet t "*Enable Zenkaku alphabet")
+(defvar its-kata-period "\e(I!\e(B" "*\e$B%T%j%*%I\e(B")  ; ". " "\e$B!%\e(B"
+(defvar its-kata-comma  "\e(I$\e(B" "*\e$B%3%s%^\e(B")    ; ", " "\e$B!$\e(B"
+(defvar its-kata-open-bracket  "\e(I"\e(B" "*[")  ; "\e$B!N\e(B"
+(defvar its-kata-close-bracket  "\e(I#\e(B" "*]") ; "\e$B!O\e(B"
+(defvar its-kata-horizontal  "\e(I0\e(B" "*-")    ; "\e$B!]\e(B"
+
+(define-its-state-machine its-han-kata-map
+  "roma-han-kata" "\e(I11\e(B" "Japanese" nil
+  "Map for Romaji-Hankaku-Katakana translation. (Japanese)"
+
+  (defconst its-hankaku-escape "~")  ;; Escape character to Hankaku inputs
+
+  (its-defrule-select-mode-temporally "q" downcase)
+
+;;; k      k
+;;; kk     \e$B%C\e(Bk
+;;; kka    \e$B%C%+\e(B
+;;;
+;;; kkk    \e$B%C\e(Bk DING!
+
+  (its-defrule "tch"  "\e(I/\e(B" -2)
+
+;;; \e$B!V%s!W$NF~NO\e(B
+
+  (dolist (q1 '("b" "m" "p"))
+    (its-defrule (concat "m" q1) "\e(I]\e(B" -1))
+
+  (its-defrule "N" "\e(I]\e(B")
+
+  (let ((state (its-goto-state "n" nil t)))
+    (its-make-next-state state -1 "n" "\e(I]\e(B")
+    (its-make-next-state state ?' "n" "\e(I]\e(B")
+    (its-defrule-otherwise state "\e(I]\e(B"))
+
+  (let ((small '"x" ))
+    (its-defrule (concat small "a") "\e(I'\e(B")
+    (its-defrule (concat small "i") "\e(I(\e(B")
+    (its-defrule (concat small "u") "\e(I)\e(B")
+    (its-defrule (concat small "e") "\e(I*\e(B")
+    (its-defrule (concat small "o") "\e(I+\e(B")
+    (its-defrule (concat small "ya") "\e(I,\e(B")
+    (its-defrule (concat small "yu") "\e(I-\e(B")
+    (its-defrule (concat small "yo") "\e(I.\e(B")
+    (its-defrule (concat small "tu") "\e(I/\e(B")
+    (its-defrule (concat small "tsu") "\e(I/\e(B")
+    (its-defrule (concat small "wa") "\e(I\\e(B")
+    )
+
+  (its-defrule   "a"    "\e(I1\e(B")
+  (its-defrule   "i"    "\e(I2\e(B")
+  (its-defrule   "u"    "\e(I3\e(B")
+  (its-defrule   "e"    "\e(I4\e(B")
+  (its-defrule   "o"    "\e(I5\e(B")
+
+  (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")
+              ("kya" "\e(I7,\e(B") ("kyu"  "\e(I7-\e(B") ("kye"  "\e(I7*\e(B") ("kyo"  "\e(I7.\e(B")))
+    (its-defrule (car k) (cadr k))
+    (its-defrule (concat "k" (car k)) (concat "\e(I/\e(B" (cadr k))))
+  (its-defoutput "kk" "\e(I/\e(Bk")
+  (its-defoutput "kky" "\e(I/\e(Bky")
+
+  (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")
+              ("sya"  "\e(I<,\e(B") ("syu"  "\e(I<-\e(B") ("sye"  "\e(I<*\e(B") ("syo"  "\e(I<.\e(B")
+              ("sha"  "\e(I<,\e(B") ("shi"  "\e(I<\e(B") ("shu"  "\e(I<-\e(B") ("she"  "\e(I<*\e(B")
+              ("sho"  "\e(I<.\e(B")))
+    (its-defrule (car s) (cadr s))
+    (its-defrule (concat "s" (car s)) (concat "\e(I/\e(B" (cadr s))))
+  (its-defoutput "ss" "\e(I/\e(Bs")
+  (its-defoutput "ssy" "\e(I/\e(Bsy")
+  (its-defoutput "ssh" "\e(I/\e(Bsh")
+
+  (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")
+              ("tya"  "\e(IA,\e(B") ("tyi"  "\e(IC(\e(B") ("tyu"  "\e(IA-\e(B") ("tye"  "\e(IA*\e(B")
+              ("tyo"  "\e(IA.\e(B") ("tsu"  "\e(IB\e(B")))
+    (its-defrule (car T) (cadr T))
+    (its-defrule (concat "t" (car T)) (concat "\e(I/\e(B" (cadr T))))
+  (its-defoutput "tt" "\e(I/\e(Bt")
+  (its-defoutput "tty" "\e(I/\e(Bty")
+  (its-defoutput "tts" "\e(I/\e(Bts")
+
+  (dolist (c '(("cha"  "\e(IA,\e(B") ("chi"  "\e(IA\e(B") ("chu"  "\e(IA-\e(B")
+              ("che"  "\e(IA*\e(B") ("cho"  "\e(IA.\e(B")))
+    (its-defrule (car c) (cadr c))
+    (its-defrule (concat "c" (car c)) (concat "\e(I/\e(B" (cadr c))))
+  (its-defoutput "cc" "\e(I/\e(Bc")
+  (its-defoutput "cch" "\e(I/\e(Bch")
+
+  (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")
+              ("hya"  "\e(IK,\e(B") ("hyu"  "\e(IK-\e(B") ("hye"  "\e(IK*\e(B") ("hyo"  "\e(IK.\e(B")))
+    (its-defrule (car h) (cadr h))
+    (its-defrule (concat "h" (car h)) (concat "\e(I/\e(B" (cadr h))))
+  (its-defoutput "hh" "\e(I/\e(Bh")
+  (its-defoutput "hhy" "\e(I/\e(Bhy")
+
+  (dolist (f '(("fa"  "\e(IL'\e(B") ("fi"  "\e(IL(\e(B") ("fu"  "\e(IL\e(B") ("fe"  "\e(IL*\e(B")
+              ("fo"  "\e(IL+\e(B")))
+    (its-defrule (car f) (cadr f))
+    (its-defrule (concat "f" (car f)) (concat "\e(I/\e(B" (cadr f))))
+  (its-defoutput "ff" "\e(I/\e(Bf")
+
+  (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")
+              ("rya"  "\e(IX,\e(B") ("ryu"  "\e(IX-\e(B") ("rye"  "\e(IX*\e(B") ("ryo"  "\e(IX.\e(B")))
+    (its-defrule (car r) (cadr r))
+    (its-defrule (concat "r" (car r)) (concat "\e(I/\e(B" (cadr r))))
+  (its-defoutput "rr" "\e(I/\e(Br")
+  (its-defoutput "rry" "\e(I/\e(Bry")
+
+  (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")
+              ("lya"  "\e(IX,\e(B") ("lyu"  "\e(IX-\e(B") ("lye"  "\e(IX*\e(B") ("lyo"  "\e(IX.\e(B")))
+    (its-defrule (car l) (cadr l))
+    (its-defrule (concat "l" (car l)) (concat "\e(I/\e(B" (cadr l))))
+  (its-defoutput "ll" "\e(I/\e(Bl")
+  (its-defoutput "lly" "\e(I/\e(Bly")
+
+  (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")
+              ("gya"  "\e(I7^,\e(B") ("gyu"  "\e(I7^-\e(B") ("gye"  "\e(I7^*\e(B") ("gyo"  "\e(I7^.\e(B")))
+    (its-defrule (car g) (cadr g))
+    (its-defrule (concat "g" (car g)) (concat "\e(I/\e(B" (cadr g))))
+  (its-defoutput "gg" "\e(I/\e(Bg")
+  (its-defoutput "ggy" "\e(I/\e(Bgy")
+
+  (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")
+              ("zya"  "\e(I<^,\e(B") ("zyu"  "\e(I<^-\e(B") ("zye"  "\e(I<^*\e(B") ("zyo"  "\e(I<^.\e(B")))
+    (its-defrule (car z) (cadr z))
+    (its-defrule (concat "z" (car z)) (concat "\e(I/\e(B" (cadr z))))
+  (its-defoutput "zz" "\e(I/\e(Bz")
+  (its-defoutput "zzy" "\e(I/\e(Bzy")
+
+  (dolist (j '(("ja"  "\e(I<^,\e(B") ("ji"  "\e(I<^\e(B") ("ju"  "\e(I<^-\e(B") ("je"  "\e(I<^*\e(B")
+              ("jo"  "\e(I<^.\e(B") ("jya"  "\e(I<^,\e(B") ("jyu"  "\e(I<^-\e(B") ("jye"  "\e(I<^*\e(B")
+              ("jyo"  "\e(I<^.\e(B")))
+    (its-defrule (car j) (cadr j))
+    (its-defrule (concat "j" (car j)) (concat "\e(I/\e(B" (cadr j))))
+  (its-defoutput "jj" "\e(I/\e(Bj")
+  (its-defoutput "jjy" "\e(I/\e(Bjy")
+
+  (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")
+              ("dya"  "\e(IA^,\e(B") ("dyi"  "\e(IC^(\e(B") ("dyu"  "\e(IA^-\e(B") ("dye"  "\e(IA^*\e(B")
+              ("dyo"  "\e(IA^.\e(B")))
+    (its-defrule (car d) (cadr d))
+    (its-defrule (concat "d" (car d)) (concat "\e(I/\e(B" (cadr d))))
+  (its-defoutput "dd" "\e(I/\e(Bd")
+  (its-defoutput "ddy" "\e(I/\e(Bdy")
+
+  (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")
+              ("bya"  "\e(IK^,\e(B") ("byu"  "\e(IK^-\e(B") ("bye"  "\e(IK^*\e(B") ("byo"  "\e(IK^.\e(B")))
+    (its-defrule (car b) (cadr b))
+    (its-defrule (concat "b" (car b)) (concat "\e(I/\e(B" (cadr b))))
+  (its-defoutput "bb" "\e(I/\e(Bb")
+  (its-defoutput "bby" "\e(I/\e(Bby")
+
+  (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")
+              ("pya"  "\e(IK_,\e(B") ("pyu"  "\e(IK_-\e(B") ("pye"  "\e(IK_*\e(B") ("pyo"  "\e(IK_.\e(B")))
+    (its-defrule (car p) (cadr p))
+    (its-defrule (concat "p" (car p)) (concat "\e(I/\e(B" (cadr p))))
+  (its-defoutput "pp" "\e(I/\e(Bp")
+  (its-defoutput "ppy" "\e(I/\e(Bpy")
+
+  (dolist (v '(("va" "\e(I3^'\e(B") ("vi" "\e(I3^(\e(B") ("vu" "\e(I3^\e(B") ("ve" "\e(I3^*\e(B")
+              ("vo" "\e(I3^+\e(B")))
+    (its-defrule (car v) (cadr v))
+    (its-defrule (concat "v" (car v)) (concat "\e(I/\e(B" (cadr v))))
+  (its-defoutput "vv" "\e(I/\e(Bv")
+
+  (its-defrule   "ma"   "\e(IO\e(B")
+  (its-defrule   "mi"   "\e(IP\e(B")
+  (its-defrule   "mu"   "\e(IQ\e(B")
+  (its-defrule   "me"   "\e(IR\e(B")
+  (its-defrule   "mo"   "\e(IS\e(B")
+  (its-defrule   "mya"  "\e(IP,\e(B")
+  (its-defrule   "myu"  "\e(IP-\e(B")
+  (its-defrule   "mye"  "\e(IP*\e(B")
+  (its-defrule   "myo"  "\e(IP.\e(B")
+  (its-defrule   "ya"   "\e(IT\e(B")
+  (its-defrule   "yi"   "\e(I2\e(B")
+  (its-defrule   "yu"   "\e(IU\e(B")
+  (its-defrule   "yo"   "\e(IV\e(B")
+  (its-defrule   "ye"   "\e(I2*\e(B")
+  (its-defrule   "wa"   "\e(I\\e(B")
+  (its-defrule   "wi"   "\e(I(\e(B")
+  (its-defrule   "wu"   "\e(I3\e(B")
+  (its-defrule   "we"   "\e(I*\e(B")
+  (its-defrule   "wo"   "\e(I&\e(B")
+
+  (its-defrule   "kwa"  "\e(I8\\e(B")
+  (its-defrule   "kwi"  "\e(I8(\e(B")
+  (its-defrule   "kwu"  "\e(I8\e(B")
+  (its-defrule   "kwe"  "\e(I8*\e(B")
+  (its-defrule   "kwo"  "\e(I8+\e(B")
+  (its-defrule   "gwa"  "\e(I8^\\e(B")
+  (its-defrule   "gwi"  "\e(I8^(\e(B")
+  (its-defrule   "gwu"  "\e(I8^\e(B")
+  (its-defrule   "gwe"  "\e(I8^*\e(B")
+  (its-defrule   "gwo"  "\e(I8^+\e(B")
+  (its-defrule   "tsa"  "\e(IB'\e(B")
+  (its-defrule   "tsi"  "\e(IB(\e(B")
+  (its-defrule   "tse"  "\e(IB*\e(B")
+  (its-defrule   "tso"  "\e(IB+\e(B")
+
+  (its-defrule   "na"   "\e(IE\e(B")
+  (its-defrule   "ni"   "\e(IF\e(B")
+  (its-defrule   "nu"   "\e(IG\e(B")
+  (its-defrule   "ne"   "\e(IH\e(B")
+  (its-defrule   "no"   "\e(II\e(B")
+  (its-defrule   "nya"  "\e(IF,\e(B")
+  (its-defrule   "nyu"  "\e(IF-\e(B")
+  (its-defrule   "nye"  "\e(IF*\e(B")
+  (its-defrule   "nyo"  "\e(IF.\e(B")
+
+  (its-defrule   "xti"  "\e(IC(\e(B")
+  (its-defrule   "xdi"  "\e(IC^(\e(B")
+  (its-defrule   "xdu"  "\e(ID^)\e(B")
+  (its-defrule   "xde"  "\e(IC^*\e(B")
+  (its-defrule   "xdo"  "\e(ID^+\e(B")
+  (its-defrule   "xwi"  "\e(I3(\e(B")
+  (its-defrule   "xwe"  "\e(I3*\e(B")
+  (its-defrule   "xwo"  "\e(I3+\e(B")
+
+;;;
+;;; Symbol inputs
+;;;
+
+  (dolist (digit '( "1"  "2"  "3"  "4" "5"  "6"  "7"  "8"  "9"  "0" ))
+    (its-defrule (concat its-hankaku-escape digit)  digit))
+
+  (dolist (symbol '( " "  "!"  "@"  "#"  "$"  "%"  "^"  "&"  "*"  "("  ")"
+                    "-"  "="  "`"  "\\" "|"  "_"  "+"  "~" "["  "]"  "{"  "}"
+                    ":"  ";"  "\"" "'"  "<"  ">"  "?"  "/"  ","  "." ))
+    (its-defrule (concat its-hankaku-escape symbol) symbol))
+
+  (dolist (downcase '("a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n"
+                     "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"))
+    (its-defrule (concat its-hankaku-escape downcase) downcase))
+
+  (dolist (upcase    '("A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N"
+                      "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z"))
+    (its-defrule (concat its-hankaku-escape upcase) upcase)))
+
+(define-its-state-machine-append its-han-kata-map
+  (if its-kata-enable-double-n
+      (its-defrule "nn" "\e(I]\e(B")
+    (its-defrule "nn" "\e(I]\e(B" -1))
+
+  (its-defrule "-" its-kata-horizontal)
+  (its-defrule "[" its-kata-open-bracket)
+  (its-defrule "]" its-kata-close-bracket)
+  (its-defrule "." its-kata-period)
+  (its-defrule "," its-kata-comma)
+  )
+
+(provide 'its/hankata)
+;;; its/kata.el ends here.