The task is to write a program using the computer language C++ that will help us contrast two human languages: English and French. To this end, we will analyze two language versions of the book "On the Origin of Species", by Charles Darwin.
The book is in the public domain and can be retrieved in either language from the Gutenberg project: http://www.gutenberg.org/cache/epub/1228/pg1228.txt http://www.gutenberg.org/cache/epub/14158/pg14158.txt
Download the files to your computer. The files are in plain text. Have a peek by opening each file with either Notepad or Wordpad. Then write a C++ program that works in the following way:
1. Define a C++ function with the name evaluateBook. The function receives as one argument the name of the file to be processed (i.e., the book's file). So that if you pass the English version, we will see the results only for that language.
2. Function evaluateBook opens the file, reads it, analyzes it, and prints the answer to the following questions:
1. What it the total number of text lines in the file?
2. What it the number of text lines without any lower-case letter? To answer this question, write and call the function testLowerCase.
3. What it the number of text lines without any number? To answer this question, write and call the function testNumber.
4. What is the total number of visible characters (so, excluding invisible codes such as '\n') ? To answer this question, write and call the function countCharacters.
5. What is the total number of letters (i.e., excluding symbols, numbers, etc.)? To answer this question, write and call the function countLetters. 6. How many times each of the following punctuation symbols appear: comma, period, double quotes, single quotes ?
7. What is the most popular letter (regardless of its case) ?
8. The word "et" in French means "and". How many times does this word appear? The function should search for both words, so that if you pass the English version, the count for "et" will be likely zero. Also, ignore the case, but do not count a matching if part of another word, such as "Andrew".
3. You need to write the functions testLowerCase, testNumber, countCharacters, countLetters, which you will call from evaluateBook. The function's argument for each of them is the current line from the textbook that is being processed (as a string). The function then must return a boolean with the result of the test.
4. Call the function evaluateBook from main, first with the English version pg1228.txt and then with the French version pg14158.txt so that we can contrast the results for each language on the screen