+
+ def ids_tree() IDS_Tree.new(self); end
+
+ def compose(dbname="ids")
+ ids = self.aggregate
+ cd = ChiseDB.instance
+ byidsdb = cd.get_by_ids_db(dbname)
+ cid = byidsdb.decode(ids)
+ return "" if cid.nil? # TO CHECK: why "", not nil?
+ composed = Character.get(cid).to_s
+ return "" if composed.nil?
+ return "" if composed.char_length == 0
+ return composed if composed.char_length == 1
+ composed.each_char {|ch|
+ char = ch.char
+ return ch # TO CHECK: the first character?
+ }
+ "" # TO CHECK: why "", not nil?
+ end
+
+ def aggregate(dbname="ids")
+ # In each sub part of IDS, search the corresponding char_id.
+ # If you could search the corresponding char_id, substitute with it.
+ tree = self.ids_tree
+ return self if tree.depth <= 1 # no sub_node
+ tree.sub_nodes.each {|node|
+ c = node.compose(dbname)
+ next if c.nil? || c == ""
+ n = self.gsub(node, c)
+ return n.aggregate(dbname)
+ }
+ self
+ end
+
+ def find() # "日雲"→"曇"とかいう感じの操作
+ ar = []
+ length = char_length()
+ each_char {|ch|
+ char = ch.char
+ ar << char.ids_contained #その文字を含んでいる漢字のリスト
+ }
+ h = Hash.new(0)
+ #qp ar
+ ar.each {|list|
+ next if list.nil?
+ list.each_char {|ch|
+ h[ch] += 1
+ }
+ }
+ str = ""
+ h.each {|k, v|
+ # p [k, v]
+ if length == v #全部に顔を出していたら
+ str += k
+ end
+ }
+ # p str
+ str
+ end