update.
authoreto <eto>
Wed, 7 Jul 2004 23:57:07 +0000 (23:57 +0000)
committereto <eto>
Wed, 7 Jul 2004 23:57:07 +0000 (23:57 +0000)
chise/character.rb
chise/chisedb.rb
chise/ids.rb
chise/libchise.rb
chise/libchise_r.rb
test/test-libchise.rb

index 6fb8fbf..f3ac142 100755 (executable)
@@ -45,11 +45,9 @@ module CHISE
       raise if char_id < 0 # make sure char_id is positive.
       @char_id = char_id
       @char_id.freeze
-      # @utf8_mcs = CHISE.i_tou8(@char_id)
       @utf8_mcs = itou8(@char_id)
       @utf8_mcs.freeze
       @feature = {}
-      # @check_all_done = nil
     end
     attr_reader :char_id
     attr_reader :utf8_mcs
@@ -115,9 +113,7 @@ module CHISE
 
     def each_feature
       cd = ChiseDB.instance
-      #return
       cd.each_feature_name {|f|
-       #p f
        feature = cd.get_feature(f)
        begin
          v = feature.get_value(@char_id)
index 7d7715e..78a6e81 100755 (executable)
@@ -9,7 +9,7 @@ module CHISE
       return nil if v.nil?
       return v.to_i if /\A\d+\Z/ =~ v # number?
       return $1 if /\A"(.+)"\Z/ =~ v # remove surrounding "
-      v # sexp?
+      v # sexp? or the other?
     end
   end
 
@@ -37,7 +37,6 @@ module CHISE
     end
 
     def each_feature_name()
-#      setup_ds
       @ds.each_feature_name {|f|
        next if f.to_s == "." || f.to_s == ".."
        next if f.to_s =~ /\.txt\Z/
@@ -46,36 +45,30 @@ module CHISE
     end
 
     def each_ccs
-#      setup_ds
       each_entry("character/by_feature") {|f| yield(f) }
     end
 
     def get_feature(name)
-#      setup_ds
       @feature_db[name] = FeatureDB.new(self, name) if @feature_db[name].nil?
       @feature_db[name]
     end
 
     def load_feature(cid, name)
-#      setup_ds
       feature = get_feature(name)
       feature.get_value(cid)
     end
 
     def get_ccs(name)
-#      setup_ds
       @ccs_db[name] = CCS_DB.new(self, name) if @ccs_db[name].nil?
       @ccs_db[name]
     end
 
     def decode_char(ccs, code_point)
-#      setup_ds
       ccsdb = get_ccs(ccs)
       ccsdb.decode(code_point)
     end
 
     def get_by_ids_db(n)
-#      setup_ds
       @byids_db[n] = ByIDS_DB.new(self, n) if @byids_db[n].nil?
       @byids_db[n]
     end
index 0ccb8d6..7041073 100755 (executable)
@@ -29,50 +29,6 @@ module CHISE
   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 }
@@ -104,7 +60,8 @@ module CHISE
     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)
index 4b6e005..b26be17 100755 (executable)
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift("../ext")
 require "chise/libchise_r"
 begin
   require "libchise_c.so"
-  #raise LoadError # uncomment, if you'd like to use libchise_r.
+  raise LoadError # uncomment, if you'd like to use libchise_r.
   module CHISE
     DataSource = DataSource_C
     Feature = Feature_C
index d68c776..f6a0e45 100755 (executable)
@@ -96,6 +96,7 @@ module CHISE
       begin
        @db.sync
        @db.close
+       @db = nil
       rescue => e
        p e
       end
index 09daa13..ea4780f 100755 (executable)
@@ -19,8 +19,8 @@ class TestLibChise < Test::Unit::TestCase
     char_id = 0x4ECF
     feature = @ds.get_feature("ideographic-structure")
     assert_instance_of(CHISE::Feature, feature)
-    #assert_equal(true, feature.setup_db(0))
-    #assert_equal(true, feature.sync)
+    assert_equal(true, feature.setup_db(0))
+    assert_equal(true, feature.sync)
     value = feature.get_value(char_id)
     assert_equal("(?\342\277\260 ?\344\272\273 ?\345\216\266)", value)
 
@@ -60,8 +60,8 @@ class TestLibChise < Test::Unit::TestCase
     # get a character by Daikanwa number 364.
     ccs = @ds.get_ccs("=daikanwa")
     assert_instance_of(CHISE::CCS, ccs)
-    #assert_equal(true, ccs.setup_db(0))
-    #assert_equal(true, ccs.sync)
+    assert_equal(true, ccs.setup_db(0))
+    assert_equal(true, ccs.sync)
     char_id = ccs.decode(364)
     assert_equal(0x4ECF, char_id)