Skip to content

Instantly share code, notes, and snippets.

@stuckinthecloud
Created September 21, 2011 19:06
Show Gist options
  • Save stuckinthecloud/1233004 to your computer and use it in GitHub Desktop.
Save stuckinthecloud/1233004 to your computer and use it in GitHub Desktop.
Final Refactor
Dir.glob("files/*.txt").each do |text_file| # Iterate through all text files
text = File.read(text_file)
basename = File.basename(text_file, '.txt').capitalize.gsub('_', ' ')
sentences = text.gsub(/\s+/, ' ').strip.split(/\.|\?|!/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment