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, 2021
6 ;; Author: MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
7 ;; Keywords: Kanji, Ideographs, search, IDS, CHISE, UCS, Unicode
9 ;; This file is a part of CHISE-IDS.
11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version.
16 ;; This program is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; see the file COPYING. If not, write to
23 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 (defun ids-index-store-char (product component)
29 (let ((ret (get-char-attribute component 'ideographic-products)))
30 (unless (memq product ret)
31 (put-char-attribute component 'ideographic-products
33 (when (setq ret (char-feature component 'ideographic-structure))
34 (ids-index-store-structure product ret)))
37 (defun ids-index-store-structure (product structure)
39 (dolist (cell (cdr structure))
41 (setq cell (plist-get cell :char)))
42 (cond ((characterp cell)
43 (ids-index-store-char product cell))
44 ((setq ret (assq 'ideographic-structure cell))
45 (ids-index-store-structure product (cdr ret)))
46 ((setq ret (find-char cell))
47 (ids-index-store-char product ret))
51 (defun ids-update-index (&optional in-memory)
55 (ids-index-store-structure c v)
57 'ideographic-structure)
60 (ids-index-store-structure c v)
62 'ideographic-structure@apparent)
65 (ids-index-store-structure c v)
67 'ideographic-structure@apparent/leftmost)
70 (ids-index-store-structure c v)
72 'ideographic-structure@apparent/rightmost)
74 (save-char-attribute-table 'ideographic-products)))
77 (mount-char-attribute-table 'ideographic-products)
80 (defun ids-find-all-products (char)
82 (dolist (cell (char-feature char 'ideographic-products))
83 (unless (memq cell dest)
84 (setq dest (cons cell dest)))
85 (setq dest (union dest (ids-find-all-products cell))))
88 (defun of-component-features ()
90 (dolist (feature (char-attribute-list))
91 (when (string-match "^<-.*[@/]component\\(/[^*/]+\\)*$"
92 (symbol-name feature))
94 (list* '<-mistakable '->mistakable
97 '<-original '->original
101 (defun to-component-features ()
103 (dolist (feature (char-attribute-list))
104 (when (string-match "^->.*[@/]component\\(/[^*/]+\\)*$"
105 (symbol-name feature))
106 (push feature dest)))
110 (defun char-component-variants (char)
111 (let ((dest (list char))
113 (dolist (feature (to-component-features))
114 (if (setq ret (get-char-attribute char feature))
116 (setq dest (union dest (char-component-variants c))))))
118 ;; ((setq ret (some (lambda (feature)
119 ;; (get-char-attribute char feature))
120 ;; (to-component-features)))
122 ;; (setq dest (union dest (char-component-variants c))))
124 ((setq ret (get-char-attribute char '->ucs-unified))
125 (setq dest (cons char ret))
127 (setq dest (union dest
128 (some (lambda (feature)
129 (get-char-attribute c feature))
130 (of-component-features))
133 ((and (setq ret (get-char-attribute char '=>ucs))
134 (setq uchr (decode-char '=ucs ret)))
135 (setq dest (cons uchr (char-variants uchr)))
137 (setq dest (union dest
138 (some (lambda (feature)
139 (get-char-attribute c feature))
140 (of-component-features))
146 (unless (memq c dest)
147 (setq dest (cons c dest)))
150 (some (lambda (feature)
151 (char-feature c feature))
152 (of-component-features))
160 (defun ideographic-products-find (&rest components)
161 (if (stringp (car components))
162 (setq components (string-to-char-list (car components))))
164 (dolist (variant (char-component-variants (car components)))
167 (get-char-attribute variant 'ideographic-products))))
170 (setq components (cdr components)))
172 (dolist (variant (char-component-variants (car components)))
175 (get-char-attribute variant 'ideographic-products))))
176 (setq dest (intersection dest products)))
179 (defun ideograph-find-products-with-variants (components &optional ignored-chars)
180 (if (stringp components)
181 (setq components (string-to-char-list components)))
183 (dolist (variant (char-component-variants (car components)))
187 (get-char-attribute variant 'ideographic-products)
191 (setq components (cdr components)))
193 (dolist (variant (char-component-variants (car components)))
197 (get-char-attribute variant 'ideographic-products)
199 (setq dest (intersection dest products)))
202 (defun ideograph-find-products (components &optional ignored-chars)
203 (if (stringp components)
204 (setq components (string-to-char-list components)))
206 ;; (dolist (variant (char-component-variants (car components)))
209 ;; (get-char-attribute variant 'ideographic-products))))
210 ;; (setq dest products)
211 (setq dest (get-char-attribute (car components) 'ideographic-products))
213 (setq components (cdr components)))
214 ;; (setq products nil)
215 ;; (dolist (variant (char-component-variants (car components)))
218 ;; (get-char-attribute variant 'ideographic-products))))
219 (setq products (get-char-attribute (car components) 'ideographic-products))
220 (setq dest (intersection dest products)))
224 (defun ideographic-structure-char= (c1 c2)
227 (let ((m1 (char-ucs c1))
231 (memq c1 (char-component-variants c2)))))))
233 (defun ideographic-structure-member-compare-components (component s-component)
235 (cond ((char-ref= component s-component #'ideographic-structure-char=))
237 (if (setq ret (assq 'ideographic-structure s-component))
238 (ideographic-structure-member component (cdr ret))))
239 ((setq ret (get-char-attribute s-component 'ideographic-structure))
240 (ideographic-structure-member component ret)))))
243 (defun ideographic-structure-member (component structure)
244 "Return non-nil if COMPONENT is included in STRUCTURE."
245 (or (memq component structure)
247 (setq structure (cdr structure))
248 (ideographic-structure-member-compare-components
249 component (car structure)))
251 (setq structure (cdr structure))
252 (ideographic-structure-member-compare-components
253 component (car structure)))
255 (setq structure (cdr structure))
257 (ideographic-structure-member-compare-components
258 component (car structure))))))
262 (defun ideographic-structure-repertoire-p (structure components)
263 "Return non-nil if STRUCTURE can be constructed by a subset of COMPONENTS."
265 (let (ret s-component)
267 (while (setq structure (cdr structure))
268 (setq s-component (car structure))
269 (unless (characterp s-component)
270 (if (setq ret (find-char s-component))
271 (setq s-component ret)))
274 (if (setq ret (assq 'ideographic-structure s-component))
275 (ideographic-structure-repertoire-p
276 (cdr ret) components)))
277 ((member* s-component components
278 :test #'ideographic-structure-char=))
280 (get-char-attribute s-component
281 'ideographic-structure))
282 (ideographic-structure-repertoire-p ret components)))
287 (defvar ids-find-result-buffer "*ids-chars*")
289 (defun ids-find-format-line (c v)
290 (format "%c\t%s\t%s\n"
292 (or (let ((ucs (or (char-ucs c)
293 (encode-char c 'ucs))))
295 (cond ((<= ucs #xFFFF)
296 (format " U+%04X" ucs))
298 (format "U-%08X" ucs)))))
300 (or (ideographic-structure-to-ids v)
303 (defun ids-insert-chars-including-components* (components
304 &optional level ignored-chars)
308 (dolist (c (sort (copy-list (ideograph-find-products components
311 (if (setq as (char-total-strokes a))
312 (if (setq bs (char-total-strokes b))
314 (ideograph-char< a b)
317 (ideograph-char< a b)))))
318 (unless (memq c ignored-chars)
319 (setq is (char-feature c 'ideographic-structure))
324 (insert (ids-find-format-line c is))
326 (ids-insert-chars-including-components*
327 (char-to-string c) (1+ level)
328 (cons c ignored-chars))))
333 (defun ids-insert-chars-including-components (components
334 &optional level ignored-chars)
339 (ids-insert-chars-including-components* components
340 level ignored-chars)))
342 (dolist (c ignored-chars)
343 (dolist (vc (char-component-variants c))
344 (unless (memq vc ignored-chars)
345 (when (setq is (get-char-attribute vc 'ideographic-structure))
350 (insert (ids-find-format-line vc is))
352 (ids-insert-chars-including-components*
353 (char-to-string vc) (1+ level)
354 (cons vc ignored-chars)))))))
355 (dolist (c (sort (copy-list (ideograph-find-products-with-variants
356 components ignored-chars))
358 (if (setq as (char-total-strokes a))
359 (if (setq bs (char-total-strokes b))
361 (ideograph-char< a b)
364 (ideograph-char< a b)))))
365 (unless (memq c ignored-chars)
366 (setq is (get-char-attribute c 'ideographic-structure))
371 (insert (ids-find-format-line c is))
373 (ids-insert-chars-including-components*
374 (char-to-string c) (1+ level)
375 (cons c ignored-chars))))
381 (defun ids-find-chars-including-components (components)
382 "Search Ideographs whose structures have COMPONENTS."
383 (interactive "sComponents : ")
384 (with-current-buffer (get-buffer-create ids-find-result-buffer)
385 (setq buffer-read-only nil)
387 (ids-insert-chars-including-components components 0 nil)
388 ;; (let ((ignored-chars
390 ;; (ids-insert-chars-including-components components 0 nil
391 ;; #'ideograph-find-products)))
393 ;; (setq rest ignored-chars)
394 ;; ;; (dolist (c rest)
395 ;; ;; (setq ignored-chars
396 ;; ;; (union ignored-chars
397 ;; ;; (ids-insert-chars-including-components
398 ;; ;; (list c) 0 ignored-chars
399 ;; ;; #'ideograph-find-products-with-variants))))
400 ;; (ids-insert-chars-including-components components 0 ignored-chars
401 ;; #'ideograph-find-products-with-variants))
402 (goto-char (point-min)))
403 (view-buffer ids-find-result-buffer))
406 (define-obsolete-function-alias 'ideographic-structure-search-chars
407 'ids-find-chars-including-components)
410 (defun ids-find-chars-covered-by-components (components)
411 "Search Ideographs which structures are consisted by subsets of COMPONENTS."
412 (interactive "sComponents: ")
413 (if (stringp components)
414 (setq components (string-to-char-list components)))
415 (with-current-buffer (get-buffer-create ids-find-result-buffer)
416 (setq buffer-read-only nil)
420 (when (ideographic-structure-repertoire-p v components)
421 (insert (ids-find-format-line c v))))
422 'ideographic-structure)
423 (goto-char (point-min)))
424 (view-buffer ids-find-result-buffer))
427 (defun ideographic-structure-merge-components-alist (ca1 ca2)
428 (let ((dest-alist ca1)
431 (if (setq ret (assq (car cell) dest-alist))
432 (setcdr ret (+ (cdr ret)(cdr cell)))
433 (setq dest-alist (cons cell dest-alist))))
436 (defun ideographic-structure-to-components-alist (structure)
437 (apply #'ideographic-structure-to-components-alist* structure))
439 (defun ideographic-structure-to-components-alist* (operator component1 component2
442 (let (dest-alist ret)
444 (cond ((characterp component1)
445 (unless (encode-char component1 'ascii)
446 (list (cons component1 1)))
448 ((setq ret (assq 'ideographic-structure component1))
449 (ideographic-structure-to-components-alist (cdr ret))
451 ((setq ret (find-char component1))
455 (ideographic-structure-merge-components-alist
457 (cond ((characterp component2)
458 (unless (encode-char component2 'ascii)
459 (list (cons component2 1)))
461 ((setq ret (assq 'ideographic-structure component2))
462 (ideographic-structure-to-components-alist (cdr ret))
464 ((setq ret (find-char component2))
467 (if (memq operator '(?\u2FF2 ?\u2FF3))
468 (ideographic-structure-merge-components-alist
470 (cond ((characterp component3)
471 (unless (encode-char component3 'ascii)
472 (list (cons component3 1)))
474 ((setq ret (assq 'ideographic-structure component3))
475 (ideographic-structure-to-components-alist (cdr ret))
477 ((setq ret (find-char component3))
482 (defun ids-find-merge-variables (ve1 ve2)
488 (let ((dest-alist ve1)
492 (setq cell (car rest))
493 (if (setq ret (assq (car cell) ve1))
494 (eq (cdr ret)(cdr cell))
495 (setq dest-alist (cons cell dest-alist))))
496 (setq rest (cdr rest)))
502 (defun ideographic-structure-equal (structure1 structure2)
503 (let (dest-alist ret)
504 (and (setq dest-alist (ideographic-structure-character=
505 (car structure1)(car structure2)))
506 (setq ret (ideographic-structure-character=
507 (nth 1 structure1)(nth 1 structure2)))
508 (setq dest-alist (ids-find-merge-variables dest-alist ret))
509 (setq ret (ideographic-structure-character=
510 (nth 2 structure1)(nth 2 structure2)))
511 (setq dest-alist (ids-find-merge-variables dest-alist ret))
512 (if (memq (car structure1) '(?\u2FF2 ?\u2FF3))
513 (and (setq ret (ideographic-structure-character=
514 (nth 3 structure1)(nth 3 structure2)))
515 (setq dest-alist (ids-find-merge-variables dest-alist ret)))
519 (defun ideographic-structure-character= (c1 c2)
521 (cond ((characterp c1)
522 (cond ((encode-char c1 'ascii)
526 (if (encode-char c2 'ascii)
530 ((setq ret2 (find-char c2))
533 ((setq ret2 (assq 'ideographic-structure c2))
534 (and (setq ret (get-char-attribute c1 'ideographic-structure))
535 (ideographic-structure-equal ret (cdr ret2)))
538 ((setq ret (assq 'ideographic-structure c1))
539 (cond ((characterp c2)
540 (if (encode-char c2 'ascii)
542 (and (setq ret2 (get-char-attribute c2 'ideographic-structure))
543 (ideographic-structure-equal (cdr ret) ret2)))
545 ((setq ret2 (find-char c2))
546 (and (setq ret2 (get-char-attribute ret2 'ideographic-structure))
547 (ideographic-structure-equal (cdr ret) ret2))
549 ((setq ret2 (assq 'ideographic-structure c2))
550 (ideographic-structure-equal (cdr ret)(cdr ret2))
553 ((setq ret (find-char c1))
554 (cond ((characterp c2)
555 (if (encode-char c2 'ascii)
559 ((setq ret2 (find-char c2))
562 ((setq ret2 (assq 'ideographic-structure c2))
563 (and (setq ret (get-char-attribute ret 'ideographic-structure))
564 (ideographic-structure-equal ret (cdr ret2))
568 (defun ideographic-structure-find-chars (structure)
569 (let ((comp-alist (ideographic-structure-to-components-alist structure))
572 (sort (mapcar (lambda (cell)
573 (if (setq ret (get-char-attribute
574 (car cell) 'ideographic-products))
575 (cons ret (length ret))
579 (< (cdr a)(cdr b))))))
580 (when (or (and (setq str
581 (get-char-attribute pc 'ideographic-structure))
582 (ideographic-structure-equal str structure))
584 (get-char-attribute pc 'ideographic-structure@apparent))
585 (ideographic-structure-equal str structure))
587 (get-char-attribute pc 'ideographic-structure@apparent/leftmost))
588 (ideographic-structure-equal str structure)))
589 (setq pl (cons pc pl))
594 (defun ideographic-char-count-components (char component)
597 (cond ((eq char component)
599 ((setq structure (get-char-attribute char 'ideographic-structure))
600 (dolist (cell (ideographic-structure-to-components-alist structure))
603 (if (eq (car cell) char)
605 (* (ideographic-char-count-components (car cell) component)
613 (defun ideographic-character-get-structure (character)
614 "Return ideographic-structure of CHARACTER.
615 CHARACTER can be a character or char-spec."
616 (mapcar (lambda (cell)
617 (or (and (listp cell)
621 (cond ((characterp character)
622 (get-char-attribute character 'ideographic-structure)
624 ((setq ret (assq 'ideographic-structure character))
627 ((setq ret (find-char character))
628 (get-char-attribute ret 'ideographic-structure)
632 (defun ideographic-char-match-component (char component)
633 "Return non-nil if character CHAR has COMPONENT in ideographic-structure.
634 COMPONENT can be a character or char-spec."
635 (or (ideographic-structure-character= char component)
636 (let ((str (ideographic-character-get-structure char)))
638 (or (ideographic-char-match-component (nth 1 str) component)
639 (ideographic-char-match-component (nth 2 str) component)
640 (if (memq (car str) '(?\u2FF2 ?\u2FF3))
641 (ideographic-char-match-component (nth 3 str) component)))))))
643 (defun ideographic-structure-char< (a b)
644 (let ((sa (get-char-attribute a 'ideographic-structure))
645 (sb (get-char-attribute b 'ideographic-structure))
649 (setq tsa (char-total-strokes a)
650 tsb (char-total-strokes b))
655 (ideograph-char< a b)))
659 (ideograph-char< a b))))
667 (setq tsa (char-total-strokes a)
668 tsb (char-total-strokes b))
673 (ideograph-char< a b)))
677 (ideograph-char< a b)))
682 (defun ideo-comp-tree-adjoin (tree char)
686 (while (and (not finished)
688 (setq cell (pop rest))
689 (cond ((ideographic-structure-character= char (car cell))
694 ((ideographic-char-match-component char (car cell))
696 (cons (cons (car cell)
697 (ideo-comp-tree-adjoin (cdr cell) char))
701 ((ideographic-char-match-component (car cell) char)
702 (setq included (cons cell included))
705 ;; (setq other (cons cell other))
708 (setq dest (cons cell dest))
714 (cons (cons char included)
718 (cons (list char) tree)
721 (defun ideographic-chars-to-is-a-tree (chars)
723 (dolist (char (sort (copy-list chars) #'ideographic-structure-char<))
724 (setq tree (ideo-comp-tree-adjoin tree char)))
727 (defun ids-find-chars-including-ids (structure)
728 (let (comp-alist comp-spec ret str rest)
730 ((characterp structure)
731 (setq rest (copy-list (get-char-attribute structure 'ideographic-products)))
733 ((setq ret (ideographic-structure-find-chars structure))
738 (copy-list (get-char-attribute pc 'ideographic-products)))))
741 (setq comp-alist (ideographic-structure-to-components-alist structure)
742 comp-spec (list (cons 'ideographic-structure structure)))
744 (sort (mapcar (lambda (cell)
745 (if (setq ret (get-char-attribute
746 (car cell) 'ideographic-products))
747 (cons ret (length ret))
751 (< (cdr a)(cdr b))))))
752 (when (and (every (lambda (cell)
753 (>= (ideographic-char-count-components pc (car cell))
756 (or (ideographic-char-match-component pc comp-spec)
757 (and (setq str (get-char-attribute pc 'ideographic-structure))
758 (ideographic-char-match-component
761 'ideographic-structure
762 (functional-ideographic-structure-to-apparent-structure
767 (ideographic-chars-to-is-a-tree rest)))
769 (defun functional-ideographic-structure-to-apparent-structure (structure)
770 (ideographic-structure-compare-functional-and-apparent
771 structure nil 'conversion-only))
774 (defun ideographic-structure-compact (structure)
775 (let ((rest structure)
779 (setq cell (pop rest))
780 (if (and (consp cell)
781 (setq ret (find-char cell)))
785 (cond ((setq ret (assq 'ideographic-structure cell))
792 (cond ((setq ret (ideographic-structure-find-chars sub))
795 ((setq ret (ideographic-structure-compact sub))
796 (list (cons 'ideographic-structure ret))
799 (list (cons 'ideographic-structure sub))))
802 (setq dest (cons cell dest)))
805 (defun ideographic-structure-compare-functional-and-apparent (structure
808 (let (enc enc-str enc2-str enc3-str new-str new-str-c
809 f-res a-res ret code)
811 ((eq (car structure) ?⿸)
812 (setq enc (nth 1 structure))
814 (cond ((characterp enc)
815 (get-char-attribute enc 'ideographic-structure)
818 (cdr (assq 'ideographic-structure enc))
821 ((eq (car enc-str) ?⿰)
822 (unless conversion-only
823 (setq f-res (ids-find-chars-including-ids enc-str)))
824 (setq new-str (list ?⿱
828 (if (setq ret (ideographic-structure-find-chars new-str))
830 (list (cons 'ideographic-structure new-str))))
832 (list ?⿰ (nth 1 enc-str) new-str-c)
833 (setq a-res (ids-find-chars-including-ids new-str))
838 (list ?⿰ (nth 1 enc-str) new-str-c)
841 ((and (eq (car enc-str) ?⿲)
842 (memq (char-ucs (nth 1 enc-str)) '(#x4EBB #x2E85))
843 (eq (nth 2 enc-str) ?丨))
844 (unless conversion-only
845 (setq f-res (ids-find-chars-including-ids enc-str)))
846 (setq new-str (list ?⿱
850 (if (setq ret (ideographic-structure-find-chars new-str))
852 (list (cons 'ideographic-structure new-str))))
854 (list ?⿰ (decode-char '=big5-cdp #x8B7A) new-str-c)
855 (setq a-res (ids-find-chars-including-ids new-str))
860 (list ?⿰ (decode-char '=big5-cdp #x8B7A) new-str-c)
863 ((eq (car enc-str) ?⿱)
864 (unless conversion-only
865 (setq f-res (ids-find-chars-including-ids enc-str)))
869 ((characterp (nth 2 enc-str))
870 (if (or (memq (encode-char (nth 2 enc-str) '=>ucs@component)
871 '(#x20087 #x5382 #x4E06))
872 (eq (encode-char (nth 2 enc-str) '=>ucs@iwds-1)
874 (eq (encode-char (nth 2 enc-str) '=ucs-itaiji-001)
876 (eq (encode-char (nth 2 enc-str) '=big5-cdp)
878 (eq (encode-char (nth 2 enc-str) '=>big5-cdp)
880 (eq (encode-char (nth 2 enc-str) '=big5-cdp)
882 (eq (or (encode-char (nth 2 enc-str) '=>big5-cdp)
883 (encode-char (nth 2 enc-str) '=big5-cdp-itaiji-001))
885 (eq (car (get-char-attribute (nth 2 enc-str)
886 'ideographic-structure))
890 ((eq (car (cdr (assq 'ideographic-structure (nth 2 enc-str))))
898 (if (setq ret (ideographic-structure-find-chars new-str))
900 (list (cons 'ideographic-structure new-str))))
902 (list ?⿱ (nth 1 enc-str) new-str-c)
903 (setq a-res (ids-find-chars-including-ids new-str))
908 (list ?⿱ (nth 1 enc-str) new-str-c)
909 (if (eq (car new-str) ?⿸)
913 ((eq (car enc-str) ?⿸)
914 (unless conversion-only
915 (setq f-res (ids-find-chars-including-ids enc-str)))
916 (setq new-str (list (cond
917 ((characterp (nth 2 enc-str))
918 (if (memq (char-ucs (nth 2 enc-str))
928 (if (setq ret (ideographic-structure-find-chars new-str))
930 (list (cons 'ideographic-structure new-str))))
932 (list ?⿸ (nth 1 enc-str) new-str-c)
933 (setq a-res (ids-find-chars-including-ids new-str))
938 (list ?⿸ (nth 1 enc-str) new-str-c)
939 (if (eq (car new-str) ?⿰)
944 ((eq (car structure) ?⿹)
945 (setq enc (nth 1 structure))
947 (cond ((characterp enc)
948 (get-char-attribute enc 'ideographic-structure)
951 (cdr (assq 'ideographic-structure enc))
954 ((eq (car enc-str) ?⿰)
955 (unless conversion-only
956 (setq f-res (ids-find-chars-including-ids enc-str)))
957 (setq new-str (list ?⿱
961 (if (setq ret (ideographic-structure-find-chars new-str))
963 (list (cons 'ideographic-structure new-str))))
965 (list ?⿰ new-str-c (nth 2 enc-str))
966 (setq a-res (ids-find-chars-including-ids new-str))
971 (list ?⿰ new-str-c (nth 2 enc-str))
974 ((eq (car enc-str) ?⿱)
975 (unless conversion-only
976 (setq f-res (ids-find-chars-including-ids enc-str)))
977 (setq new-str (list ?⿰
981 (if (setq ret (ideographic-structure-find-chars new-str))
983 (list (cons 'ideographic-structure new-str))))
985 (list ?⿱ (nth 1 enc-str) new-str-c)
986 (setq a-res (ids-find-chars-including-ids new-str))
991 (list ?⿱ (nth 1 enc-str) new-str-c)
996 ((eq (get-char-attribute (car structure) '=ucs-itaiji-001) #x2FF6)
997 (setq enc (nth 1 structure))
999 (cond ((characterp enc)
1000 (get-char-attribute enc 'ideographic-structure)
1003 (cdr (assq 'ideographic-structure enc))
1006 ((eq (car enc-str) ?⿺)
1007 (unless conversion-only
1008 (setq f-res (ids-find-chars-including-ids enc-str)))
1009 (setq new-str (list ?⿱
1013 (if (setq ret (ideographic-structure-find-chars new-str))
1015 (list (cons 'ideographic-structure new-str))))
1017 (list ?⿺ new-str-c (nth 2 enc-str))
1018 (setq a-res (ids-find-chars-including-ids new-str))
1023 (list ?⿺ new-str-c (nth 2 enc-str))
1026 ((eq (car enc-str) ?⿱)
1027 (unless conversion-only
1028 (setq f-res (ids-find-chars-including-ids enc-str)))
1029 (setq new-str (list ?⿰
1033 (if (setq ret (ideographic-structure-find-chars new-str))
1035 (list (cons 'ideographic-structure new-str))))
1037 (list ?⿱ new-str-c (nth 2 enc-str))
1038 (setq a-res (ids-find-chars-including-ids new-str))
1043 (list ?⿱ new-str-c (nth 2 enc-str))
1046 ((eq (car enc-str) ?⿰)
1047 (unless conversion-only
1048 (setq f-res (ids-find-chars-including-ids enc-str)))
1049 (setq new-str (list ?⿱
1053 (if (setq ret (ideographic-structure-find-chars new-str))
1055 (list (cons 'ideographic-structure new-str))))
1057 (list ?⿰ new-str-c (nth 2 enc-str))
1058 (setq a-res (ids-find-chars-including-ids new-str))
1063 (list ?⿰ new-str-c (nth 2 enc-str))
1068 ((eq (car structure) ?⿴)
1069 (setq enc (nth 1 structure))
1071 (cond ((characterp enc)
1072 (get-char-attribute enc 'ideographic-structure)
1075 (cdr (assq 'ideographic-structure enc))
1078 ((eq (car enc-str) ?⿱)
1080 ((and (characterp (nth 2 enc-str))
1081 (or (memq (char-ucs (nth 2 enc-str)) '(#x56D7 #x5F51 #x897F))
1082 (eq (char-feature (nth 2 enc-str) '=>big5-cdp)
1084 (unless conversion-only
1085 (setq f-res (ids-find-chars-including-ids enc-str)))
1086 (setq new-str (list ?⿴
1090 (if (setq ret (ideographic-structure-find-chars new-str))
1092 (list (cons 'ideographic-structure new-str))))
1094 (list ?⿱ (nth 1 enc-str) new-str-c)
1095 (setq a-res (ids-find-chars-including-ids new-str))
1100 (list ?⿱ (nth 1 enc-str) new-str-c)
1103 ((and (characterp (nth 2 enc-str))
1104 (eq (char-ucs (nth 2 enc-str)) #x51F5))
1105 (unless conversion-only
1106 (setq f-res (ids-find-chars-including-ids enc-str)))
1107 (setq new-str (list ?⿶
1111 (if (setq ret (ideographic-structure-find-chars new-str))
1113 (list (cons 'ideographic-structure new-str))))
1115 (list ?⿱ (nth 1 enc-str) new-str-c)
1116 (setq a-res (ids-find-chars-including-ids new-str))
1121 (list ?⿱ (nth 1 enc-str) new-str-c)
1124 ((and (characterp (nth 1 enc-str))
1125 (eq (char-feature (nth 1 enc-str) '=>ucs@component)
1127 (unless conversion-only
1128 (setq f-res (ids-find-chars-including-ids enc-str)))
1129 (setq new-str (list ?⿵
1133 (if (setq ret (ideographic-structure-find-chars new-str))
1135 (list (cons 'ideographic-structure new-str))))
1137 (list ?⿱ new-str-c (nth 2 enc-str))
1138 (setq a-res (ids-find-chars-including-ids new-str))
1143 (list ?⿱ new-str-c (nth 2 enc-str))
1147 (unless conversion-only
1148 (setq f-res (ids-find-chars-including-ids enc-str)))
1149 (setq new-str (list ?⿱ (nth 2 structure) (nth 2 enc-str)))
1151 (if (setq ret (ideographic-structure-find-chars new-str))
1153 (list (cons 'ideographic-structure new-str))))
1155 (list ?⿱ (nth 1 enc-str) new-str-c)
1156 (setq a-res (ids-find-chars-including-ids new-str))
1161 (list ?⿱ (nth 1 enc-str) new-str-c)
1165 ((eq (car enc-str) ?⿳)
1167 ((and (characterp (nth 2 enc-str))
1168 (eq (char-ucs (nth 2 enc-str)) #x56D7))
1169 (unless conversion-only
1170 (setq f-res (ids-find-chars-including-ids enc-str)))
1171 (setq new-str (list ?⿴ (nth 2 enc-str) (nth 2 structure)))
1173 (if (setq ret (ideographic-structure-find-chars new-str))
1175 (list (cons 'ideographic-structure new-str))))
1176 (setq new-str (list ?⿱ (nth 1 enc-str) new-str-c))
1178 (if (setq ret (ideographic-structure-find-chars new-str))
1180 (list (cons 'ideographic-structure new-str))))
1182 (list ?⿱ new-str-c (nth 3 enc-str))
1183 (setq a-res (ids-find-chars-including-ids new-str))
1188 (list ?⿱ new-str-c (nth 3 enc-str))
1191 ((and (characterp (nth 2 enc-str))
1192 (eq (char-ucs (nth 2 enc-str)) #x5196))
1193 (unless conversion-only
1194 (setq f-res (ids-find-chars-including-ids enc-str)))
1195 (setq new-str (list ?⿱ (nth 1 enc-str) (nth 2 enc-str)))
1197 (if (setq ret (ideographic-structure-find-chars new-str))
1199 (list (cons 'ideographic-structure new-str))))
1200 (setq new-str (list ?⿱ new-str-c (nth 2 structure)))
1202 (if (setq ret (ideographic-structure-find-chars new-str))
1204 (list (cons 'ideographic-structure new-str))))
1206 (list ?⿱ new-str-c (nth 3 enc-str))
1207 (setq a-res (ids-find-chars-including-ids new-str))
1212 (list ?⿱ new-str-c (nth 3 enc-str))
1215 ((and (characterp (nth 2 enc-str))
1216 (or (eq (encode-char (nth 2 enc-str) '=>big5-cdp)
1218 (eq (encode-char (nth 2 enc-str) '=>gt-k)
1220 (eq (char-ucs (nth 2 enc-str)) #x2008A)))
1221 (unless conversion-only
1222 (setq f-res (ids-find-chars-including-ids enc-str)))
1223 (setq new-str (list ?⿱ (nth 2 structure) (nth 2 enc-str)))
1225 (if (setq ret (ideographic-structure-find-chars new-str))
1227 (list (cons 'ideographic-structure new-str))))
1228 (setq new-str (list ?⿸ new-str-c (nth 3 enc-str)))
1230 (if (setq ret (ideographic-structure-find-chars new-str))
1232 (list (cons 'ideographic-structure new-str))))
1234 (list ?⿱ (nth 1 enc-str) new-str-c)
1235 (setq a-res (ids-find-chars-including-ids new-str))
1240 (list ?⿱ (nth 1 enc-str) new-str-c)
1244 (unless conversion-only
1245 (setq f-res (ids-find-chars-including-ids enc-str)))
1246 (setq new-str (list ?⿻ (nth 2 enc-str) (nth 2 structure)))
1248 (if (setq ret (ideographic-structure-find-chars new-str))
1250 (list (cons 'ideographic-structure new-str))))
1251 (setq new-str (list ?⿱ (nth 1 enc-str) new-str-c))
1253 (if (setq ret (ideographic-structure-find-chars new-str))
1255 (list (cons 'ideographic-structure new-str))))
1257 (list ?⿱ new-str-c (nth 3 enc-str))
1258 (setq a-res (ids-find-chars-including-ids new-str))
1263 (list ?⿱ new-str-c (nth 3 enc-str))
1267 ((eq (car enc-str) ?⿰)
1269 ((equal (nth 1 enc-str)(nth 2 enc-str))
1270 (unless conversion-only
1271 (setq f-res (ids-find-chars-including-ids enc-str)))
1272 (setq new-str (list ?⿲
1277 (list (cons 'ideographic-structure new-str)))
1280 (setq a-res (ids-find-chars-including-ids new-str))
1289 (unless conversion-only
1290 (setq f-res (ids-find-chars-including-ids enc-str)))
1291 (setq new-str (list ?⿰
1295 (if (setq ret (ideographic-structure-find-chars new-str))
1297 (list (cons 'ideographic-structure new-str))))
1299 (list ?⿰ (nth 1 enc-str) new-str-c)
1300 (setq a-res (ids-find-chars-including-ids new-str))
1305 (list ?⿰ (nth 1 enc-str) new-str-c)
1311 ((eq (car structure) ?⿶)
1312 (setq enc (nth 1 structure))
1314 (cond ((characterp enc)
1315 (get-char-attribute enc 'ideographic-structure)
1318 (cdr (assq 'ideographic-structure enc))
1321 ((eq (car enc-str) ?⿱)
1322 (setq enc2-str (ideographic-character-get-structure (nth 1 enc-str)))
1324 (eq (car enc2-str) ?⿰))
1325 (unless conversion-only
1326 (setq f-res (ids-find-chars-including-ids enc-str)))
1327 (setq new-str (list ?⿲
1332 (if (setq ret (ideographic-structure-find-chars new-str))
1334 (list (cons 'ideographic-structure new-str))))
1336 (list ?⿱ new-str-c (nth 2 enc-str))
1337 (setq a-res (ids-find-chars-including-ids new-str))
1342 (list ?⿱ new-str-c (nth 2 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 ?⿲
1357 (if (setq ret (ideographic-structure-find-chars new-str))
1359 (list (cons 'ideographic-structure new-str))))
1361 (list ?⿳ new-str-c (nth 2 enc-str) (nth 3 enc-str))
1362 (setq a-res (ids-find-chars-including-ids new-str))
1367 (list ?⿳ new-str-c (nth 2 enc-str) (nth 3 enc-str))
1371 ((eq (car enc-str) ?⿲)
1372 (unless conversion-only
1373 (setq f-res (ids-find-chars-including-ids enc-str)))
1374 (setq new-str (list ?⿱
1378 (if (setq ret (ideographic-structure-find-chars new-str))
1380 (list (cons 'ideographic-structure new-str))))
1382 (list ?⿲ (nth 1 enc-str) new-str-c (nth 3 enc-str))
1383 (setq a-res (ids-find-chars-including-ids new-str))
1388 (list ?⿲ (nth 1 enc-str) new-str-c (nth 3 enc-str))
1391 ((eq (car enc-str) ?⿴)
1392 (setq enc2-str (ideographic-character-get-structure (nth 1 enc-str)))
1394 (eq (car enc2-str) ?⿰))
1395 (unless conversion-only
1396 (setq f-res (ids-find-chars-including-ids enc-str)))
1397 (setq new-str (list ?⿱
1401 (if (setq ret (ideographic-structure-find-chars new-str))
1403 (list (cons 'ideographic-structure new-str))))
1405 (list ?⿲ (nth 1 enc2-str) new-str-c (nth 2 enc2-str))
1406 (setq a-res (ids-find-chars-including-ids new-str))
1411 (list ?⿲ (nth 1 enc2-str) new-str-c (nth 2 enc2-str))
1416 ((eq (car structure) ?⿵)
1417 (setq enc (nth 1 structure))
1419 (cond ((characterp enc)
1420 (get-char-attribute enc 'ideographic-structure)
1423 (cdr (assq 'ideographic-structure enc))
1426 ((eq (car enc-str) ?⿱)
1428 ((and (characterp (nth 2 enc-str))
1429 (memq (char-ucs (nth 2 enc-str))
1431 (unless conversion-only
1432 (setq f-res (ids-find-chars-including-ids enc-str)))
1433 (setq new-str (list ?⿵
1437 (if (setq ret (ideographic-structure-find-chars new-str))
1439 (list (cons 'ideographic-structure new-str))))
1441 (list ?⿱ (nth 1 enc-str) new-str-c)
1442 (setq a-res (ids-find-chars-including-ids new-str))
1447 (list ?⿱ (nth 1 enc-str) new-str-c)
1450 ((and (setq enc2-str (ideographic-character-get-structure (nth 2 enc-str)))
1452 ((eq (car enc2-str) ?⿰)
1455 ((eq (car enc2-str) ?⿲)
1458 ((and (eq (car enc2-str) ?⿱)
1460 (ideographic-character-get-structure (nth 2 enc2-str)))
1461 (eq (car enc3-str) ?⿰))
1464 (unless conversion-only
1465 (setq f-res (ids-find-chars-including-ids enc-str)))
1467 (cond ((eq code 611)
1482 (list (list 'ideographic-structure
1489 (if (setq ret (ideographic-structure-find-chars new-str))
1491 (list (cons 'ideographic-structure
1492 (ideographic-structure-compact new-str)))))
1494 (cond ((or (eq code 611)
1496 (list ?⿱ (nth 1 enc-str) new-str-c)
1499 (list ?⿳ (nth 1 enc-str)(nth 1 enc2-str) new-str-c)
1501 (setq a-res (ids-find-chars-including-ids new-str))
1506 (cond ((or (eq code 611)
1508 (list ?⿱ (nth 1 enc-str) new-str-c)
1511 (list ?⿳ (nth 1 enc-str)(nth 1 enc2-str) new-str-c)
1516 ((eq (car enc-str) ?⿳)
1517 (setq enc2-str (ideographic-character-get-structure (nth 3 enc-str)))
1519 (eq (car enc2-str) ?⿰))
1520 (unless conversion-only
1521 (setq f-res (ids-find-chars-including-ids enc-str)))
1522 (setq new-str (list ?⿲
1527 (if (setq ret (ideographic-structure-find-chars new-str))
1529 (list (cons 'ideographic-structure new-str))))
1531 (list ?⿳ (nth 1 enc-str) (nth 2 enc-str) new-str-c)
1532 (setq a-res (ids-find-chars-including-ids new-str))
1537 (list ?⿳ (nth 1 enc-str) (nth 2 enc-str) new-str-c)
1541 ((eq (car enc-str) ?⿲)
1542 (unless conversion-only
1543 (setq f-res (ids-find-chars-including-ids enc-str)))
1544 (setq new-str (list ?⿱
1548 (if (setq ret (ideographic-structure-find-chars new-str))
1550 (list (cons 'ideographic-structure new-str))))
1552 (list ?⿲ (nth 1 enc-str) new-str-c (nth 3 enc-str))
1553 (setq a-res (ids-find-chars-including-ids new-str))
1558 (list ?⿲ (nth 1 enc-str) new-str-c (nth 3 enc-str))
1561 ((eq (car enc-str) ?⿴)
1562 (setq enc2-str (ideographic-character-get-structure (nth 1 enc-str)))
1564 (eq (car enc2-str) ?⿰))
1565 (unless conversion-only
1566 (setq f-res (ids-find-chars-including-ids enc-str)))
1567 (setq new-str (list ?⿱
1571 (if (setq ret (ideographic-structure-find-chars new-str))
1573 (list (cons 'ideographic-structure new-str))))
1575 (list ?⿲ (nth 1 enc2-str) new-str-c (nth 2 enc2-str))
1576 (setq a-res (ids-find-chars-including-ids new-str))
1581 (list ?⿲ (nth 1 enc2-str) new-str-c (nth 2 enc2-str))
1584 ((eq (car enc-str) ?⿵)
1585 (unless conversion-only
1586 (setq f-res (ids-find-chars-including-ids enc-str)))
1587 (setq new-str (list ?⿱
1591 (if (setq ret (ideographic-structure-find-chars new-str))
1593 (list (cons 'ideographic-structure new-str))))
1595 (list ?⿵ (nth 1 enc-str) new-str-c)
1596 (setq a-res (ids-find-chars-including-ids new-str))
1601 (list ?⿵ (nth 1 enc-str) new-str-c)
1606 ((eq (car structure) ?⿷)
1607 (setq enc (nth 1 structure))
1609 (cond ((characterp enc)
1610 (get-char-attribute enc 'ideographic-structure)
1613 (cdr (assq 'ideographic-structure enc))
1616 ((eq (car enc-str) ?⿺)
1617 (unless conversion-only
1618 (setq f-res (ids-find-chars-including-ids enc-str)))
1619 (setq new-str (list ?⿱
1623 (if (setq ret (ideographic-structure-find-chars new-str))
1625 (list (cons 'ideographic-structure new-str))))
1627 (list ?⿺ (nth 1 enc-str) new-str-c)
1628 (setq a-res (ids-find-chars-including-ids new-str))
1633 (list ?⿺ (nth 1 enc-str) new-str-c)
1636 ((eq (car enc-str) ?⿸)
1637 (unless conversion-only
1638 (setq f-res (ids-find-chars-including-ids enc-str)))
1640 ((and (characterp (nth 2 enc-str))
1641 (or (memq (char-ucs (nth 2 enc-str))
1642 '(#x4EBA #x5165 #x513F #x51E0))
1643 (memq (or (encode-char (nth 2 enc-str) '=>ucs@iwds-1)
1644 (encode-char (nth 2 enc-str) '=>ucs@component))
1646 (setq new-str (list ?⿺
1650 (if (setq ret (ideographic-structure-find-chars new-str))
1652 (list (cons 'ideographic-structure new-str))))
1654 (list ?⿸ (nth 1 enc-str) new-str-c)
1655 (setq a-res (ids-find-chars-including-ids new-str))
1660 (list ?⿸ (nth 1 enc-str) new-str-c)
1664 (setq new-str (list ?⿱
1668 (if (setq ret (ideographic-structure-find-chars new-str))
1670 (list (cons 'ideographic-structure new-str))))
1672 (list ?⿸ (nth 1 enc-str) new-str-c)
1673 (setq a-res (ids-find-chars-including-ids new-str))
1678 (list ?⿸ (nth 1 enc-str) new-str-c)
1684 ((eq (car structure) ?⿺)
1685 (setq enc (nth 1 structure))
1687 (cond ((characterp enc)
1688 (or (get-char-attribute enc 'ideographic-structure)
1689 (get-char-attribute enc 'ideographic-structure@apparent)
1690 (get-char-attribute enc 'ideographic-structure@apparent/leftmost))
1693 (or (cdr (assq 'ideographic-structure enc))
1694 (cdr (assq 'ideographic-structure@apparent enc))
1695 (cdr (assq 'ideographic-structure@apparent/leftmost enc)))
1698 ;; (mapcar (lambda (cell)
1699 ;; (or (and (listp cell)
1700 ;; (find-char cell))
1704 ((eq (car enc-str) ?⿱)
1706 ((and (characterp (nth 1 enc-str))
1707 (or (and (eq (char-ucs (nth 1 enc-str)) #x200CA)
1709 (and (eq (char-feature (nth 1 enc-str) '=>iwds-1) 233)
1710 (characterp (nth 2 structure))
1711 (eq (char-ucs (nth 2 structure)) #x4E36)
1713 (unless conversion-only
1714 (setq f-res (ids-find-chars-including-ids enc-str)))
1715 (setq new-str (list ?⿺
1719 (if (setq ret (ideographic-structure-find-chars new-str))
1721 (list (cons 'ideographic-structure new-str))))
1723 (list ?⿱ new-str-c (nth 2 enc-str))
1724 (setq a-res (ids-find-chars-including-ids new-str))
1729 (list ?⿱ new-str-c (nth 2 enc-str))
1732 ((and (characterp (nth 2 enc-str))
1733 (or (memq (char-ucs (nth 2 enc-str))
1736 #x65E5 #x66F0 #x5FC3
1737 #x2123C #x58EC #x738B #x7389))
1738 (memq (encode-char (nth 2 enc-str) '=>ucs@component)
1740 (eq (encode-char (nth 2 enc-str) '=>ucs@iwds-1)
1742 (eq (encode-char (nth 2 enc-str) '=>big5-cdp)
1744 (unless conversion-only
1745 (setq f-res (ids-find-chars-including-ids enc-str)))
1746 (setq new-str (list ?⿰
1750 (if (setq ret (ideographic-structure-find-chars new-str))
1752 (list (cons 'ideographic-structure new-str))))
1754 (list ?⿱ new-str-c (nth 2 enc-str))
1755 (setq a-res (ids-find-chars-including-ids new-str))
1760 (list ?⿱ new-str-c (nth 2 enc-str))
1765 ((eq (car structure) ?⿻)
1766 (setq enc (nth 1 structure))
1768 (cond ((characterp enc)
1769 (get-char-attribute enc 'ideographic-structure)
1772 (cdr (assq 'ideographic-structure enc))
1775 ((eq (car enc-str) ?⿱)
1776 (unless conversion-only
1777 (setq f-res (ids-find-chars-including-ids enc-str)))
1779 (list ?⿳ (nth 1 enc-str) (nth 2 structure) (nth 2 enc-str))
1799 ;;; ids-find.el ends here