From: eto Date: Sat, 6 May 2006 05:46:08 +0000 (+0000) Subject: update. X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;p=chise%2Fruby.git update. --- diff --git a/ChangeLog b/ChangeLog new file mode 100755 index 0000000..a65c438 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,10 @@ +2006-05-06 Kouichirou Eto <2006 eto.com> + + * idsdb.rb: Adapt to libchise API. + * ids.rb: Ditto. + * config.rb: Ditto. + * chisedb.rb: Ditto. + +2006-05-06 Kouichirou Eto <2006 eto.com> + + * Add ChangeLog diff --git a/chise/chisedb.rb b/chise/chisedb.rb index 2969383..4b930a1 100755 --- a/chise/chisedb.rb +++ b/chise/chisedb.rb @@ -22,7 +22,8 @@ module CHISE setup_ds @feature_db = {} @ccs_db = {} - @byids_db = {} + # @byids_db = {} + @ccsstr_db = {} end attr_reader :ds, :location @@ -68,11 +69,17 @@ module CHISE ccsdb.decode(code_point) end - def get_by_ids_db(n) + def nuget_by_ids_db(n) @byids_db[n] = ByIDS_DB.new(self, n) if @byids_db[n].nil? @byids_db[n] end + def get_ccs_str(n) + @ccsstr_db[n] = CCS_STR.new(self, n) if @ccsstr_db[n].nil? +# @ccsstr_db[n] = CCS_STR_DB.new(self, n) if @ccsstr_db[n].nil? + @ccsstr_db[n] + end + private include EachEntryModule end @@ -166,7 +173,7 @@ module CHISE end end - class ByIDS_DB + class CCS_STR_DB include ParseValueModule include ChiseValue include TableAccessModule @@ -182,16 +189,16 @@ module CHISE } end - def decode(ids) + def get_by_str(str) setup_db return nil if @db.nil? - parse_c_string(@db.get(ids)) + parse_c_string(@db.get(str)) end - def set_decoded_char(ids, cid) + def set_by_str(str, cid) setup_db(true) raise "@db is nil." if @db.nil? - @db.put(ids, format_char_id(cid)) + @db.put(str, format_char_id(cid)) end def each_char @@ -202,4 +209,5 @@ module CHISE } end end + end diff --git a/chise/config.rb b/chise/config.rb index 1415367..c52395e 100755 --- a/chise/config.rb +++ b/chise/config.rb @@ -5,12 +5,12 @@ require "chise/version" module CHISE # on Winodws - #DB_DIR = "c:/chise/chise-db" # /character/feature/=ucs - #IDS_DIR = "c:/chise/ids" # /IDS-JIS-X0208-1990.txt + DB_DIR = "c:/chise/chise-db" # /character/feature/=ucs + IDS_DIR = "c:/chise/ids" # /IDS-JIS-X0208-1990.txt # on Unix - DB_DIR = "/usr/local/lib/xemacs-21.4.14/i686-pc-linux/chise-db" - IDS_DIR = "/home/eto/work/chise/ids" + #DB_DIR = "/usr/local/lib/xemacs-21.4.14/i686-pc-linux/chise-db" + #IDS_DIR = "/home/eto/work/chise/ids" def windows?() rp = RUBY_PLATFORM diff --git a/chise/ids.rb b/chise/ids.rb index 7041073..0c7e33a 100755 --- a/chise/ids.rb +++ b/chise/ids.rb @@ -43,8 +43,10 @@ module CHISE def compose(dbname="ids") ids = self.aggregate cd = ChiseDB.instance - byidsdb = cd.get_by_ids_db(dbname) - cid = byidsdb.decode(ids) + #byids = cd.get_by_ids_db(dbname) + byids = cd.get_ccs(dbname) + #cid = byids.decode(ids) + cid = byids.get_by_str(ids) return "" if cid.nil? # TO CHECK: why "", not nil? composed = Character.get(cid).to_s return "" if composed.nil? diff --git a/chise/idsdb.rb b/chise/idsdb.rb index 83a55c0..133b298 100755 --- a/chise/idsdb.rb +++ b/chise/idsdb.rb @@ -105,10 +105,10 @@ module CHISE def make_by_ids_db_org h = {} - byids = @cd.get_by_ids_db("ids-org") + byids = @cd.get_ccs_str("ids-org") @cd.get_feature("ids-org").each_char {|cid, ids| char = Character.get(cid) - byids.set_decoded_char(ids, cid) + byids.set_by_str(ids, cid) h[ids] = cid } qp h.length @@ -174,10 +174,10 @@ module CHISE end def make_by_ids_db - byids = @cd.get_by_ids_db("ids") + byids = @cd.get_ccs("ids") @cd.get_feature("ids").each_char {|cid, ids| char = Character.get(cid) - byids.set_decoded_char(ids, cid) + byids.set_by_str(ids, cid) } byids.dump end diff --git a/chise/path.rb b/chise/path.rb index 9e695f6..1d68d04 100755 --- a/chise/path.rb +++ b/chise/path.rb @@ -11,10 +11,10 @@ end class Pathname def escape - s = self.basename.to_s.gsub(/([\/%]+)/n){ + s = self.to_s.gsub(/([\/%]+)/n){ "%" + $1.unpack("H2" * $1.size).join("%").upcase } - Pathname.new(self.dirname+s) + Pathname.new(s) end def unescape # copied from cgi.rb diff --git a/test/test-idsdb.rb b/test/test-idsdb.rb index e03acd0..fb93f93 100755 --- a/test/test-idsdb.rb +++ b/test/test-idsdb.rb @@ -39,7 +39,7 @@ class TestIDS_DB_Management < Test::Unit::TestCase #man.store_ids_as_text # 172.024 : 177.618 86470 #man.store_ids_de_er # 47.99 : 38.926 81899 #man.check_integrity_of_ids_tree # 58.185 : 48.015 79417 - #man.make_by_ids_db_org # 29.572 : 24.511 75562 + man.make_by_ids_db_org # 29.572 : 24.511 75562 #man.store_ids_aggregated # 66.609 : 51.832 79417 #man.store_ids_subparts # 1638.966 : 959.413 79417 #man.store_ids_contained # 773.808 : 696.374 diff --git a/test/test-idstree.rb b/test/test-idstree.rb index 0c563a4..772f194 100755 --- a/test/test-idstree.rb +++ b/test/test-idstree.rb @@ -85,8 +85,8 @@ class TestIDSTree < Test::Unit::TestCase def test_ids_tree_by_character assert_equal(3, "⿳".char.idc_argument_number) - assert_equal("⿳士冖匕", "壱".ids) - assert_equal(3, "壱".ids.to_a[0].char.idc_argument_number) +# assert_equal("⿳士冖匕", "壱".ids) +# assert_equal(3, "壱".ids.to_a[0].char.idc_argument_number) assert_nil(CHISE::IDS_Tree.new("⿳士冖匕").check_integrity) assert_raise(RuntimeError, "unmatch leaves") { check_tree("⿳士冖") } assert_raise(RuntimeError, "extra nodes") { check_tree("⿳士冖匕匕") }