def tree() IDS_Tree.new(@ids); end
- def compose
- ids = @ids
+ def compose(dbname="ids")
cd = ChiseDB.instance
- ct = cd.get_by_ids_db("ids")
- cid = ct.decode(ids)
- return "" if cid.nil?
+ 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
composed.each_char {|ch|
char = ch.char
#return ch if char.has_attribute?
- return ch
+ return ch # TO CHECK: the first character?
}
return ""
end
- def aggregate
- # Take each sub part of String.
- # If you can aggregate the sub part, aggregate it.
- #tree = IDS_Tree.new(@ids)
+ 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
+ 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
+ return n.to_ids.aggregate(dbname)
}
@ids
end
ids = self.ids_meaning
return ids if ids && 0 < ids.length && k != ids
end
- ids = self.ids_aggregated
- return ids if ids && 0 < ids.length && k != ids
ids = self.ids
return ids if ids && 0 < ids.length && k != ids
+ ids = self.ids_org
+ return ids if ids && 0 < ids.length && k != ids
k
#return k if ids.nil? || ids.length == 0 || k == ids