Newer
Older
3D_Braille / 3D_Braille / kana_Braille.rb
@natto natto on 16 Dec 2018 740 bytes all push
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

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


def contracted(str,gana)
  while true
    if Regexp.new(/(\S)(ャ|ュ|ョ)/)=~str
      cont=$1+$2
      str=$`+gana[cont][1]+gana[cont][0]+$'
    else
      break
    end
  end
  str
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