An example implementation of the text-analysis project.
textalyze.rbis the source code for this projecttextalyze_test.rbcontains tests for the code intextalyze.rbsample_datais a directory containing sample text files to analyze, mostly from Project Gutenberg.
$ ruby textalyze.rb <text file>
Where <text file> is the filename of a plain-text file to be analyzed.
Displays a histogram chart of frequencies for each alphanumeric character in the text provided.
$ ruby textalyze.rb ./sample_data/moby-dick.txt
The counts for ./sample_data/moby-dick.txt are...
a [ 8.26%] ############################################
b [ 1.43%] #######
c [ 2.29%] ############
# ...
Tests are in the textalyze_test.rb file.
$ ruby textalyze_test.rb
Running tests for frequencies()...
true
true
# ...