(defun ideographic-structure-char= (c1 c2)
(or (eq c1 c2)
(and c1 c2
- (or (eq (char-ucs c1)(char-ucs c2))
- (let ((m1 (car (get-char-attribute c1 '<-radical)))
- (m2 (car (get-char-attribute c2 '<-radical))))
- (unless (characterp m1)
- (setq m1 (or (find-char m1))))
- (unless (characterp m2)
- (setq m2 (find-char m2)))
- (when (or m1 m2)
- (ideographic-structure-char= m1 m2)))))))
+ (let ((m1 (char-ucs c1))
+ (m2 (char-ucs c2)))
+ (or (and m1 m2
+ (eq m1 m2))
+ (progn
+ (setq m1 (car (get-char-attribute c1 '<-radical))
+ m2 (car (get-char-attribute c2 '<-radical)))
+ (unless (characterp m1)
+ (setq m1 (or (find-char m1))))
+ (unless (characterp m2)
+ (setq m2 (find-char m2)))
+ (when (or m1 m2)
+ (ideographic-structure-char= m1 m2))))))))
(defun ideographic-structure-member-compare-parts (part s-part)
(let (ret)
((setq ret (get-char-attribute s-part 'ideographic-structure))
(ideographic-structure-member part ret)))))
+;;;###autoload
(defun ideographic-structure-member (part structure)
+ "Return non-nil if PART is included in STRUCTURE."
(or (progn
(setq structure (cdr structure))
(ideographic-structure-member-compare-parts part (car structure)))
(ideographic-structure-member-compare-parts
part (car structure))))))
+
+;;;###autoload
+(defun ideographic-structure-repertoire-p (structure parts)
+ "Return non-nil if STRUCTURE can be constructed by a subset of PARTS."
+ (and structure
+ (let (ret s-part)
+ (catch 'tag
+ (while (setq structure (cdr structure))
+ (setq s-part (car structure))
+ (unless (characterp s-part)
+ (if (setq ret (find-char s-part))
+ (setq s-part ret)))
+ (unless (cond
+ ((listp s-part)
+ (if (setq ret (assq 'ideographic-structure s-part))
+ (ideographic-structure-repertoire-p
+ (cdr ret) parts)))
+ ((member* s-part parts
+ :test #'ideographic-structure-char=))
+ ((setq ret
+ (get-char-attribute s-part
+ 'ideographic-structure))
+ (ideographic-structure-repertoire-p ret parts)))
+ (throw 'tag nil)))
+ t))))
+
;;;###autoload
(defun ideographic-structure-search-chars (parts)
"Search Ideographs by PARTS."