1 ;; anthy-dic.el -- Anthy
3 ;; Copyright (C) 2001 - 2005
4 ;; Author: Yusuke Tabata<yusuke@w5.dion.ne.jp>
7 ;; This file is part of Anthy
14 ;; Funded by IPA
\e$BL$F'%=%U%H%&%'%"AOB$;v6H
\e(B 2001 11/10
17 (defvar anthy-dic-util-command "anthy-dic-tool")
18 (defvar anthy-dic-buffer-name " *anthy-dic*")
20 (defun anthy-add-word-compose-paramlist (param)
23 (let* ((cur (car param))
25 (val (if (stringp (car (cdr cur)))
27 (if (car (cdr cur)) "y" "n"))))
29 var "\t=\t" val "\n")))
30 (setq param (cdr param)))
33 (defun anthy-add-word (yomi freq word paramlist)
35 (setq proc (start-process "anthy-dic" anthy-dic-buffer-name
36 anthy-dic-util-command "--append"))
40 (if (coding-system-p (find-coding-system 'euc-japan))
41 (set-process-coding-system proc 'euc-japan 'euc-japan))
42 (cond ((coding-system-p 'euc-japan)
43 (set-process-coding-system proc 'euc-japan 'euc-japan))
44 ((coding-system-p '*euc-japan*)
45 (set-process-coding-system proc '*euc-japan* '*euc-japan*))))
46 (process-send-string proc
47 (concat yomi " " (int-to-string freq) " " word "\n"))
48 (process-send-string proc
49 (anthy-add-word-compose-paramlist paramlist))
50 (process-send-string proc "\n")
51 (process-send-eof proc)
55 (defun anthy-dic-get-noun-category (word)
57 ((res '(("
\e$BIJ;l
\e(B" "
\e$BL>;l
\e(B")))
58 (na (y-or-n-p (concat "
\e$B!V
\e(B" word "
\e$B$J!W$H8@$$$^$9$+
\e(B? ")))
59 (sa (y-or-n-p (concat "
\e$B!V
\e(B" word "
\e$B$5!W$H8@$$$^$9$+
\e(B? ")))
60 (suru (y-or-n-p (concat "
\e$B!V
\e(B" word "
\e$B$9$k!W$H8@$$$^$9$+
\e(B? ")))
61 (ind (y-or-n-p (concat "
\e$B!V
\e(B" word "
\e$B!W$OC1FH$GJ8@a$K$J$j$^$9$+
\e(B? ")))
62 (kaku (y-or-n-p (concat "
\e$B!V
\e(B" word "
\e$B$H!W$H8@$$$^$9$+
\e(B? "))))
63 (setq res (cons `("
\e$B$J@\B3
\e(B" ,na) res))
64 (setq res (cons `("
\e$B$5@\B3
\e(B" ,sa) res))
65 (setq res (cons `("
\e$B$9$k@\B3
\e(B" ,suru) res))
66 (setq res (cons `("
\e$B8l44$N$_$GJ8@a
\e(B" ,ind) res))
67 (setq res (cons `("
\e$B3J=u;l@\B3
\e(B" ,kaku) res))
70 (defun anthy-dic-get-special-noun-category (word)
74 (read-from-minibuffer "1:
\e$B?ML>
\e(B 2:
\e$BCOL>
\e(B: "))))
76 (setq res '(("
\e$BIJ;l
\e(B" "
\e$B?ML>
\e(B"))))
78 (setq res '(("
\e$BIJ;l
\e(B" "
\e$BCOL>
\e(B")))))
81 (defun anthy-dic-get-adjective-category (word)
82 '(("
\e$BIJ;l
\e(B" "
\e$B7AMF;l
\e(B")))
84 (defun anthy-dic-get-av-category (word)
86 ((res '(("
\e$BIJ;l
\e(B" "
\e$BI{;l
\e(B")))
87 (to (y-or-n-p (concat "
\e$B!V
\e(B" word "
\e$B$H!W$H8@$$$^$9$+
\e(B?")))
88 (taru (y-or-n-p (concat "
\e$B!V
\e(B" word "
\e$B$?$k!W$H8@$$$^$9$+
\e(B?")))
89 (suru (y-or-n-p (concat "
\e$B!V
\e(B" word "
\e$B$9$k!W$H8@$$$^$9$+
\e(B?")))
90 (ind (y-or-n-p (concat "
\e$B!V
\e(B" word "
\e$B!W$OC1FH$GJ8@a$K$J$j$^$9$+
\e(B?"))))
91 (setq res (cons `("
\e$B$H@\B3
\e(B" ,to) res))
92 (setq res (cons `("
\e$B$?$k@\B3
\e(B" ,taru) res))
93 (setq res (cons `("
\e$B$9$k@\B3
\e(B" ,suru) res))
94 (setq res (cons `("
\e$B8l44$N$_$GJ8@a
\e(B" ,ind) res))
97 ;; taken from tooltip.el
98 (defmacro anthy-region-active-p ()
99 "Value is non-nil if the region is currently active."
100 (if (string-match "^GNU" (emacs-version))
101 `(and transient-mark-mode mark-active)
104 (defun anthy-add-word-interactive ()
108 ((param '()) (res '())
109 (word (if (anthy-region-active-p)
110 (buffer-substring (region-beginning) (region-end))
113 (and (string= word "")
114 (setq word (read-from-minibuffer "
\e$BC18l
\e(B(
\e$B8l44$N$_
\e(B): ")))
115 (setq yomi (read-from-minibuffer (concat "
\e$BFI$_
\e(B (" word "): ")))
116 (setq cat (string-to-int
117 (read-from-minibuffer
118 "
\e$B%+%F%4%j!<
\e(B 1:
\e$B0lHLL>;l
\e(B 2:
\e$B$=$NB>$NL>;l
\e(B 3:
\e$B7AMF;l
\e(B 4:
\e$BI{;l
\e(B: ")))
120 (setq param (anthy-dic-get-noun-category word)))
122 (setq param (anthy-dic-get-special-noun-category word)))
124 (setq param (anthy-dic-get-adjective-category word)))
126 (setq param (anthy-dic-get-av-category word))))
128 (setq res (anthy-add-word yomi 1 word param)))
130 (message (concat word "(" yomi ")
\e$B$rEPO?$7$^$7$?
\e(B")))))