Newer
Older
3D_Braille / mecabarry.rb
@natto natto on 10 Nov 2018 706 bytes all_tenji_system
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

def seiku(file)
  kaesu=Hash.new 
  open(file,"r:utf-8") do |ha|
    while iindesuka=ha.gets
      if/(\S+)\s+(\S+)\s+(\S+)/=~iindesuka
        kaesu[$1]=[$2,$3]
        
      end
    end
  end
   kaesu
end


def youon(b,c)
  while true
    if Regexp.new(/(\S)(ャ|ュ|ョ)/)=~b 
      a=$1+$2
      b=$`+c[a][1]+c[a][0]+$'
    else
      break
    end
  end
  b
end

def tenji(br_file)  
  ch=Hash.new
  open(br_file, "r:utf-8") do |read|
    while line = read.gets
      if /^(\S+),(\d,\d,\d,\d,\d,\d)/ =~ line
        ch[$1] = $2.split(/,/)
      elsif /(\s+),(\d,\d,\d,\d,\d,\d)/ =~ line
        ch[$1] = $2.split(/,/)
      end
    end
  end
  ch
end