Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- qwerty = '1234567890-^\\qwertyuiop@[asdfghjkl;:]zxcvbnm,./\\!"#$%&\'()=~|QWERTYUIOP`{ASDFGHJKL+*}ZXCVBNM<>?_"'
- dvorak = '1234567890@^¥:,.pyfgcrl/[aoeuidhtns-];qjkxbmwvz\\!"#$%&\'()`~|*<>PYFGCRL?{AOEUIDHTNS=}+QJKXBMWVZ_'
- def convert(input, from_map, to_map)
- return input.each_char.map {|c|
- index = from_map.each_char.find_index{|e| e == c }
- next to_map[index]
- }.join('')
- end
- input = File::open(ARGV[0], "r")
- input.each_line do |line|
- input, output, next_input = line.split(/\s/)
- converted_input = convert(input, qwerty, dvorak) if input
- converted_next_input = convert(next_input, qwerty, dvorak) if next_input
- puts [converted_input, output, converted_next_input].join("\t")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement