Skip to content

Instantly share code, notes, and snippets.

@abachman
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abachman/1e6e11188fd2eb123734 to your computer and use it in GitHub Desktop.
Save abachman/1e6e11188fd2eb123734 to your computer and use it in GitHub Desktop.
Deacronym
#!/bin/env ruby
# Usage:
#
# $ deacronym ASDF
# Attracted Shrinking Development Finish
#
# You'll need your own copy of Seasoning of Wood by J.B. Wagner
# http://www.gutenberg.org/ebooks/26598
# lexicon = File.read(File.join ENV['HOME'], '/Documents/seasoning_of_wood.txt').
# OR Wizard People, Dear Reader
# http://www.erikkennedy.com/wizardpeopledearreaders.html
lexicon = File.read(File.join ENV['HOME'], '/Documents/wizard_people.txt').
split(/[^a-zA-Z']/).
# get rid of non-word characters
map {|w| w.downcase.gsub(/[^a-z']/, '')}.
# get rid of short words, they are not interesting
reject {|w| w.size < 4}.
sort.
uniq
lexicon_hash = {}
lexicon.each {|word|
lexicon_hash[word[0]] ||= []
lexicon_hash[word[0]] << word
}
(ARGV[1] || 4).to_i.times do
puts ARGV[0].split('').map {|l| lexicon_hash[l.downcase].sample.capitalize}.join ' '
end
@jjulian
Copy link

jjulian commented May 23, 2014

There's a hashtag generator in here somewhere....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment