Mercurial > emacs
annotate lisp/international/skkdic-utl.el @ 23834:ce563c147515
Do string comparision of _NMAKE_VER.
author | Geoff Voelker <voelker@cs.washington.edu> |
---|---|
date | Tue, 08 Dec 1998 23:56:14 +0000 |
parents | 60bf060b9ab1 |
children |
rev | line source |
---|---|
17315
a3ca5e15c82a
Fix the format of the first line.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1 ;;; skkdic-utl.el --- Utility functions for handling SKK dictionary |
17052 | 2 |
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | |
18377
8b4a66c66dd6
Change copyright notice.
Richard M. Stallman <rms@gnu.org>
parents:
17315
diff
changeset
|
4 ;; Licensed to the Free Software Foundation. |
17052 | 5 |
6 ;; Keywords: mule, multilingual, Japanese, SKK | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
17071 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
17052 | 24 |
25 ;;; Commentary: | |
26 | |
27 ;; SKK is a free Japanese input method running on Mule created by | |
18645
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
28 ;; Masahiko Sato <masahiko@sato.riec.tohoku.ac.jp>. The Emacs Lisp |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
29 ;; library kkc.el provides a facility to convert a Japanese kana |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
30 ;; string to a kanji-kana-mixed string by using a SKK dictionary. |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
31 ;; |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
32 ;; This file provides a generic function to look up a SKK dictionary. |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
33 ;; |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
34 ;; The original SKK dictionary SKK-JISYO.L is converted to skkdic.el. |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
35 ;; We get entries of the dictionary in four variables (listed below) |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
36 ;; by loadig this file (or byte-compiled version skkdic.elc). |
17052 | 37 |
38 ;;; Code: | |
39 | |
18645
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
40 ;; The following four variables are set by loading skkdic.el[c]. |
17052 | 41 (defvar skkdic-okuri-ari nil |
18645
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
42 "Nested alist for OKURI-ARI entries of SKK dictionary.") |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
43 |
17052 | 44 (defvar skkdic-postfix nil |
18645
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
45 "Nested alist for SETSUBIJI (postfix) entries of SKK dictionary.") |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
46 |
17052 | 47 (defvar skkdic-prefix nil |
18645
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
48 "Nested alist SETTOUJI (prefix) entries of SKK dictionary.") |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
49 |
17052 | 50 (defvar skkdic-okuri-nasi nil |
18645
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
51 "Nested alist for OKURI-NASI entries of SKK dictionary.") |
17052 | 52 |
53 (defconst skkdic-okurigana-table | |
54 '((?$B$!(B . ?a) (?$B$"(B . ?a) (?$B$#(B . ?i) (?$B$$(B . ?i) (?$B$%(B . ?u) | |
55 (?$B$&(B . ?u) (?$B$'(B . ?e) (?$B$((B . ?e) (?$B$)(B . ?o) (?$B$*(B . ?o) | |
56 (?$B$+(B . ?k) (?$B$,(B . ?g) (?$B$-(B . ?k) (?$B$.(B . ?g) (?$B$/(B . ?k) | |
57 (?$B$0(B . ?g) (?$B$1(B . ?k) (?$B$2(B . ?g) (?$B$3(B . ?k) (?$B$4(B . ?g) | |
58 (?$B$5(B . ?s) (?$B$6(B . ?z) (?$B$7(B . ?s) (?$B$8(B . ?j) (?$B$9(B . ?s) | |
59 (?$B$:(B . ?z) (?$B$;(B . ?s) (?$B$<(B . ?z) (?$B$=(B . ?s) (?$B$>(B . ?z) | |
60 (?$B$?(B . ?t) (?$B$@(B . ?d) (?$B$A(B . ?t) (?$B$B(B . ?d) (?$B$C(B . ?t) | |
61 (?$B$D(B . ?t) (?$B$E(B . ?d) (?$B$F(B . ?t) (?$B$G(B . ?d) (?$B$H(B . ?t) (?$B$I(B . ?d) | |
62 (?$B$J(B . ?n) (?$B$K(B . ?n) (?$B$L(B . ?n) (?$B$M(B . ?n) (?$B$N(B . ?n) | |
63 (?$B$O(B . ?h) (?$B$P(B . ?b) (?$B$Q(B . ?p) (?$B$R(B . ?h) (?$B$S(B . ?b) | |
64 (?$B$T(B . ?p) (?$B$U(B . ?h) (?$B$V(B . ?b) (?$B$W(B . ?p) (?$B$X(B . ?h) | |
65 (?$B$Y(B . ?b) (?$B$Z(B . ?p) (?$B$[(B . ?h) (?$B$\(B . ?b) (?$B$](B . ?p) | |
66 (?$B$^(B . ?m) (?$B$_(B . ?m) (?$B$`(B . ?m) (?$B$a(B . ?m) (?$B$b(B . ?m) | |
67 (?$B$c(B . ?y) (?$B$d(B . ?y) (?$B$e(B . ?y) (?$B$f(B . ?y) (?$B$g(B . ?y) (?$B$h(B . ?y) | |
68 (?$B$i(B . ?r) (?$B$j(B . ?r) (?$B$k(B . ?r) (?$B$l(B . ?r) (?$B$m(B . ?r) | |
69 (?$B$o(B . ?w) (?$B$p(B . ?w) (?$B$q(B . ?w) (?$B$r(B . ?w) | |
70 (?$B$s(B . ?n) | |
18645
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
71 ) |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
72 "Alist of Okuriganas vs trailing ASCII letters in OKURI-ARI entry.") |
17052 | 73 |
74 (defun skkdic-merge-head-and-tail (heads tails postfix) | |
20736
60bf060b9ab1
(skkdic-jbytes): Variable deleted.
Kenichi Handa <handa@m17n.org>
parents:
18645
diff
changeset
|
75 (let ((min-len 2) |
17052 | 76 l) |
77 (while heads | |
78 (if (or (not postfix) | |
79 (>= (length (car heads)) min-len)) | |
80 (let ((tail tails)) | |
81 (while tail | |
82 (if (or postfix | |
83 (>= (length (car tail)) min-len)) | |
84 (setq l (cons (concat (car heads) (car tail)) l))) | |
85 (setq tail (cdr tail))))) | |
86 (setq heads (cdr heads))) | |
87 l)) | |
88 | |
89 (defconst skkdic-jisx0208-hiragana-block (nth 1 (split-char ?$B$"(B))) | |
90 | |
18645
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
91 (defun skkdic-lookup-key (seq len &optional postfix prefer-noun) |
17052 | 92 "Return a list of conversion string for sequence SEQ of length LEN. |
93 | |
94 SEQ is a vector of Kana characters to be converted by SKK dictionary. | |
95 If LEN is shorter than the length of KEYSEQ, the first LEN keys in SEQ | |
96 are took into account. | |
97 | |
18645
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
98 Optional 3rd arg POSTFIX non-nil means SETSUBIJI (postfix) are also |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
99 considered to find conversion strings. |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
100 |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
101 Optional 4th arg PREFER-NOUN non-nil means that the conversions |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
102 without okurigana are placed at the head of the returned list." |
17052 | 103 (or skkdic-okuri-nasi |
104 (condition-case err | |
105 (load-library "skk/skkdic") | |
106 (error (ding) | |
107 (with-output-to-temp-buffer "*Help*" | |
108 (princ "The library `skkdic' can't be loaded. | |
109 | |
110 The most common case is that you have not yet installed the library | |
111 included in LEIM (Libraries of Emacs Input Method) which is | |
112 distributed separately from Emacs. | |
113 | |
114 LEIM is available from the same ftp directory as Emacs.")) | |
115 (signal (car err) (cdr err))))) | |
116 | |
117 (let ((vec (make-vector len 0)) | |
118 (i 0) | |
119 entry) | |
120 ;; At first, generate vector VEC from SEQ for looking up SKK | |
121 ;; alists. Nth element in VEC corresponds to Nth element in SEQ. | |
122 ;; The values are decided as follows. | |
123 ;; If SEQ[N] is `$B!<(B', VEC[N] is 0, | |
18645
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
124 ;; else if SEQ[N] is a Hiragana character, VEC[N] is: |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
125 ;; ((The 2nd position code of SEQ[N]) - 32), |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
126 ;; else VEC[N] is 128. |
17052 | 127 (while (< i len) |
128 (let ((ch (aref seq i)) | |
129 elts) | |
130 (if (= ch ?$B!<(B) | |
131 (aset vec i 0) | |
132 (setq elts (split-char ch)) | |
133 (if (and (eq (car elts) 'japanese-jisx0208) | |
134 (= (nth 1 elts) skkdic-jisx0208-hiragana-block)) | |
135 (aset vec i (- (nth 2 elts) 32)) | |
136 (aset vec i 128)))) | |
137 (setq i (1+ i))) | |
138 | |
139 ;; Search OKURI-NASI entries. | |
140 (setq entry (lookup-nested-alist vec skkdic-okuri-nasi len 0 t)) | |
141 (if (consp (car entry)) | |
142 (setq entry (copy-sequence (car entry))) | |
143 (setq entry nil)) | |
144 | |
145 (if postfix | |
146 ;; Search OKURI-NASI entries with postfixes. | |
147 (let ((break (max (- len (car skkdic-postfix)) 1)) | |
148 entry-head entry-postfix entry2) | |
149 (while (< break len) | |
150 (if (and (setq entry-head | |
151 (lookup-nested-alist vec skkdic-okuri-nasi | |
152 break 0 t)) | |
153 (consp (car entry-head)) | |
154 (setq entry-postfix | |
155 (lookup-nested-alist vec skkdic-postfix | |
156 len break t)) | |
157 (consp (car entry-postfix)) | |
158 (setq entry2 (skkdic-merge-head-and-tail | |
159 (car entry-head) (car entry-postfix) t))) | |
160 (if entry | |
161 (nconc entry entry2) | |
162 (setq entry entry2))) | |
163 (setq break (1+ break))))) | |
164 | |
165 ;; Search OKURI-NASI entries with prefixes. | |
166 (let ((break (min (car skkdic-prefix) (- len 2))) | |
167 entry-prefix entry-tail entry2) | |
168 (while (> break 0) | |
169 (if (and (setq entry-prefix | |
170 (lookup-nested-alist vec skkdic-prefix break 0 t)) | |
171 (consp (car entry-prefix)) | |
172 (setq entry-tail | |
173 (lookup-nested-alist vec skkdic-okuri-nasi len break t)) | |
174 (consp (car entry-tail)) | |
175 (setq entry2 (skkdic-merge-head-and-tail | |
176 (car entry-prefix) (car entry-tail) nil))) | |
18645
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
177 (progn |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
178 (if entry |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
179 (nconc entry entry2) |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
180 (setq entry entry2)))) |
17052 | 181 (setq break (1- break)))) |
182 | |
183 ;; Search OKURI-ARI entries. | |
184 (let ((okurigana (assq (aref seq (1- len)) skkdic-okurigana-table)) | |
185 orig-element entry2) | |
186 (if okurigana | |
187 (progn | |
188 (setq orig-element (aref vec (1- len))) | |
189 (aset vec (1- len) (- (cdr okurigana))) | |
190 (if (and (setq entry2 (lookup-nested-alist vec skkdic-okuri-ari | |
191 len 0 t)) | |
192 (consp (car entry2))) | |
193 (progn | |
194 (setq entry2 (copy-sequence (car entry2))) | |
195 (let ((l entry2) | |
196 (okuri (char-to-string (aref seq (1- len))))) | |
197 (while l | |
198 (setcar l (concat (car l) okuri)) | |
199 (setq l (cdr l))) | |
200 (if entry | |
18645
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
201 (if prefer-noun |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
202 (nconc entry entry2) |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
203 (setq entry2 (nreverse entry2)) |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
204 (nconc entry2 entry) |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
205 (setq entry entry2)) |
d290e793b965
(skkdic-okuri-ari): Doc-string
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
206 (setq entry (nreverse entry2)))))) |
17052 | 207 (aset vec (1- len) orig-element)))) |
208 | |
209 entry)) | |
210 | |
211 ;; | |
212 (provide 'skkdic-utl) | |
213 | |
214 ;; skkdic-utl.el ends here |