IDC_FLL = IDC_LL
IDC_O = IDC_OV
- class IDS_TEXT_DB < DB #======================================================================
+ class IDS_TEXT_DB < DB
include Singleton
+
IDS_LIST = "
IDS-UCS-Basic.txt
#IDS-UCS-Compat-Supplement.txt
IDS-Daikanwa-ho.txt
IDS-CBETA.txt
".split
+
def initialize()
super
@ids_list = IDS_LIST
end
}
end
+
def dump_text_all
each_file {|file|
dir = File.dirname(file) + "/../ids-new/"
}
}
end
+
def make_ids_error
each_file {|file|
dir = File.dirname(file) + "/../ids-error"
class IDS_DB < DB # BDB化したIDS DBを扱う
include Singleton
+
def initialize
@dbs = CharDB.instance
end
+
def make_ids_db
db = IDS_TEXT_DB.instance
db.each_file {|file|
@dbs.dump_db("ids-error") #テキスト化する
@dbs.dump_db("ids") #テキスト化する
end
+
def make_ids_reverse
h = Hash.new
@dbs.each("ids") {|k, v|
cdb.open_db("ids") #これが無いと、dump_dbされません。
cdb.dump_db("ids")
end
+
def char_sort(composed)
return composed if composed.char_length == 1
ar = composed.to_a
end
return ar2.join("")
end
+
def dump_ids_duplicated
open("ids-duplicated.txt", "w"){|out|
#out.binmode
}
}
end
+
def make_ids_aggregated
@dbs.each("ids") {|k, v|
char = k.char
}
@dbs.dump_db("ids-aggregated")
end
+
def dump_ids_aggregated
open("ids-aggregated.txt", "w"){|out|
#out.binmode
}
}
end
+
def make_ids_parts
@dbs.each("ids") {|k, v|
char = k.char
}
@dbs.dump_db("ids-parts")
end
+
def make_ids_contained
h = Hash.new
@dbs.each("ids-parts") {|k, v|
}
@dbs.dump_db("ids-contained")
end
+
def make_ids_decomposed
@dbs.each("ids") {|k, v|
char = k.char
}
@dbs.dump_db("ids-decomposed")
end
+
end
- class Node < Array #==================================木構造の中の一つの枝
+ class Node < Array # 木構造の中の一つの枝
def initialize(nodeleaf=nil, nodenum=nil)
super()
@nodeleaf = nodeleaf
end
end
attr_reader :nodenum
+
alias original_add <<
private :original_add
+
def <<(obj)
original_add(obj)
@nodenum -= 1 if @nodenum
end
+
def nodes
ar = []
ar << self.to_s
}
return ar
end
+
end
- class Tree #==================================================木構造を扱う
+ class Tree # 木構造を扱う
def initialize()
@root = Node.new()
@stack = [@root]
@leafnum = 0
@depth = 1 #stackの深さが最大になったところの値、木構造が無いときは1となる
end
+
def depth() @depth - 1 end
+
def add_node(nodeleaf=nil, nodenum=nil) #枝を追加
new_node = Node.new(nodeleaf, nodenum)
@stack.last << new_node
end
self
end
+
def end_node() #この枝は終り
@stack.pop
self
end
+
def add_leaf(a) #葉を追加
@stack.last << a
end_check()
self
end
+
def end_check()
n = @stack.last.nodenum
if n && n == 0
end_check() #再帰
end
end
+
def check_integrity
n = @stack.last.nodenum
return nil if @root.length == 0 #no tree is good tree
return "extra leaves" if @root.length != 1
return nil
end
+
def nodes
r = @root.nodes
r.shift
r
end
+
def sub_nodes
r = nodes
r.shift
r
end
+
def to_s() @root.to_s end
+
def inspect() @root.inspect end
end
super()
parse()
end
+
def parse()
@str.each_char {|ch|
char = Character.new(ch)
end
}
end
+
def is_ids?(obj)
return true if "+*".include?(obj.to_s) #テスト用ですかね
return true if obj.is_ids?
return false
end
+
def ids_operator_argc(obj)
return obj.ids_operator_argc if 0 < obj.ids_operator_argc
return 2 #テスト用ってことで
end
+
def check_integrity
r = super
return r if r #不完全がすでにわかっているならreturn
end
end
- class IDS #=========================================IDSそのものを扱うclass
+ class IDS # IDSそのものを扱うclass
def initialize(str) #IDS文字列をうけとる。
@str = str
end
+
def parse
end
+
def parse_x #柔軟型のParse. IDSキャラクターが前にきてなくてもよい。などなど。
end
end
@count = 0
@proc = proc
end
+
def count
@count += 1
if @max <= @count
@proc.call
end
end
- end
+ end
end