Last active
February 27, 2019 13:03
-
-
Save peterc/bf495244dd098cdd7ddca241dab33446 to your computer and use it in GitHub Desktop.
Turns a11y-style text back into English. Or tries to, anyway.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ruby s4d.rb "h3o w3d" 5 | |
text = ARGV.first || "y1u a5t p1l? j2t w4d to s1y hi" | |
times = (ARGV[1] || 1).to_i | |
words = File.readlines('/usr/share/dict/words') | |
.map(&:downcase) | |
.map(&:chomp) | |
times.times do | |
puts text.gsub(/\w+/) { |word| | |
words.select { |realword| | |
realword.start_with?(word[0]) && | |
realword.end_with?(word[-1]) && | |
realword.length == word[1..-2].to_i + 2 | |
}.sample | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
c1n y1u t2l w2t t2s s2s?