Question: Project 5: Concordance (using std::multimap ), use #include Introduction The Standard Library provides sets, multisets, maps, and multimaps, which are all typically implemented as balanced

Project 5: Concordance (using std::multimap), use #include

Introduction

The Standard Library provides sets, multisets, maps, and multimaps, which are all typically implemented as balanced binary search trees. Maps and multimaps are associative containers, that associate a key with a value. Multimaps are different from maps in that they allow multiple values for a given key.

Concordance

A concordance is an alphabetical list of the words in a text, with citations of the passages concerned. It is more useful if the words are first sorted by length, then alphabetically. Here is a sample output of the program you will write (analyzing the Gettysburg Address). (Compare it to your own writing.)

//------------------------------------ // 7 LETTER WORDS... //------------------------------------ brought: 1 created: 1 detract: 5 engaged: 3 fathers: 1 fitting: 3 freedom: 5 honored: 5 liberty: 1 measure: 5 portion: 3 resolve: 5 resting: 3 testing: 3 whether: 3 ... 15 words with size: 7 //------------------------------------ // 8 LETTER WORDS... //------------------------------------ advanced: 5 dedicate: 3 5 devotion: 5 remember: 5 ... 4 words with size: 8 //------------------------------------ // 9 LETTER WORDS... //------------------------------------ conceived: 1 3 continent: 1 dedicated: 1 3 5 increased: 5 remaining: 5 struggled: 5 ... 6 words with size: 9 //------------------------------------ // 10 LETTER WORDS... //------------------------------------ altogether: 3 consecrate: 5

Project 5: Concordance

page 1 of 5

government: 5 unfinished: 5 ... 4 words with size: 10 ... //------------------------------------ // WORD LENGTH DISTRO Len: 1 -- Len: 2 -- Len: 3 -- Len: 4 -- Len: 5 -- Len: 6 -- Len: 7 -- Len: 8 -- Len: 9 -- Len: 10 -- 1 word 15 words 23 words 24 words 28 words 16 words 15 words 4 words 6 words 4 words

The numbers next to each word indicate the line numbers at which the word was found.

Objective

You are given a partial implementation of a concordance class. It contains the class declaration, the minimum and maximum length of words to analyze (e.g., from 4 letter words to 12 letter words), a multimap (std::multimap), and a vector (std::vector). The StringLenCmp class is provided. The vector counts how many unique words of each length occurred (it doesnt count the number of times that word occurred). The Comparator class only defines operator(), sometimes called the function call operator. As you can see from the code, its only job is to tell the multimap to sort the entries first by word length, then alphabetically. Nothing to it!

Your job is to complete the concordance class (concordance.h), so that it correctly calculates the number of words in three separate pieces of text, all from the book: Harry Potter and the Sorcerors Stone. The first piece of text is the first paragraph from the book. The second piece is the first page (and a bit more to finish the paragraph). The last piece is the entire first chapter from the book.

Source Code Files

You are given skeleton code files with declarations that may be incomplete and without any implementation. Implement the code and ensure that all the tests in main.cpp pass successfully.

concordance.h:Thisistobecompleted Note:thefunctionstoreadfromafileandsplitalineintowordsisalreadygiventoyou.

You need to implement the remaining 4 public member functions.

main.cpp:Thiscallsatestfunction(inmain.cpp)thatteststheoutputofyourconcordance

class. You may wish to add additional tests, based on the ones already provided.

README.md:YoumusteditthisfiletoincludethenameandCSUFemailofeachstudentin

your group. Do this even if you are working by yourself. This information will be used so that we can enter your grades into Titanium.

Hints

As you start implementing the concordance class, comment out the tests in main.cpp that you havent implemented yet in your class. As you fill in the code for your class, uncomment the matching tests to make sure your class is working. Keep testing your code as you implement it. It is much easier to debug one method in your class than all of the methods at the same time.

Project 5: Concordance page 2 of 5

Do not wait till the very end to test your code. Speak to your teachers if you need help designing your approach, or are having trouble compiling or debugging your code. const errors can frequently prevent your code from compiling. Note also that it is possible to be 95% of the way finished, but have the impression you are miles away. Your instructor can help you get over that final 5% if you need help. Dont hesitate to ask.

Expected output

There are two types of output: 1) the counts of words of each length and 2) the list of words sorted by length along with their page numbers.

Word counts

When you complete your project, all of the tests of word counts should run correctly. Expected output is shown below, for the concordance of all three input files.

hp1_paragraph words with length... PASSED ...para words with length 1: expected and received 0 PASSED ...para words with length 2: expected and received 6 PASSED ...para words with length 3: expected and received 5 PASSED ...para words with length 4: expected and received 11 PASSED ...para words with length 5: expected and received 4 PASSED ...para words with length 6: expected and received 6 PASSED ...para words with length 7: expected and received 3 PASSED ...para words with length 8: expected and received 3 PASSED ...para words with length 9: expected and received 1 PASSED ...para words with length 10: expected and received 1 PASSED hp1_para total words: expected and received 40 hp1_page words with length... PASSED ...page words with length 1: expected and received 1 PASSED ...page words with length 2: expected and received 15 PASSED ...page words with length 3: expected and received 30 PASSED ...page words with length 4: expected and received 48 PASSED ...page words with length 5: expected and received 30 PASSED ...page words with length 6: expected and received 40 PASSED ...page words with length 7: expected and received 20 PASSED ...page words with length 8: expected and received 17 PASSED ...page words with length 9: expected and received 9 PASSED ...page words with length 10: expected and received 2 PASSED ...page words with length 11: expected and received 0 PASSED ...page words with length 12: expected and received 1 PASSED ...page words with length 13: expected and received 0 PASSED ...page words with length 14: expected and received 0 PASSED ...page words with length 15: expected and received 0

Project 5: Concordance

page 3 of 5

PASSED hp1_page1 total words: expected and received 213 hp1_chapter words with length... PASSED ...chapter words with length 1: expected and received 3 PASSED ...chapter words with length 2: expected and received 28 PASSED ...chapter words with length 3: expected and received 96 PASSED ...chapter words with length 4: expected and received 222 PASSED ...chapter words with length 5: expected and received 205 PASSED ...chapter words with length 6: expected and received 207 PASSED ...chapter words with length 7: expected and received 184 PASSED ...chapter words with length 8: expected and received 122 PASSED ...chapter words with length 9: expected and received 62 PASSED ...chapter words with length 10: expected and received 26 PASSED ...chapter words with length 11: expected and received 12 PASSED ...chapter words with length 12: expected and received 7 PASSED ...chapter words with length 13: expected and received 3 PASSED ...chapter words with length 14: expected and received 1 PASSED ...chapter words with length 15: expected and received 0 PASSED hp1_chapter1 total words: expected and received 1179 PASSED Total tests passed: expected and received 43

...done.

Printing the concordance

In addition to the automated tests of word counts, you are also expected to print the list of words and page numbers by iterating through the multimap. The challenge is to print only once and not to repeat page numbers. Sample output is shown in this file.

Obtaining and submitting code

Click the assignment link to fork your own copy of the skeleton code to your PC.

https://classroom.github.com/g/iLilP4cS

Development environment

The test platform is Linux with the g++ -std=c++14 compiler. For this reason, the recommended development platform is Linux.

Linux environment

To attempt to compile the test program, use the following command:

g++ -std=c++14 main.cpp -o test

To attempt to run the compiled test program, use the following command:

./test

Project 5: Concordance

page 4 of 5

Grading rubric

Your grade will be comprised of two parts, Form and Function. Function refers to whether your code works properly as tested by the main function (80%). Form refers to the design, organization, and presentation of your code. An instructor will read your code and evaluate these aspects of your submission (20%).

Deadline The project deadline is November 28th at 11:55pm.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!