1 ;;; ids-find.el --- search utility based on Ideographic-structures ;; -*- coding: utf-8-mcs-er -*-
3 ;; Copyright (C) 2002, 2003, 2005, 2006, 2007, 2017, 2020 MORIOKA Tomohiko
5 ;; Author: MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
6 ;; Keywords: Kanji, Ideographs, search, IDS, CHISE, UCS, Unicode
8 ;; This file is a part of CHISE-IDS.
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with this program; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 (defun ids-index-store-char (product component)
28 (let ((ret (get-char-attribute component 'ideographic-products)))
29 (unless (memq product ret)
30 (put-char-attribute component 'ideographic-products
32 (when (setq ret (char-feature component 'ideographic-structure))
33 (ids-index-store-structure product ret)))
36 (defun ids-index-store-structure (product structure)
38 (dolist (cell (cdr structure))
40 (setq cell (plist-get cell :char)))
41 (cond ((characterp cell)
42 (ids-index-store-char product cell))
43 ((setq ret (assq 'ideographic-structure cell))
44 (ids-index-store-structure product (cdr ret)))
45 ((setq ret (find-char cell))
46 (ids-index-store-char product ret))
50 (defun ids-update-index (&optional in-memory)
54 (ids-index-store-structure c v)
56 'ideographic-structure)
59 (ids-index-store-structure c v)
61 'ideographic-structure@apparent)
63 (save-char-attribute-table 'ideographic-products)))
66 (mount-char-attribute-table 'ideographic-products)
69 (defun ids-find-all-products (char)
71 (dolist (cell (char-feature char 'ideographic-products))
72 (unless (memq cell dest)
73 (setq dest (cons cell dest)))
74 (setq dest (union dest (ids-find-all-products cell))))
77 (defun of-component-features ()
79 (dolist (feature (char-attribute-list))
80 (when (string-match "^<-.*[@/]component\\(/[^*/]+\\)*$"
81 (symbol-name feature))
83 (list* '<-mistakable '->mistakable
86 '<-original '->original
90 (defun to-component-features ()
92 (dolist (feature (char-attribute-list))
93 (when (string-match "^->.*[@/]component\\(/[^*/]+\\)*$"
94 (symbol-name feature))
99 (defun char-component-variants (char)
100 (let ((dest (list char))
102 (dolist (feature (to-component-features))
103 (if (setq ret (get-char-attribute char feature))
105 (setq dest (union dest (char-component-variants c))))))
107 ;; ((setq ret (some (lambda (feature)
108 ;; (get-char-attribute char feature))
109 ;; (to-component-features)))
111 ;; (setq dest (union dest (char-component-variants c))))
113 ((setq ret (get-char-attribute char '->ucs-unified))
114 (setq dest (cons char ret))
116 (setq dest (union dest
117 (some (lambda (feature)
118 (get-char-attribute c feature))
119 (of-component-features))
122 ((and (setq ret (get-char-attribute char '=>ucs))
123 (setq uchr (decode-char '=ucs ret)))
124 (setq dest (cons uchr (char-variants uchr)))
126 (setq dest (union dest
127 (some (lambda (feature)
128 (get-char-attribute c feature))
129 (of-component-features))
135 (unless (memq c dest)
136 (setq dest (cons c dest)))
139 (some (lambda (feature)
140 (char-feature c feature))
141 (of-component-features))
149 (defun ideographic-products-find (&rest components)
150 (if (stringp (car components))
151 (setq components (string-to-char-list (car components))))
153 (dolist (variant (char-component-variants (car components)))
156 (get-char-attribute variant 'ideographic-products))))
159 (setq components (cdr components)))
161 (dolist (variant (char-component-variants (car components)))
164 (get-char-attribute variant 'ideographic-products))))
165 (setq dest (intersection dest products)))
168 (defun ideograph-find-products-with-variants (components &optional ignored-chars)
169 (if (stringp components)
170 (setq components (string-to-char-list components)))
172 (dolist (variant (char-component-variants (car components)))
176 (get-char-attribute variant 'ideographic-products)
180 (setq components (cdr components)))
182 (dolist (variant (char-component-variants (car components)))
186 (get-char-attribute variant 'ideographic-products)
188 (setq dest (intersection dest products)))
191 (defun ideograph-find-products (components &optional ignored-chars)
192 (if (stringp components)
193 (setq components (string-to-char-list components)))
195 ;; (dolist (variant (char-component-variants (car components)))
198 ;; (get-char-attribute variant 'ideographic-products))))
199 ;; (setq dest products)
200 (setq dest (get-char-attribute (car components) 'ideographic-products))
202 (setq components (cdr components)))
203 ;; (setq products nil)
204 ;; (dolist (variant (char-component-variants (car components)))
207 ;; (get-char-attribute variant 'ideographic-products))))
208 (setq products (get-char-attribute (car components) 'ideographic-products))
209 (setq dest (intersection dest products)))
213 (defun ideographic-structure-char= (c1 c2)
216 (let ((m1 (char-ucs c1))
220 (memq c1 (char-component-variants c2)))))))
222 (defun ideographic-structure-member-compare-components (component s-component)
224 (cond ((char-ref= component s-component #'ideographic-structure-char=))
226 (if (setq ret (assq 'ideographic-structure s-component))
227 (ideographic-structure-member component (cdr ret))))
228 ((setq ret (get-char-attribute s-component 'ideographic-structure))
229 (ideographic-structure-member component ret)))))
232 (defun ideographic-structure-member (component structure)
233 "Return non-nil if COMPONENT is included in STRUCTURE."
234 (or (memq component structure)
236 (setq structure (cdr structure))
237 (ideographic-structure-member-compare-components
238 component (car structure)))
240 (setq structure (cdr structure))
241 (ideographic-structure-member-compare-components
242 component (car structure)))
244 (setq structure (cdr structure))
246 (ideographic-structure-member-compare-components
247 component (car structure))))))
251 (defun ideographic-structure-repertoire-p (structure components)
252 "Return non-nil if STRUCTURE can be constructed by a subset of COMPONENTS."
254 (let (ret s-component)
256 (while (setq structure (cdr structure))
257 (setq s-component (car structure))
258 (unless (characterp s-component)
259 (if (setq ret (find-char s-component))
260 (setq s-component ret)))
263 (if (setq ret (assq 'ideographic-structure s-component))
264 (ideographic-structure-repertoire-p
265 (cdr ret) components)))
266 ((member* s-component components
267 :test #'ideographic-structure-char=))
269 (get-char-attribute s-component
270 'ideographic-structure))
271 (ideographic-structure-repertoire-p ret components)))
276 (defvar ids-find-result-buffer "*ids-chars*")
278 (defun ids-find-format-line (c v)
279 (format "%c\t%s\t%s\n"
281 (or (let ((ucs (or (char-ucs c)
282 (encode-char c 'ucs))))
284 (cond ((<= ucs #xFFFF)
285 (format " U+%04X" ucs))
287 (format "U-%08X" ucs)))))
289 (or (ideographic-structure-to-ids v)
292 (defun ids-insert-chars-including-components* (components
293 &optional level ignored-chars)
297 (dolist (c (sort (copy-list (ideograph-find-products components
300 (if (setq as (char-total-strokes a))
301 (if (setq bs (char-total-strokes b))
303 (ideograph-char< a b)
306 (ideograph-char< a b)))))
307 (unless (memq c ignored-chars)
308 (setq is (char-feature c 'ideographic-structure))
313 (insert (ids-find-format-line c is))
315 (ids-insert-chars-including-components*
316 (char-to-string c) (1+ level)
317 (cons c ignored-chars))))
322 (defun ids-insert-chars-including-components (components
323 &optional level ignored-chars)
328 (ids-insert-chars-including-components* components
329 level ignored-chars)))
331 (dolist (c ignored-chars)
332 (dolist (vc (char-component-variants c))
333 (unless (memq vc ignored-chars)
334 (when (setq is (get-char-attribute vc 'ideographic-structure))
339 (insert (ids-find-format-line vc is))
341 (ids-insert-chars-including-components*
342 (char-to-string vc) (1+ level)
343 (cons vc ignored-chars)))))))
344 (dolist (c (sort (copy-list (ideograph-find-products-with-variants
345 components ignored-chars))
347 (if (setq as (char-total-strokes a))
348 (if (setq bs (char-total-strokes b))
350 (ideograph-char< a b)
353 (ideograph-char< a b)))))
354 (unless (memq c ignored-chars)
355 (setq is (get-char-attribute c 'ideographic-structure))
360 (insert (ids-find-format-line c is))
362 (ids-insert-chars-including-components*
363 (char-to-string c) (1+ level)
364 (cons c ignored-chars))))
370 (defun ids-find-chars-including-components (components)
371 "Search Ideographs whose structures have COMPONENTS."
372 (interactive "sComponents : ")
373 (with-current-buffer (get-buffer-create ids-find-result-buffer)
374 (setq buffer-read-only nil)
376 (ids-insert-chars-including-components components 0 nil)
377 ;; (let ((ignored-chars
379 ;; (ids-insert-chars-including-components components 0 nil
380 ;; #'ideograph-find-products)))
382 ;; (setq rest ignored-chars)
383 ;; ;; (dolist (c rest)
384 ;; ;; (setq ignored-chars
385 ;; ;; (union ignored-chars
386 ;; ;; (ids-insert-chars-including-components
387 ;; ;; (list c) 0 ignored-chars
388 ;; ;; #'ideograph-find-products-with-variants))))
389 ;; (ids-insert-chars-including-components components 0 ignored-chars
390 ;; #'ideograph-find-products-with-variants))
391 (goto-char (point-min)))
392 (view-buffer ids-find-result-buffer))
395 (define-obsolete-function-alias 'ideographic-structure-search-chars
396 'ids-find-chars-including-components)
399 (defun ids-find-chars-covered-by-components (components)
400 "Search Ideographs which structures are consisted by subsets of COMPONENTS."
401 (interactive "sComponents: ")
402 (if (stringp components)
403 (setq components (string-to-char-list components)))
404 (with-current-buffer (get-buffer-create ids-find-result-buffer)
405 (setq buffer-read-only nil)
409 (when (ideographic-structure-repertoire-p v components)
410 (insert (ids-find-format-line c v))))
411 'ideographic-structure)
412 (goto-char (point-min)))
413 (view-buffer ids-find-result-buffer))
416 (defun ideographic-structure-merge-components-alist (ca1 ca2)
417 (let ((dest-alist ca1)
420 (if (setq ret (assq (car cell) dest-alist))
421 (setcdr ret (+ (cdr ret)(cdr cell)))
422 (setq dest-alist (cons cell dest-alist))))
425 (defun ideographic-structure-to-components-alist (structure)
426 (apply #'ideographic-structure-to-components-alist* structure))
428 (defun ideographic-structure-to-components-alist* (operator component1 component2
431 (let (dest-alist ret)
433 (cond ((characterp component1)
434 (unless (encode-char component1 'ascii)
435 (list (cons component1 1)))
437 ((setq ret (assq 'ideographic-structure component1))
438 (ideographic-structure-to-components-alist (cdr ret))
440 ((setq ret (find-char component1))
444 (ideographic-structure-merge-components-alist
446 (cond ((characterp component2)
447 (unless (encode-char component2 'ascii)
448 (list (cons component2 1)))
450 ((setq ret (assq 'ideographic-structure component2))
451 (ideographic-structure-to-components-alist (cdr ret))
453 ((setq ret (find-char component2))
456 (if (memq operator '(?\u2FF2 ?\u2FF3))
457 (ideographic-structure-merge-components-alist
459 (cond ((characterp component3)
460 (unless (encode-char component3 'ascii)
461 (list (cons component3 1)))
463 ((setq ret (assq 'ideographic-structure component3))
464 (ideographic-structure-to-components-alist (cdr ret))
466 ((setq ret (find-char component3))
471 (defun ids-find-merge-variables (ve1 ve2)
477 (let ((dest-alist ve1)
481 (setq cell (car rest))
482 (if (setq ret (assq (car cell) ve1))
483 (eq (cdr ret)(cdr cell))
484 (setq dest-alist (cons cell dest-alist))))
485 (setq rest (cdr rest)))
491 (defun ideographic-structure-equal (structure1 structure2)
492 (let (dest-alist ret)
493 (and (setq dest-alist (ideographic-structure-character=
494 (car structure1)(car structure2)))
495 (setq ret (ideographic-structure-character=
496 (nth 1 structure1)(nth 1 structure2)))
497 (setq dest-alist (ids-find-merge-variables dest-alist ret))
498 (setq ret (ideographic-structure-character=
499 (nth 2 structure1)(nth 2 structure2)))
500 (setq dest-alist (ids-find-merge-variables dest-alist ret))
501 (if (memq (car structure1) '(?\u2FF2 ?\u2FF3))
502 (and (setq ret (ideographic-structure-character=
503 (nth 3 structure1)(nth 3 structure2)))
504 (setq dest-alist (ids-find-merge-variables dest-alist ret)))
508 (defun ideographic-structure-character= (c1 c2)
510 (cond ((characterp c1)
511 (cond ((encode-char c1 'ascii)
515 (if (encode-char c2 'ascii)
519 ((setq ret2 (find-char c2))
522 ((setq ret2 (assq 'ideographic-structure c2))
523 (and (setq ret (get-char-attribute c1 'ideographic-structure))
524 (ideographic-structure-equal ret (cdr ret2)))
527 ((setq ret (assq 'ideographic-structure c1))
528 (cond ((characterp c2)
529 (if (encode-char c2 'ascii)
531 (and (setq ret2 (get-char-attribute c2 'ideographic-structure))
532 (ideographic-structure-equal (cdr ret) ret2)))
534 ((setq ret2 (find-char c2))
535 (and (setq ret2 (get-char-attribute ret2 'ideographic-structure))
536 (ideographic-structure-equal (cdr ret) ret2))
538 ((setq ret2 (assq 'ideographic-structure c2))
539 (ideographic-structure-equal (cdr ret)(cdr ret2))
542 ((setq ret (find-char c1))
543 (cond ((characterp c2)
544 (if (encode-char c2 'ascii)
548 ((setq ret2 (find-char c2))
551 ((setq ret2 (assq 'ideographic-structure c2))
552 (and (setq ret (get-char-attribute ret 'ideographic-structure))
553 (ideographic-structure-equal ret (cdr ret2))
557 (defun ideographic-structure-find-chars (structure)
558 (let ((comp-alist (ideographic-structure-to-components-alist structure))
561 (sort (mapcar (lambda (cell)
562 (if (setq ret (get-char-attribute
563 (car cell) 'ideographic-products))
564 (cons ret (length ret))
568 (< (cdr a)(cdr b))))))
569 (when (or (and (setq str
570 (get-char-attribute pc 'ideographic-structure))
571 (ideographic-structure-equal str structure))
573 (get-char-attribute pc 'ideographic-structure@apparent))
574 (ideographic-structure-equal str structure)))
575 (setq pl (cons pc pl))
580 (defun ideographic-char-count-components (char component)
583 (cond ((eq char component)
585 ((setq structure (get-char-attribute char 'ideographic-structure))
586 (dolist (cell (ideographic-structure-to-components-alist structure))
589 (if (eq (car cell) char)
591 (* (ideographic-char-count-components (car cell) component)
599 (defun ideographic-character-get-structure (character)
600 "Return ideographic-structure of CHARACTER.
601 CHARACTER can be a character or char-spec."
602 (mapcar (lambda (cell)
603 (or (and (listp cell)
607 (cond ((characterp character)
608 (get-char-attribute character 'ideographic-structure)
610 ((setq ret (assq 'ideographic-structure character))
613 ((setq ret (find-char character))
614 (get-char-attribute ret 'ideographic-structure)
618 (defun ideographic-char-match-component (char component)
619 "Return non-nil if character CHAR has COMPONENT in ideographic-structure.
620 COMPONENT can be a character or char-spec."
621 (or (ideographic-structure-character= char component)
622 (let ((str (ideographic-character-get-structure char)))
624 (or (ideographic-char-match-component (nth 1 str) component)
625 (ideographic-char-match-component (nth 2 str) component)
626 (if (memq (car str) '(?\u2FF2 ?\u2FF3))
627 (ideographic-char-match-component (nth 3 str) component)))))))
629 (defun ideographic-structure-char< (a b)
630 (let ((sa (get-char-attribute a 'ideographic-structure))
631 (sb (get-char-attribute b 'ideographic-structure))
635 (setq tsa (char-total-strokes a)
636 tsb (char-total-strokes b))
641 (ideograph-char< a b)))
645 (ideograph-char< a b))))
653 (setq tsa (char-total-strokes a)
654 tsb (char-total-strokes b))
659 (ideograph-char< a b)))
663 (ideograph-char< a b)))
668 (defun ideo-comp-tree-adjoin (tree char)
672 (while (and (not finished)
674 (setq cell (pop rest))
675 (cond ((ideographic-structure-character= char (car cell))
680 ((ideographic-char-match-component char (car cell))
682 (cons (cons (car cell)
683 (ideo-comp-tree-adjoin (cdr cell) char))
687 ((ideographic-char-match-component (car cell) char)
688 (setq included (cons cell included))
691 ;; (setq other (cons cell other))
694 (setq dest (cons cell dest))
700 (cons (cons char included)
704 (cons (list char) tree)
707 (defun ideographic-chars-to-is-a-tree (chars)
709 (dolist (char (sort (copy-list chars) #'ideographic-structure-char<))
710 (setq tree (ideo-comp-tree-adjoin tree char)))
713 (defun ids-find-chars-including-ids (structure)
714 (let (comp-alist comp-spec ret str rest)
716 ((characterp structure)
717 (setq rest (copy-list (get-char-attribute structure 'ideographic-products)))
719 ((setq ret (ideographic-structure-find-chars structure))
724 (copy-list (get-char-attribute pc 'ideographic-products)))))
727 (setq comp-alist (ideographic-structure-to-components-alist structure)
728 comp-spec (list (cons 'ideographic-structure structure)))
730 (sort (mapcar (lambda (cell)
731 (if (setq ret (get-char-attribute
732 (car cell) 'ideographic-products))
733 (cons ret (length ret))
737 (< (cdr a)(cdr b))))))
738 (when (and (every (lambda (cell)
739 (>= (ideographic-char-count-components pc (car cell))
742 (or (ideographic-char-match-component pc comp-spec)
743 (and (setq str (get-char-attribute pc 'ideographic-structure))
744 (ideographic-char-match-component
747 'ideographic-structure
748 (functional-ideographic-structure-to-apparent-structure
753 (ideographic-chars-to-is-a-tree rest)))
755 (defun functional-ideographic-structure-to-apparent-structure (structure)
756 (ideographic-structure-compare-functional-and-apparent
757 structure nil 'conversion-only))
760 (defun ideographic-structure-compact (structure)
761 (let ((rest structure)
765 (setq cell (pop rest))
768 (cond ((setq ret (assq 'ideographic-structure cell))
775 (if (setq ret (ideographic-structure-find-chars sub))
777 (list (cons 'ideographic-structure sub))))
779 (setq dest (cons cell dest)))
782 (defun ideographic-structure-compare-functional-and-apparent (structure
785 (let (enc enc-str enc2-str enc3-str new-str new-str-c f-res a-res ret code)
787 ((eq (car structure) ?⿸)
788 (setq enc (nth 1 structure))
790 (cond ((characterp enc)
791 (get-char-attribute enc 'ideographic-structure)
794 (cdr (assq 'ideographic-structure enc))
797 ((eq (car enc-str) ?⿰)
798 (unless conversion-only
799 (setq f-res (ids-find-chars-including-ids enc-str)))
800 (setq new-str (list ?⿱
804 (if (setq ret (ideographic-structure-find-chars new-str))
806 (list (cons 'ideographic-structure new-str))))
808 (list ?⿰ (nth 1 enc-str) new-str-c)
809 (setq a-res (ids-find-chars-including-ids new-str))
814 (list ?⿰ (nth 1 enc-str) new-str-c)
817 ((and (eq (car enc-str) ?⿲)
818 (memq (char-ucs (nth 1 enc-str)) '(#x4EBB #x2E85))
819 (eq (nth 2 enc-str) ?丨))
820 (unless conversion-only
821 (setq f-res (ids-find-chars-including-ids enc-str)))
822 (setq new-str (list ?⿱
826 (if (setq ret (ideographic-structure-find-chars new-str))
828 (list (cons 'ideographic-structure new-str))))
830 (list ?⿰ (decode-char '=big5-cdp #x8B7A) new-str-c)
831 (setq a-res (ids-find-chars-including-ids new-str))
836 (list ?⿰ (decode-char '=big5-cdp #x8B7A) new-str-c)
839 ((eq (car enc-str) ?⿱)
840 (unless conversion-only
841 (setq f-res (ids-find-chars-including-ids enc-str)))
845 ((characterp (nth 2 enc-str))
846 (if (or (memq (encode-char (nth 2 enc-str) '=>ucs@component)
847 '(#x20087 #x5382 #x4E06))
848 (eq (encode-char (nth 2 enc-str) '=>ucs@iwds-1)
850 (eq (encode-char (nth 2 enc-str) '=ucs-itaiji-001)
852 (eq (encode-char (nth 2 enc-str) '=big5-cdp)
854 (eq (encode-char (nth 2 enc-str) '=>big5-cdp)
856 (eq (encode-char (nth 2 enc-str) '=big5-cdp)
858 (eq (or (encode-char (nth 2 enc-str) '=>big5-cdp)
859 (encode-char (nth 2 enc-str) '=big5-cdp-itaiji-001))
861 (eq (car (get-char-attribute (nth 2 enc-str)
862 'ideographic-structure))
866 ((eq (car (cdr (assq 'ideographic-structure (nth 2 enc-str))))
874 (if (setq ret (ideographic-structure-find-chars new-str))
876 (list (cons 'ideographic-structure new-str))))
878 (list ?⿱ (nth 1 enc-str) new-str-c)
879 (setq a-res (ids-find-chars-including-ids new-str))
884 (list ?⿱ (nth 1 enc-str) new-str-c)
885 (if (eq (car new-str) ?⿸)
889 ((eq (car enc-str) ?⿸)
890 (unless conversion-only
891 (setq f-res (ids-find-chars-including-ids enc-str)))
892 (setq new-str (list (cond
893 ((characterp (nth 2 enc-str))
894 (if (memq (char-ucs (nth 2 enc-str))
904 (if (setq ret (ideographic-structure-find-chars new-str))
906 (list (cons 'ideographic-structure new-str))))
908 (list ?⿸ (nth 1 enc-str) new-str-c)
909 (setq a-res (ids-find-chars-including-ids new-str))
914 (list ?⿸ (nth 1 enc-str) new-str-c)
915 (if (eq (car new-str) ?⿰)
920 ((eq (car structure) ?⿹)
921 (setq enc (nth 1 structure))
923 (cond ((characterp enc)
924 (get-char-attribute enc 'ideographic-structure)
927 (cdr (assq 'ideographic-structure enc))
930 ((eq (car enc-str) ?⿰)
931 (unless conversion-only
932 (setq f-res (ids-find-chars-including-ids enc-str)))
933 (setq new-str (list ?⿱
937 (if (setq ret (ideographic-structure-find-chars new-str))
939 (list (cons 'ideographic-structure new-str))))
941 (list ?⿰ new-str-c (nth 2 enc-str))
942 (setq a-res (ids-find-chars-including-ids new-str))
947 (list ?⿰ new-str-c (nth 2 enc-str))
951 ((eq (get-char-attribute (car structure) '=ucs-itaiji-001) #x2FF6)
952 (setq enc (nth 1 structure))
954 (cond ((characterp enc)
955 (get-char-attribute enc 'ideographic-structure)
958 (cdr (assq 'ideographic-structure enc))
961 ((eq (car enc-str) ?⿺)
962 (unless conversion-only
963 (setq f-res (ids-find-chars-including-ids enc-str)))
964 (setq new-str (list ?⿱
968 (if (setq ret (ideographic-structure-find-chars new-str))
970 (list (cons 'ideographic-structure new-str))))
972 (list ?⿺ new-str-c (nth 2 enc-str))
973 (setq a-res (ids-find-chars-including-ids new-str))
978 (list ?⿺ new-str-c (nth 2 enc-str))
981 ((eq (car enc-str) ?⿱)
982 (unless conversion-only
983 (setq f-res (ids-find-chars-including-ids enc-str)))
984 (setq new-str (list ?⿰
988 (if (setq ret (ideographic-structure-find-chars new-str))
990 (list (cons 'ideographic-structure new-str))))
992 (list ?⿱ new-str-c (nth 2 enc-str))
993 (setq a-res (ids-find-chars-including-ids new-str))
998 (list ?⿱ new-str-c (nth 2 enc-str))
1001 ((eq (car enc-str) ?⿰)
1002 (unless conversion-only
1003 (setq f-res (ids-find-chars-including-ids enc-str)))
1004 (setq new-str (list ?⿱
1008 (if (setq ret (ideographic-structure-find-chars new-str))
1010 (list (cons 'ideographic-structure new-str))))
1012 (list ?⿰ new-str-c (nth 2 enc-str))
1013 (setq a-res (ids-find-chars-including-ids new-str))
1018 (list ?⿰ new-str-c (nth 2 enc-str))
1023 ((eq (car structure) ?⿴)
1024 (setq enc (nth 1 structure))
1026 (cond ((characterp enc)
1027 (get-char-attribute enc 'ideographic-structure)
1030 (cdr (assq 'ideographic-structure enc))
1033 ((eq (car enc-str) ?⿱)
1035 ((and (characterp (nth 2 enc-str))
1036 (or (memq (char-ucs (nth 2 enc-str)) '(#x56D7 #x5F51 #x897F))
1037 (eq (char-feature (nth 2 enc-str) '=>big5-cdp)
1039 (unless conversion-only
1040 (setq f-res (ids-find-chars-including-ids enc-str)))
1041 (setq new-str (list ?⿴
1045 (if (setq ret (ideographic-structure-find-chars new-str))
1047 (list (cons 'ideographic-structure new-str))))
1049 (list ?⿱ (nth 1 enc-str) new-str-c)
1050 (setq a-res (ids-find-chars-including-ids new-str))
1055 (list ?⿱ (nth 1 enc-str) new-str-c)
1058 ((and (characterp (nth 2 enc-str))
1059 (eq (char-ucs (nth 2 enc-str)) #x51F5))
1060 (unless conversion-only
1061 (setq f-res (ids-find-chars-including-ids enc-str)))
1062 (setq new-str (list ?⿶
1066 (if (setq ret (ideographic-structure-find-chars new-str))
1068 (list (cons 'ideographic-structure new-str))))
1070 (list ?⿱ (nth 1 enc-str) new-str-c)
1071 (setq a-res (ids-find-chars-including-ids new-str))
1076 (list ?⿱ (nth 1 enc-str) new-str-c)
1079 ((and (characterp (nth 1 enc-str))
1080 (eq (char-feature (nth 1 enc-str) '=>ucs@component)
1082 (unless conversion-only
1083 (setq f-res (ids-find-chars-including-ids enc-str)))
1084 (setq new-str (list ?⿵
1088 (if (setq ret (ideographic-structure-find-chars new-str))
1090 (list (cons 'ideographic-structure new-str))))
1092 (list ?⿱ new-str-c (nth 2 enc-str))
1093 (setq a-res (ids-find-chars-including-ids new-str))
1098 (list ?⿱ new-str-c (nth 2 enc-str))
1102 (unless conversion-only
1103 (setq f-res (ids-find-chars-including-ids enc-str)))
1104 (setq new-str (list ?⿱ (nth 2 structure) (nth 2 enc-str)))
1106 (if (setq ret (ideographic-structure-find-chars new-str))
1108 (list (cons 'ideographic-structure new-str))))
1110 (list ?⿱ (nth 1 enc-str) new-str-c)
1111 (setq a-res (ids-find-chars-including-ids new-str))
1116 (list ?⿱ (nth 1 enc-str) new-str-c)
1120 ((eq (car enc-str) ?⿳)
1122 ((and (characterp (nth 2 enc-str))
1123 (eq (char-ucs (nth 2 enc-str)) #x56D7))
1124 (unless conversion-only
1125 (setq f-res (ids-find-chars-including-ids enc-str)))
1126 (setq new-str (list ?⿴ (nth 2 enc-str) (nth 2 structure)))
1128 (if (setq ret (ideographic-structure-find-chars new-str))
1130 (list (cons 'ideographic-structure new-str))))
1131 (setq new-str (list ?⿱ (nth 1 enc-str) new-str-c))
1133 (if (setq ret (ideographic-structure-find-chars new-str))
1135 (list (cons 'ideographic-structure new-str))))
1137 (list ?⿱ new-str-c (nth 3 enc-str))
1138 (setq a-res (ids-find-chars-including-ids new-str))
1143 (list ?⿱ new-str-c (nth 3 enc-str))
1146 ((and (characterp (nth 2 enc-str))
1147 (eq (char-ucs (nth 2 enc-str)) #x5196))
1148 (unless conversion-only
1149 (setq f-res (ids-find-chars-including-ids enc-str)))
1150 (setq new-str (list ?⿱ (nth 1 enc-str) (nth 2 enc-str)))
1152 (if (setq ret (ideographic-structure-find-chars new-str))
1154 (list (cons 'ideographic-structure new-str))))
1155 (setq new-str (list ?⿱ new-str-c (nth 2 structure)))
1157 (if (setq ret (ideographic-structure-find-chars new-str))
1159 (list (cons 'ideographic-structure new-str))))
1161 (list ?⿱ new-str-c (nth 3 enc-str))
1162 (setq a-res (ids-find-chars-including-ids new-str))
1167 (list ?⿱ new-str-c (nth 3 enc-str))
1170 ((and (characterp (nth 2 enc-str))
1171 (or (eq (encode-char (nth 2 enc-str) '=>big5-cdp)
1173 (eq (encode-char (nth 2 enc-str) '=>gt-k)
1175 (eq (char-ucs (nth 2 enc-str)) #x2008A)))
1176 (unless conversion-only
1177 (setq f-res (ids-find-chars-including-ids enc-str)))
1178 (setq new-str (list ?⿱ (nth 2 structure) (nth 2 enc-str)))
1180 (if (setq ret (ideographic-structure-find-chars new-str))
1182 (list (cons 'ideographic-structure new-str))))
1183 (setq new-str (list ?⿸ new-str-c (nth 3 enc-str)))
1185 (if (setq ret (ideographic-structure-find-chars new-str))
1187 (list (cons 'ideographic-structure new-str))))
1189 (list ?⿱ (nth 1 enc-str) new-str-c)
1190 (setq a-res (ids-find-chars-including-ids new-str))
1195 (list ?⿱ (nth 1 enc-str) new-str-c)
1199 (unless conversion-only
1200 (setq f-res (ids-find-chars-including-ids enc-str)))
1201 (setq new-str (list ?⿻ (nth 2 enc-str) (nth 2 structure)))
1203 (if (setq ret (ideographic-structure-find-chars new-str))
1205 (list (cons 'ideographic-structure new-str))))
1206 (setq new-str (list ?⿱ (nth 1 enc-str) new-str-c))
1208 (if (setq ret (ideographic-structure-find-chars new-str))
1210 (list (cons 'ideographic-structure new-str))))
1212 (list ?⿱ new-str-c (nth 3 enc-str))
1213 (setq a-res (ids-find-chars-including-ids new-str))
1218 (list ?⿱ new-str-c (nth 3 enc-str))
1222 ((eq (car enc-str) ?⿰)
1224 ((equal (nth 1 enc-str)(nth 2 enc-str))
1225 (unless conversion-only
1226 (setq f-res (ids-find-chars-including-ids enc-str)))
1227 (setq new-str (list ?⿲
1232 (list (cons 'ideographic-structure new-str)))
1235 (setq a-res (ids-find-chars-including-ids new-str))
1244 (unless conversion-only
1245 (setq f-res (ids-find-chars-including-ids enc-str)))
1246 (setq new-str (list ?⿰
1250 (if (setq ret (ideographic-structure-find-chars new-str))
1252 (list (cons 'ideographic-structure new-str))))
1254 (list ?⿰ (nth 1 enc-str) new-str-c)
1255 (setq a-res (ids-find-chars-including-ids new-str))
1260 (list ?⿰ (nth 1 enc-str) new-str-c)
1266 ((eq (car structure) ?⿶)
1267 (setq enc (nth 1 structure))
1269 (cond ((characterp enc)
1270 (get-char-attribute enc 'ideographic-structure)
1273 (cdr (assq 'ideographic-structure enc))
1276 ((eq (car enc-str) ?⿱)
1277 (setq enc2-str (ideographic-character-get-structure (nth 1 enc-str)))
1279 (eq (car enc2-str) ?⿰))
1280 (unless conversion-only
1281 (setq f-res (ids-find-chars-including-ids enc-str)))
1282 (setq new-str (list ?⿲
1287 (if (setq ret (ideographic-structure-find-chars new-str))
1289 (list (cons 'ideographic-structure new-str))))
1291 (list ?⿱ new-str-c (nth 2 enc-str))
1292 (setq a-res (ids-find-chars-including-ids new-str))
1297 (list ?⿱ new-str-c (nth 2 enc-str))
1301 ((eq (car enc-str) ?⿳)
1302 (setq enc2-str (ideographic-character-get-structure (nth 1 enc-str)))
1304 (eq (car enc2-str) ?⿰))
1305 (unless conversion-only
1306 (setq f-res (ids-find-chars-including-ids enc-str)))
1307 (setq new-str (list ?⿲
1312 (if (setq ret (ideographic-structure-find-chars new-str))
1314 (list (cons 'ideographic-structure new-str))))
1316 (list ?⿳ new-str-c (nth 2 enc-str) (nth 3 enc-str))
1317 (setq a-res (ids-find-chars-including-ids new-str))
1322 (list ?⿳ new-str-c (nth 2 enc-str) (nth 3 enc-str))
1326 ((eq (car enc-str) ?⿲)
1327 (unless conversion-only
1328 (setq f-res (ids-find-chars-including-ids enc-str)))
1329 (setq new-str (list ?⿱
1333 (if (setq ret (ideographic-structure-find-chars new-str))
1335 (list (cons 'ideographic-structure new-str))))
1337 (list ?⿲ (nth 1 enc-str) new-str-c (nth 3 enc-str))
1338 (setq a-res (ids-find-chars-including-ids new-str))
1343 (list ?⿲ (nth 1 enc-str) new-str-c (nth 3 enc-str))
1346 ((eq (car enc-str) ?⿴)
1347 (setq enc2-str (ideographic-character-get-structure (nth 1 enc-str)))
1349 (eq (car enc2-str) ?⿰))
1350 (unless conversion-only
1351 (setq f-res (ids-find-chars-including-ids enc-str)))
1352 (setq new-str (list ?⿱
1356 (if (setq ret (ideographic-structure-find-chars new-str))
1358 (list (cons 'ideographic-structure new-str))))
1360 (list ?⿲ (nth 1 enc2-str) new-str-c (nth 2 enc2-str))
1361 (setq a-res (ids-find-chars-including-ids new-str))
1366 (list ?⿲ (nth 1 enc2-str) new-str-c (nth 2 enc2-str))
1371 ((eq (car structure) ?⿵)
1372 (setq enc (nth 1 structure))
1374 (cond ((characterp enc)
1375 (get-char-attribute enc 'ideographic-structure)
1378 (cdr (assq 'ideographic-structure enc))
1381 ((eq (car enc-str) ?⿱)
1383 ((and (characterp (nth 2 enc-str))
1384 (memq (char-ucs (nth 2 enc-str))
1386 (unless conversion-only
1387 (setq f-res (ids-find-chars-including-ids enc-str)))
1388 (setq new-str (list ?⿵
1392 (if (setq ret (ideographic-structure-find-chars new-str))
1394 (list (cons 'ideographic-structure new-str))))
1396 (list ?⿱ (nth 1 enc-str) new-str-c)
1397 (setq a-res (ids-find-chars-including-ids new-str))
1402 (list ?⿱ (nth 1 enc-str) new-str-c)
1405 ((and (setq enc2-str (ideographic-character-get-structure (nth 2 enc-str)))
1407 ((eq (car enc2-str) ?⿰)
1410 ((and (eq (car enc2-str) ?⿱)
1412 (ideographic-character-get-structure (nth 2 enc2-str)))
1413 (eq (car enc3-str) ?⿰))
1416 (unless conversion-only
1417 (setq f-res (ids-find-chars-including-ids enc-str)))
1419 (cond ((eq code 611)
1432 (if (setq ret (ideographic-structure-find-chars new-str))
1434 (list (cons 'ideographic-structure new-str))))
1436 (cond ((eq code 611)
1437 (list ?⿱ (nth 1 enc-str) new-str-c)
1440 (list ?⿳ (nth 1 enc-str)(nth 1 enc2-str) new-str-c)
1442 (setq a-res (ids-find-chars-including-ids new-str))
1447 (cond ((eq code 611)
1448 (list ?⿱ (nth 1 enc-str) new-str-c)
1451 (list ?⿳ (nth 1 enc-str)(nth 1 enc2-str) new-str-c)
1456 ((eq (car enc-str) ?⿳)
1457 (setq enc2-str (ideographic-character-get-structure (nth 3 enc-str)))
1459 (eq (car enc2-str) ?⿰))
1460 (unless conversion-only
1461 (setq f-res (ids-find-chars-including-ids enc-str)))
1462 (setq new-str (list ?⿲
1467 (if (setq ret (ideographic-structure-find-chars new-str))
1469 (list (cons 'ideographic-structure new-str))))
1471 (list ?⿳ (nth 1 enc-str) (nth 2 enc-str) new-str-c)
1472 (setq a-res (ids-find-chars-including-ids new-str))
1477 (list ?⿳ (nth 1 enc-str) (nth 2 enc-str) new-str-c)
1481 ((eq (car enc-str) ?⿲)
1482 (unless conversion-only
1483 (setq f-res (ids-find-chars-including-ids enc-str)))
1484 (setq new-str (list ?⿱
1488 (if (setq ret (ideographic-structure-find-chars new-str))
1490 (list (cons 'ideographic-structure new-str))))
1492 (list ?⿲ (nth 1 enc-str) new-str-c (nth 3 enc-str))
1493 (setq a-res (ids-find-chars-including-ids new-str))
1498 (list ?⿲ (nth 1 enc-str) new-str-c (nth 3 enc-str))
1501 ((eq (car enc-str) ?⿴)
1502 (setq enc2-str (ideographic-character-get-structure (nth 1 enc-str)))
1504 (eq (car enc2-str) ?⿰))
1505 (unless conversion-only
1506 (setq f-res (ids-find-chars-including-ids enc-str)))
1507 (setq new-str (list ?⿱
1511 (if (setq ret (ideographic-structure-find-chars new-str))
1513 (list (cons 'ideographic-structure new-str))))
1515 (list ?⿲ (nth 1 enc2-str) new-str-c (nth 2 enc2-str))
1516 (setq a-res (ids-find-chars-including-ids new-str))
1521 (list ?⿲ (nth 1 enc2-str) new-str-c (nth 2 enc2-str))
1526 ((eq (car structure) ?⿷)
1527 (setq enc (nth 1 structure))
1529 (cond ((characterp enc)
1530 (get-char-attribute enc 'ideographic-structure)
1533 (cdr (assq 'ideographic-structure enc))
1536 ((eq (car enc-str) ?⿺)
1537 (unless conversion-only
1538 (setq f-res (ids-find-chars-including-ids enc-str)))
1539 (setq new-str (list ?⿱
1543 (if (setq ret (ideographic-structure-find-chars new-str))
1545 (list (cons 'ideographic-structure new-str))))
1547 (list ?⿺ (nth 1 enc-str) new-str-c)
1548 (setq a-res (ids-find-chars-including-ids new-str))
1553 (list ?⿺ (nth 1 enc-str) new-str-c)
1557 ((eq (car structure) ?⿺)
1558 (setq enc (nth 1 structure))
1560 (cond ((characterp enc)
1561 (or (get-char-attribute enc 'ideographic-structure)
1562 (get-char-attribute enc 'ideographic-structure@apparent))
1565 (or (cdr (assq 'ideographic-structure enc))
1566 (cdr (assq 'ideographic-structure@apparent enc)))
1569 ;; (mapcar (lambda (cell)
1570 ;; (or (and (listp cell)
1571 ;; (find-char cell))
1575 ((eq (car enc-str) ?⿱)
1577 ((and (characterp (nth 1 enc-str))
1578 (or (and (eq (char-ucs (nth 1 enc-str)) #x200CA)
1580 (and (eq (char-feature (nth 1 enc-str) '=>iwds-1) 233)
1581 (characterp (nth 2 structure))
1582 (eq (char-ucs (nth 2 structure)) #x4E36)
1584 (unless conversion-only
1585 (setq f-res (ids-find-chars-including-ids enc-str)))
1586 (setq new-str (list ?⿺
1590 (if (setq ret (ideographic-structure-find-chars new-str))
1592 (list (cons 'ideographic-structure new-str))))
1594 (list ?⿱ new-str-c (nth 2 enc-str))
1595 (setq a-res (ids-find-chars-including-ids new-str))
1600 (list ?⿱ new-str-c (nth 2 enc-str))
1603 ((and (characterp (nth 2 enc-str))
1604 (memq (char-ucs (nth 2 enc-str))
1607 #x65E5 #x66F0 #x5FC3
1608 #x2123C #x58EC #x738B #x7389)))
1609 (unless conversion-only
1610 (setq f-res (ids-find-chars-including-ids enc-str)))
1611 (setq new-str (list ?⿰
1615 (if (setq ret (ideographic-structure-find-chars new-str))
1617 (list (cons 'ideographic-structure new-str))))
1619 (list ?⿱ new-str-c (nth 2 enc-str))
1620 (setq a-res (ids-find-chars-including-ids new-str))
1625 (list ?⿱ new-str-c (nth 2 enc-str))
1630 ((eq (car structure) ?⿻)
1631 (setq enc (nth 1 structure))
1633 (cond ((characterp enc)
1634 (get-char-attribute enc 'ideographic-structure)
1637 (cdr (assq 'ideographic-structure enc))
1640 ((eq (car enc-str) ?⿱)
1641 (unless conversion-only
1642 (setq f-res (ids-find-chars-including-ids enc-str)))
1644 (list ?⿳ (nth 1 enc-str) (nth 2 structure) (nth 2 enc-str))
1664 ;;; ids-find.el ends here