Method: Textbringer::TCodeInputMethod#setup_dictionaries

Defined in:
lib/textbringer/input_methods/t_code_input_method.rb

#setup_dictionariesObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/textbringer/input_methods/t_code_input_method.rb', line 24

def setup_dictionaries
  data_dir = CONFIG[:t_code_data_dir] ||
    File.expand_path("~/.textbringer/tcode")
  bushu_path = File.join(data_dir, "bushu.rev")
  mazegaki_path = File.join(data_dir, "mazegaki.dic")
  if BUSHU_DIC.empty?
    File.open(bushu_path) do |f|
      f.each_line do |line|
        x, *xs = line.chomp.chars
        BUSHU_DIC[xs.sort.join] = x
      end
    end
  end
  if MAZEGAKI_DIC.empty?
    File.open(mazegaki_path) do |f|
      f.each_line do |line|
        x, y = line.split
        MAZEGAKI_DIC[x] = y
      end
    end
  end
end