annotate lisp/international/ja-dic-utl.el @ 84143:3d8e7284e76a

Move to ../doc/emacs/, misc/
author Glenn Morris <rgm@gnu.org>
date Thu, 06 Sep 2007 04:35:27 +0000
parents 2daf9c28b3a4
children b6fdfff4ae81 f55f9811f5d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 36682
diff changeset
1 ;;; ja-dic-utl.el --- utilities for handling Japanese dictionary (SKK-JISYO.L)
31163
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2
74605
6ee41fdd69ff Update AIST copyright years.
Kenichi Handa <handa@m17n.org>
parents: 74544
diff changeset
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
75364
a0b90c38e931 Add 2007 to copyright.
Glenn Morris <rgm@gnu.org>
parents: 74605
diff changeset
4 ;; 2005, 2006, 2007
62274
c36561fe0657 Fix copyrights.
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
5 ;; National Institute of Advanced Industrial Science and Technology (AIST)
c36561fe0657 Fix copyrights.
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
6 ;; Registration Number H14PRO021
31163
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
7
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
8 ;; Keywords: mule, multilingual, Japanese
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
9
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
11
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
78310
2daf9c28b3a4 Restore comma mistakenly removed in last change.
Glenn Morris <rgm@gnu.org>
parents: 78301
diff changeset
14 ;; the Free Software Foundation; either version 3, or (at your option)
31163
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
15 ;; any later version.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
16
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
21
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62274
diff changeset
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62274
diff changeset
25 ;; Boston, MA 02110-1301, USA.
31163
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
26
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
27 ;;; Commentary:
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
28
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
29 ;; This file provides a generic function to look up a Japanese
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
30 ;; dictionary of SKK format.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
31 ;;
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
32 ;; SKK is a free Japanese input method running on Mule created by
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
33 ;; Masahiko Sato <masahiko@sato.riec.tohoku.ac.jp>. The Emacs Lisp
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
34 ;; library kkc.el provides a facility to convert a Japanese kana
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
35 ;; string to a kanji-kana-mixed string by using SKK's dictionary.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
36 ;;
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
37 ;; The original SKK dictionary SKK-JISYO.L is converted to ja-dic.el
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
38 ;; by ja-dic-cnv.el. We get entries of the dictionary in four
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
39 ;; variables (listed below) by loading that file (or byte-compiled
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
40 ;; version ja-dic.elc).
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
41
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
42 ;;; Code:
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
43
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
44 ;; The following four variables are set by loading ja-dic.el[c].
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
45 (defvar skkdic-okuri-ari nil
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
46 "Nested alist for OKURI-ARI entries of SKK dictionary.")
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
47
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
48 (defvar skkdic-postfix nil
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
49 "Nested alist for SETSUBIJI (postfix) entries of SKK dictionary.")
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
50
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
51 (defvar skkdic-prefix nil
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
52 "Nested alist SETTOUJI (prefix) entries of SKK dictionary.")
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
53
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
54 (defvar skkdic-okuri-nasi nil
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
55 "Nested alist for OKURI-NASI entries of SKK dictionary.")
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
56
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
57 (defconst skkdic-okurigana-table
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
58 '((?$B$!(B . ?a) (?$B$"(B . ?a) (?$B$#(B . ?i) (?$B$$(B . ?i) (?$B$%(B . ?u)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
59 (?$B$&(B . ?u) (?$B$'(B . ?e) (?$B$((B . ?e) (?$B$)(B . ?o) (?$B$*(B . ?o)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
60 (?$B$+(B . ?k) (?$B$,(B . ?g) (?$B$-(B . ?k) (?$B$.(B . ?g) (?$B$/(B . ?k)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
61 (?$B$0(B . ?g) (?$B$1(B . ?k) (?$B$2(B . ?g) (?$B$3(B . ?k) (?$B$4(B . ?g)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
62 (?$B$5(B . ?s) (?$B$6(B . ?z) (?$B$7(B . ?s) (?$B$8(B . ?j) (?$B$9(B . ?s)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
63 (?$B$:(B . ?z) (?$B$;(B . ?s) (?$B$<(B . ?z) (?$B$=(B . ?s) (?$B$>(B . ?z)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
64 (?$B$?(B . ?t) (?$B$@(B . ?d) (?$B$A(B . ?t) (?$B$B(B . ?d) (?$B$C(B . ?t)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
65 (?$B$D(B . ?t) (?$B$E(B . ?d) (?$B$F(B . ?t) (?$B$G(B . ?d) (?$B$H(B . ?t) (?$B$I(B . ?d)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
66 (?$B$J(B . ?n) (?$B$K(B . ?n) (?$B$L(B . ?n) (?$B$M(B . ?n) (?$B$N(B . ?n)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
67 (?$B$O(B . ?h) (?$B$P(B . ?b) (?$B$Q(B . ?p) (?$B$R(B . ?h) (?$B$S(B . ?b)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
68 (?$B$T(B . ?p) (?$B$U(B . ?h) (?$B$V(B . ?b) (?$B$W(B . ?p) (?$B$X(B . ?h)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
69 (?$B$Y(B . ?b) (?$B$Z(B . ?p) (?$B$[(B . ?h) (?$B$\(B . ?b) (?$B$](B . ?p)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
70 (?$B$^(B . ?m) (?$B$_(B . ?m) (?$B$`(B . ?m) (?$B$a(B . ?m) (?$B$b(B . ?m)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
71 (?$B$c(B . ?y) (?$B$d(B . ?y) (?$B$e(B . ?y) (?$B$f(B . ?y) (?$B$g(B . ?y) (?$B$h(B . ?y)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
72 (?$B$i(B . ?r) (?$B$j(B . ?r) (?$B$k(B . ?r) (?$B$l(B . ?r) (?$B$m(B . ?r)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
73 (?$B$o(B . ?w) (?$B$p(B . ?w) (?$B$q(B . ?w) (?$B$r(B . ?w)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
74 (?$B$s(B . ?n)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
75 )
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
76 "Alist of Okuriganas vs trailing ASCII letters in OKURI-ARI entry.")
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
77
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
78 (defun skkdic-merge-head-and-tail (heads tails postfix)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
79 (let ((min-len 2)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
80 l)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
81 (while heads
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
82 (if (or (not postfix)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
83 (>= (length (car heads)) min-len))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
84 (let ((tail tails))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
85 (while tail
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
86 (if (or postfix
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
87 (>= (length (car tail)) min-len))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
88 (setq l (cons (concat (car heads) (car tail)) l)))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
89 (setq tail (cdr tail)))))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
90 (setq heads (cdr heads)))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
91 l))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
92
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
93 (defconst skkdic-jisx0208-hiragana-block (nth 1 (split-char ?$B$"(B)))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
94
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
95 (defun skkdic-lookup-key (seq len &optional postfix prefer-noun)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
96 "Return a list of conversion string for sequence SEQ of length LEN.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
97
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
98 SEQ is a vector of Kana characters to be converted by SKK dictionary.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
99 If LEN is shorter than the length of KEYSEQ, the first LEN keys in SEQ
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
100 are took into account.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
101
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
102 Optional 3rd arg POSTFIX non-nil means SETSUBIJI (postfix) are also
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
103 considered to find conversion strings.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
104
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
105 Optional 4th arg PREFER-NOUN non-nil means that the conversions
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
106 without okurigana are placed at the head of the returned list."
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
107 (or skkdic-okuri-nasi
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
108 (condition-case err
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
109 (load-library "ja-dic/ja-dic")
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
110 (error (ding)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
111 (with-output-to-temp-buffer "*Help*"
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
112 (princ "The library `ja-dic' can't be loaded.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
113
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
114 The most common case is that you have not yet installed the library
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
115 included in LEIM (Libraries of Emacs Input Method) which is
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
116 distributed separately from Emacs.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
117
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
118 LEIM is available from the same ftp directory as Emacs."))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
119 (signal (car err) (cdr err)))))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
120
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
121 (let ((vec (make-vector len 0))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
122 (i 0)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
123 entry)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
124 ;; At first, generate vector VEC from SEQ for looking up SKK
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
125 ;; alists. Nth element in VEC corresponds to Nth element in SEQ.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
126 ;; The values are decided as follows.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
127 ;; If SEQ[N] is `$B!<(B', VEC[N] is 0,
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
128 ;; else if SEQ[N] is a Hiragana character, VEC[N] is:
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
129 ;; ((The 2nd position code of SEQ[N]) - 32),
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
130 ;; else VEC[N] is 128.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
131 (while (< i len)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
132 (let ((ch (aref seq i))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
133 elts)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
134 (if (= ch ?$B!<(B)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
135 (aset vec i 0)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
136 (setq elts (split-char ch))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
137 (if (and (eq (car elts) 'japanese-jisx0208)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
138 (= (nth 1 elts) skkdic-jisx0208-hiragana-block))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
139 (aset vec i (- (nth 2 elts) 32))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
140 (aset vec i 128))))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
141 (setq i (1+ i)))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
142
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
143 ;; Search OKURI-NASI entries.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
144 (setq entry (lookup-nested-alist vec skkdic-okuri-nasi len 0 t))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
145 (if (consp (car entry))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
146 (setq entry (copy-sequence (car entry)))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
147 (setq entry nil))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
148
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
149 (if postfix
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
150 ;; Search OKURI-NASI entries with postfixes.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
151 (let ((break (max (- len (car skkdic-postfix)) 1))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
152 entry-head entry-postfix entry2)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
153 (while (< break len)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
154 (if (and (setq entry-head
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
155 (lookup-nested-alist vec skkdic-okuri-nasi
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
156 break 0 t))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
157 (consp (car entry-head))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
158 (setq entry-postfix
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
159 (lookup-nested-alist vec skkdic-postfix
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
160 len break t))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
161 (consp (car entry-postfix))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
162 (setq entry2 (skkdic-merge-head-and-tail
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
163 (car entry-head) (car entry-postfix) t)))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
164 (if entry
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
165 (nconc entry entry2)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
166 (setq entry entry2)))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
167 (setq break (1+ break)))))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
168
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
169 ;; Search OKURI-NASI entries with prefixes.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
170 (let ((break (min (car skkdic-prefix) (- len 2)))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
171 entry-prefix entry-tail entry2)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
172 (while (> break 0)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
173 (if (and (setq entry-prefix
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
174 (lookup-nested-alist vec skkdic-prefix break 0 t))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
175 (consp (car entry-prefix))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
176 (setq entry-tail
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
177 (lookup-nested-alist vec skkdic-okuri-nasi len break t))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
178 (consp (car entry-tail))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
179 (setq entry2 (skkdic-merge-head-and-tail
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
180 (car entry-prefix) (car entry-tail) nil)))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
181 (progn
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
182 (if entry
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
183 (nconc entry entry2)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
184 (setq entry entry2))))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
185 (setq break (1- break))))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
186
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
187 ;; Search OKURI-ARI entries.
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
188 (let ((okurigana (assq (aref seq (1- len)) skkdic-okurigana-table))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
189 orig-element entry2)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
190 (if okurigana
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
191 (progn
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
192 (setq orig-element (aref vec (1- len)))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
193 (aset vec (1- len) (- (cdr okurigana)))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
194 (if (and (setq entry2 (lookup-nested-alist vec skkdic-okuri-ari
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
195 len 0 t))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
196 (consp (car entry2)))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
197 (progn
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
198 (setq entry2 (copy-sequence (car entry2)))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
199 (let ((l entry2)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
200 (okuri (char-to-string (aref seq (1- len)))))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
201 (while l
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
202 (setcar l (concat (car l) okuri))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
203 (setq l (cdr l)))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
204 (if entry
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
205 (if prefer-noun
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
206 (nconc entry entry2)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
207 (setq entry2 (nreverse entry2))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
208 (nconc entry2 entry)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
209 (setq entry entry2))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
210 (setq entry (nreverse entry2))))))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
211 (aset vec (1- len) orig-element))))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
212
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
213 entry))
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
214
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
215 ;;
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
216 (provide 'ja-dic-utl)
35ee2cc673cd Renamed from skkdic-utl.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
217
36682
8adcbdf9202c Add coding: tag in Local Variable: section.
Kenichi Handa <handa@m17n.org>
parents: 31163
diff changeset
218 ;; Local Variables:
8adcbdf9202c Add coding: tag in Local Variable: section.
Kenichi Handa <handa@m17n.org>
parents: 31163
diff changeset
219 ;; coding: iso-2022-7bit
8adcbdf9202c Add coding: tag in Local Variable: section.
Kenichi Handa <handa@m17n.org>
parents: 31163
diff changeset
220 ;; End:
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 36682
diff changeset
221
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 38414
diff changeset
222 ;;; arch-tag: df2218fa-469c-40f6-bace-7f89a053f9c0
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 36682
diff changeset
223 ;;; ja-dic-utl.el ends here