Question: Preface This lab is based on Learn By Doing 1 3 . 1 0 Exercise 1 and a famous nifty assignment on authorship detection. In
Preface
This lab is based on Learn By Doing Exercise and a famous nifty assignment on authorship detection. In this part of the lab, you will create and store an array of AuthorStats structs on the heap, and use them to find the author who most likely wrote the mystery file.
Purpose
This lab is an opportunity for you to practice your skills in
Using header files
Creating an array of Structs on the heap
Writing a simple optimization algorithm
file processing
You will write this lab building on lab
Data
authorStats.txt Download authorStats.txt
Minimize File Preview
Jane Austen
Lewis Carroll
Charles Dickens
Agatha Christie
Brothers Grimm
Tasks
Part :
Create a copy of your lab project and call it lab If you havent downloaded all five mystery files and the author stats file, please download them now. Create a h file, and in that file create a struct to store author stats including first and last name, average word length, type token ratio, and hapax legomena ratio. Cut and past the define, include, and using statements from labcpp into the new h file. Add a method header for a method with the following signature:
int loadAuthorStatsAuthorStats authorInfo, int & numAuthors;
Include the new h file in your cpp file.
Part :
Create an array of pointers to pointers of AuthorStats objects, an integer to track the number of authors max and write the line of code to call load Author Stats. Write the load AuthorStats function. This function should allocate space on the heap for the authorstats, and copy from the file authorstats.txt to the array of structures on the heap. The method should require approximately lines of code. You are encouraged to use struct syntax including objectproperty instead of objectproperty.
Part :
Your goal is to find the author from your author stats list with the stats most similar to the stats of the mystery file. In this algorithm, you will be looking for a similarity that is the minimal difference. Because the numbers for averageWordLength are quite a bit bigger than the other stats, we will be weighting the numbers so that all can contribute to the similarity score. You will need to take the absolute value of the difference of each authors stats and the stats of the text. You will weight the averageWordLength by multiplying it by the typeTokenRatio by multiplying it by and the HapaxLegoMana ratio by multiplying it by For mystery with Jane Austen, the similarity score should be You should print a sentence of the form This text was most likely written by You do not need to print the similarity score. This should be about lines of code. You are STRONGLY encouraged to deallocate memory that you have allocated, but I am NOT going to double check with the debug flags for this lab. Estimated to be about lines of code. You are also STRONGLY encouraged to run the lab with all mystery texts which texts lead to correctincorrect author identifications? Again, I will NOT deduct for not running with all texts. You must be able to run for mystery and one other file of your choice.
Submission and Criteria
Create a Zip file with your h your cpp and a READMEtxt that lists the fileNames of the mystery files you tested, the predicted author by your algorithm, and the actual author. Submit your zip file to Canvas.
Attendance and submission is worth of your final grade. Each part is worth of your final grade.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
