update.
[chise/ruby.git] / chise / idsdb.rb
index d53998d..9e97fe5 100755 (executable)
@@ -42,10 +42,13 @@ module CHISE
     def store_ids_as_text
       @idsdb.each_ccs {|ccs|
        qp ccs
+       i = 0
        @idsdb.get_ccs(ccs).each_character {|char, ids|
          next if ids == char.to_s
          next if ids.char_length == 1
          char.ids_text = ids # just set it.
+         i += 1
+         break if 10000 < i
        }
       }
       @cd.get_feature("ids-text").dump
@@ -66,7 +69,7 @@ module CHISE
     end
 
     def check_integrity_of_ids_tree
-      @cd.get_feature("ids-de-er").each {|cid, ids|
+      @cd.get_feature("ids-de-er").each_char {|cid, ids|
        char = Character.get(cid)
        idstree = IDS_Tree.new(ids)
        begin
@@ -77,39 +80,39 @@ module CHISE
          char.ids_error = e.message
          next
        end
-       char.ids = ids # set it.
+       char.ids_org = ids # set it.
       }
-      @cd.get_feature("ids").dump
+      @cd.get_feature("ids-org").dump
       @cd.get_feature("ids-error").dump
     end
 
     def make_by_ids_db
-      ct = @cd.get_by_ids_db("ids")
-      @cd.get_feature("ids").each {|cid, ids|
+      byidsdb = @cd.get_by_ids_db("ids-org")
+      @cd.get_feature("ids-org").each_char {|cid, ids|
        char = Character.get(cid)
-       ct.set_decoded_char(ids, cid)
+       byidsdb.set_decoded_char(ids, cid)
       }
-      ct.dump
+      byidsdb.dump
     end
 
     def store_ids_aggregated
-      @cd.get_feature("ids").each {|cid, ids|
+      @cd.get_feature("ids-org").each_char {|cid, ids|
        char = Character.get(cid)
        #ids = char.decompose
        #ids = char.ids
-       ag = ids.to_ids.aggregate
+       ag = ids.to_ids.aggregate("ids-org")
        #puts "#{char.to_s}\t#{ids}\t#{ag}"
-       char.ids_aggregated = ag
+       char.ids = ag # ids-aggregated
       }
-      @cd.get_feature("ids-aggregated").dump
+      @cd.get_feature("ids").dump
     end
 
     def store_ids_subparts
-      @cd.get_feature("ids").each {|cid, v|
+      @cd.get_feature("ids").each_char {|cid, v|
        char = Character.get(cid)
        pids = char.to_s # previous_ids
        ar = []
-       i = 0
+       i = 0 # only for infinite loop check
        loop {
          ids = pids.decompose
          break if ids == pids #これ以上分割できないようだったら終了〜。
@@ -126,7 +129,7 @@ module CHISE
 
     def store_ids_contained
       h = Hash.new
-      @cd.get_feature("ids-subparts").each {|cid, v|
+      @cd.get_feature("ids-subparts").each_char {|cid, v|
        char = Character.get(cid)
        parts = char.ids_subparts
        parts.each_char {|ch|
@@ -142,7 +145,6 @@ module CHISE
       }
       @cd.get_feature("ids-contained").dump
     end
-
   end
 
   class IDS_DB