1 # Copyright (C) 2002-2004 Kouichirou Eto, All rights reserved.
6 require "chise/management"
9 class IDS_DB_Management
11 @cd = ChiseDB.instance
12 @idsdb = IDS_DB.instance
15 def check_conflict_of_ids_text
16 @idsdb.each_ccs {|ccs|
20 @idsdb.get_ccs(ccs).each_character {|char, ids|
22 next if ids == char.to_s
23 next if ids.char_length == 1
24 char_id = char.char_id
26 if cids.nil? # There is no ids yet.
27 h[char_id] = ids # just set it.
29 else # but, if there is already a ids?
30 if cids == ids # the two are same.
31 c["same"] += 1 # and just ignore
32 else # but, if the two are not same?
34 puts "conflict\t#{char.to_s}\t#{ids}\t#{cids}"
38 puts "#{ccs}\t#{c['char']}\t#{c['same']}\t#{c['conflict']}\t#{c['good']}"
43 @idsdb.each_ccs {|ccs|
45 @idsdb.get_ccs(ccs).each_character {|char, ids|
46 next if ids == char.to_s
47 next if ids.char_length == 1
48 char.ids_text = ids # just set it.
51 @cd.get_feature("ids-text").dump
55 @cd.get_feature("ids-text").each {|cid, idser|
56 char = Character.get(cid)
58 ids = idser.de_er # parse Entity Reference
63 char.ids_de_er = ids # set it.
65 @cd.get_feature("ids-de-er").dump
68 def check_integrity_of_ids_tree
69 @cd.get_feature("ids-de-er").each {|cid, ids|
70 char = Character.get(cid)
71 idstree = IDS_Tree.new(ids)
73 raise "contains self" if ids.include?(char.to_s)
74 idstree.check_integrity
76 #puts "#{cid}\t#{e.message}\t#{ids}"
77 char.ids_error = e.message
80 char.ids = ids # set it.
82 @cd.get_feature("ids").dump
83 @cd.get_feature("ids-error").dump
87 ct = @cd.get_by_ids_db("ids")
88 @cd.get_feature("ids").each {|cid, ids|
89 char = Character.get(cid)
90 ct.set_decoded_char(ids, cid)
100 @config = Config.instance
101 @path = @config.ids_dir.path
107 @dbs[ccs] = IDS_CCS_DB.new(self, ccs) if @dbs[ccs].nil?
112 @path.each_entry {|f|
113 next unless /\AIDS-(.+)\.txt\Z/ =~ f
120 def initialize(idsdb, ccs)
121 @idsdb, @ccs = idsdb, ccs
122 @path = @idsdb.path+("IDS-"+ccs+".txt")
128 next if /\A;/ =~ line # skip comment
130 code, picture, ids = line.split
139 each_line {|code, ids|
141 next if ids == "" # If there is no IDS, ignore it.
145 char = Character.get(er)