IDC_SURROUND_FROM_LOWER_LEFT = IDC_A
IDC_OVERLAID = IDC_B
- class Nu_IDS
- def initialize(ids)
- @ids = ids
- @ids.freeze
- end
-
- def tree() IDS_Tree.new(@ids); end
-
- def compose(dbname="ids")
- ids = @ids.to_ids.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 if char.has_attribute?
- return ch # TO CHECK: the first character?
- }
- return ""
- 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.tree
- return @ids if tree.depth <= 1 # no sub_node
- tree.sub_nodes.each {|node|
- c = node.to_ids.compose(dbname)
- next if c.nil? || c == ""
- # print "#{@ids} #{node} #{c}\n"
- # p [@ids, node, c]
- n = @ids.gsub(node, c)
- return n.to_ids.aggregate(dbname)
- }
- @ids
- end
- end
-
module StringIDS
def decompose
map_char {|ch| ch.char.decompose }
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
+ #tree = self.ids_tree
+ tree = IDS_Tree.new(self)
return self if tree.depth <= 1 # no sub_node
tree.sub_nodes.each {|node|
c = node.compose(dbname)