end
class Character #=============================================================== 文字オブジェクト
+ BASIC_KANJI = "人子女母父王口耳手足力目首毛心犬牛鳥貝角羽虫馬魚羊肉皮米竹木麦豆山川雨風水土石金田穴日月火音糸刀舟門戸衣矢弓車皿一二三四五六七八九十百千万寸尺上中下本玉立回食行止交向歩考入示走生出来書言大小白青多少高長"
+ COMPOSIT_KANJI = "鳴名加品古知問間聞取兄見切分粉貧林森校東明住位好岩砂里男畑習休短空坂島倉美孝赤看光初努協解新歌語話張強忘悲答晴現正字安守灰秋秒困国医包同合舌居右左受友反道返迷花菜集机主太氷州点店庫仕帳幼防引配早直班筆重番北化比死夏後進酒福私家世内谷半原前寺思電雲気布旅衆泣"
+ def is_basic_kanji?
+ BASIC_KANJI.include?(self.to_s)
+ end
+
def initialize(char_id=nil)
@char_id = Character.parse_char_id(char_id)
@attributes = Hash.new
str
end
+ def inspect_ids(hex_flag=false)
+ ids = decompose
+ ar = []
+ ar << (hex_flag ? mcs_hex : to_utf8)
+ if to_s != ids #idsが部品そのものだったら部品追加はしない
+ ids.each_char {|ch|
+ char = ch.char
+ next if char.is_ids?
+ if hex_flag then
+ ar << char.mcs_hex
+ else
+ u = char.to_utf8
+ if u != ""
+ ar << u
+ else
+# ar << char.to_s
+ ar << char.to_er
+ end
+ end
+ }
+ end
+ return "("+ar.join("\t")+")"
+ end
+
#----------------------------------------------------------------------IDS関係
def decompose
k = self.to_s
# idss = self['ids']
# return idss if idss
+ return k if self.is_basic_kanji? #基本漢字はstop kanjiとするぞと。
+
idss = self['ids-aggregated']
return idss if idss != nil && 0 < idss.length && k != idss
idss = self['ids']
end
end
- class DBS_MANAGEMENT #======================================================================ファイル管理
+ class DBS_Management #======================================================================ファイル管理
OBSOLETE_ATTRIBUTES = "
cns-radical
cns-radical?
end
end
+ class JoyoList
+ include Singleton
+ #JP_JOYO_FILE = DB_DIR+"/../jp-joyo.txt" #EUC-jisx0213
+ JP_JOYO_FILE = DB_DIR+"/../joyo-ucs.txt" #UCS
+ def initialize
+ @nchars = []
+ read_file
+ end
+ attr_reader :nchars
+ def read_file
+ open(JP_JOYO_FILE) {|f|
+ while line = f.gets
+ next if line =~ /^;/ #コメントはとばす
+ line.chomp!
+ #stroke, nchar, ochar = line.split #new char, old char, old charはnilが多い
+ stroke, nchar = line.split
+ @nchars << nchar
+ end
+ }
+ end
+ def each_char
+ @nchars.each {|ch|
+ yield(ch)
+ }
+ end
+ def dump_all_ids(hex_flag=false)
+ each_char {|ch|
+ char = ch.char
+# print char.inspect_ids(hex_flag), "\n"
+ print char.inspect_ids(true), "\t;", char.inspect_ids(false), "\n"
+ }
+ end
+ end
+
end
#----------------------------------------------------------------------終了