A text analyser

The problem

Build a tool that reads a text file and reports its word count, its most common words and its longest lines.

Requirements

Technologies

Step by step

  1. Read the file line by line with getline, and count the lines and characters.
  2. Write a function that cleans a word by lower-casing it and removing punctuation.
  3. Split each line with a string stream, and count the words in a map.
  4. Copy the map into a vector of pairs.
  5. Sort the vector with a compare function, by count and then by word.
  6. Print the top ten with setw.
  7. Test with an empty file and with a file that does not exist.

Expected result

A useful tool that summarises any text file, built almost entirely from the standard library.

How it is evaluated

Ways to improve it