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