Advertisement
Guest User

Untitled

a guest
Aug 5th, 2015
1,286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. qwerty = '1234567890-^\\qwertyuiop@[asdfghjkl;:]zxcvbnm,./\\!"#$%&\'()=~|QWERTYUIOP`{ASDFGHJKL+*}ZXCVBNM<>?_"'
  2. dvorak = '1234567890@^¥:,.pyfgcrl/[aoeuidhtns-];qjkxbmwvz\\!"#$%&\'()`~|*<>PYFGCRL?{AOEUIDHTNS=}+QJKXBMWVZ_'
  3.  
  4. def convert(input, from_map, to_map)
  5. return input.each_char.map {|c|
  6. index = from_map.each_char.find_index{|e| e == c }
  7. next to_map[index]
  8. }.join('')
  9. end
  10.  
  11. input = File::open(ARGV[0], "r")
  12.  
  13. input.each_line do |line|
  14. input, output, next_input = line.split(/\s/)
  15.  
  16. converted_input = convert(input, qwerty, dvorak) if input
  17. converted_next_input = convert(next_input, qwerty, dvorak) if next_input
  18.  
  19. puts [converted_input, output, converted_next_input].join("\t")
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement