Skip to content

Latest commit

 

History

History
45 lines (31 loc) · 1.05 KB

File metadata and controls

45 lines (31 loc) · 1.05 KB

Analyzing Text in Ruby

An example implementation of the text-analysis project.

Files In This Repository

  1. textalyze.rb is the source code for this project
  2. textalyze_test.rb contains tests for the code in textalyze.rb
  3. sample_data is a directory containing sample text files to analyze, mostly from Project Gutenberg.

Usage

$ 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.

Example

$ 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

Tests are in the textalyze_test.rb file.

$ ruby textalyze_test.rb

Running tests for frequencies()...
true
true
# ...