November 2008
Intermediate to advanced
208 pages
4h 32m
English
This script will scan a text file and count the number of times each word appears in the document. There are several reasons to extract word counts, or word frequencies, from a document. One example is for the cryptographic analysis of a cipher text that has been encrypted with a shift cipher. I find word frequency to be interesting in my own writing, too. Running this script shows me which words I use most often and, with a few tweaks, can show those that are not part of my daily vocabulary.
unless ARGV[0] puts "\nYou need to include a file to test." puts "Usage: ruby wordFreq.rb file_to_test.txt" ...
Read now
Unlock full access