2 # Copyright (C) 2002-2004 Kouichirou Eto, All rights reserved.
4 require "libchise_c.so"
6 DataSource = DataSource_C
11 $LOAD_PATH.unshift("..")
16 @ds.close unless @ds.nil?
21 db_dir = CHISE::DataSource::DB_DIR
22 @ds = CHISE::DataSource.new(CHISE::DataSource::Berkeley_DB, db_dir, 0, 0755)
23 die "Can't open data source" if @ds.nil?
25 # get a character by Daikanwa number 364.
27 char_id = @ds.decode_char("=daikanwa", 364)
29 ccs = @ds.get_ccs("=daikanwa")
30 die "Can't open CCS =daikanwa" if ccs.nil?
31 char_id = ccs.decode(364)
35 ft = @ds.get_feature("ideographic-structure")
36 value = ft.get_value(char_id)
37 printf("#x%X => %s\n", char_id, value)
39 @ds.each_feature_name {|name|
40 puts "feature : "+name
43 ft = @ds.get_feature("numeric-value")
44 ft.each_char {|cid, valdatum|
45 printf("#x%08X ", cid)
47 ucs = @ds.get_feature("=ucs").get_value(cid)
49 printf("[U-%08X]", ucs.to_i)
51 ucs = @ds.get_feature("=>ucs").get_value(cid)
53 printf("(U-%08X)", ucs.to_i)
59 printf(" %s", @ds.get_feature("name").get_value(cid))
60 printf(" %s\n", valdatum)