Design and develop an Object-Oriented C++ program that prepares a concordance of all the words in
any user-selected text file. A concordance is defined as “an alphabetical index of the principal words of a
book or document, with a reference to the passage in which each occurs.” To do this, your program will
need to read the contents of a text file, keeping track of line numbers. Then record each word with its
current line number. Your finished result will be a file containing an alphabetical listing of all the words,
and with each word, the number of times that word appeared in the document, and a list of the line
numbers on which that word was found. You must allow the user to select a file from a menu of
available files and save the results in a file named “[originalname][login to view URL]” where
[originalname] is the name of the input file without its extension. Here are the specific coding
requirements:
Create a UniqueWord class with the following attributes and methods:
o One string variable to contain the word being cataloged
o One vector of whole numbers containing the line numbers where this word was found
in the file
o One constructor that accepts a string and a line number, saves it in the string variable
and initializes the vector with the line number
o One method to add a line number (argument) to the current word’s vector of line
numbers
o One method to compare the current UniqueWord’s text to another UniqueWord’s text.
The function must return an integer value of +1 if the first argument sorts alphabetically
before the second, 0 if both strings are equal, and -1 if the second string sorts
alphabetically before the first. Use this function when searching the concordance vector
for new words.
o One toString method to format the word, its occurrence count, and its line numbers into
a single string for output in this format: word(occurrences): line, line, line, line, line
o Other variables and methods as necessary
Create a Concordance class with the following attributes and methods:
o One vector of pointers to UniqueWord objects. The UniqueWord objects in this list must
be kept in ascending alphabetical order.
o One default constructor that initializes the vector list to be empty
o One method to reset the concordance to an empty list
o One method to add a word and line number to the concordance. This method must
determine whether the word already exists in the concordance. If it does, the word’s
line number must be added to the existing word’s list of line numbers. If the word does
not already exist in the concordance, a new UniqueWord object must be created and
initialized with the new word and its line number. Then the new UniqueWord must be
inserted into the concordance in its proper alphabetical location.
o One method to save the contents of the concordance to a user-specified file.
o Other variables and methods as necessary
Create a menu-driven program that offers the user a list of available text files. The user will
select a file by name or by its number in the menu.
The program must have a single Concordance object created from the Concordance class
described above. This object must be created or reset each time an input data file is opened.
Open the user-selected file and read it line-by-line. For each line, parse the line to identify each
individual word, convert each word to lowercase, and remove all leading and trailing
punctuation. Do not remove embedded periods, hyphens, or apostrophes.
For each word, use the Condordance object’s method to add the word to the concordance. When the end of the file has been reached and all words have been cataloged, write the
contents of the concordance object to a new file, named “[originalfilename][login to view URL]”
where [originalfilename] is the name of the input file without its filename extension.
Allow the user to repeat this process for as many input files as they want
Coding
Each object must be defined within its own set of .h and .cpp files.
Validate all inputs and do not proceed until valid values are entered.
Format your source code according to the style guide presented in class.
Bonus
In the Concordance class, implement a binary search of the concordance vector to find a word in
the vector.
Data files (these were downloaded from [login to view URL])
[login to view URL] – A Modest Proposal by Jonathan Swift
[login to view URL] – Apology by Plato
[login to view URL] – The Wonderful Wizard of Oz by Frank Baum
[login to view URL] – The Adventures of Sherlock Holmes by Sir Arthur Conan Doyle
Turn in a single zip file containing your source code in one or more “.h” and “.cpp” files. Name the zip
file “First Last HW7”, where “First Last” is replaced with your First and Last names.
Hi,hope you are fine and doing great.i have seen detail and don't wanna waste your time to introduce [login to view URL] Expert and can do it [login to view URL] ready for this job right [login to view URL] give me this [login to view URL] you
Regards
$35 USD σε 2 ημέρες
4,6 (8 αξιολογήσεις)
3,4
3,4
6 freelancers δίνουν μια μέση προσφορά $36 USD για αυτή τη δουλειά
HI
Contact me for an efficient, perfect, well documented
development of your project according to 100% accuracy
and requirements, with dedicated support.
Thanks
Farah Saif
Dear sir,
I have done many projects in C++ programming for student around the world and got some positive feedback from clients. You can check my profile for more information. Let me help you. I'm ready to get started right now.
Thanks and best regards,
Tinh Nguyen