Project #158080 - Data Structures

Computer Tutors

Subject Computer
Due By (Pacific Time) 12/04/2016 06:59 pm

USING C++ LANGUAGE ONLY

 

SUBJECT: COMPUTER SCIENCE

 

COURSE: DATA STRUCTURES

 

QUESTION:

There is a real program developed by a computer company that reads in written reports, issues warnings on bad style, and partially corrects the style. YOUR ASSIGNMENT IS TO CREAT A SIMPLIFIED VERSION OF THIS PROGRAM. IT WILL EXAMINE A REPORT FOR THE USE OF ANNOYING WORDS, CAUTION THE AUTHOR ON THE TENDENCIES TO USE SUCH WORDS, AND THEN CORRECT THE REPORT. AFTER THE CORRECTED REPORT IS PRINTED, THE PROGRAM USER MAY ISSUE COMMANDS TO ADD OR DELETE ENTRIES FROM THE COLLECTION OF ANNOYING WORDS. 

 

INPUT:

 

1. From file BADWORDS: The list of annoying words, in the following format: 

<annoying-word> <synonym>, <synonym>, ... , <synonym>.

   The first word on each line is a annoying word, followed by a black space and a maximum of five  synonyms, separated by commas. The last synonym is followed by a period. Each word is a maximum of 15 characters. Sample line:

grungy dirty, soiled, grimy, encrusted.

   The entries are not arranged in any particular order.

 

2. From file TEXTFILE: A paragraph of text over several lines, in which the words are separated from one another by blacks, commas, periods, or quotes. There need not be a blank before the word at the beginning of the line.

 

3. From the user (keyboard): Any number of the following commands in any order, one per line.

    ADD <annoying word> <synonym>, ... , <synonym>.

Add <annoying word> and its synonyms TO the collection of annoying words.

    DELETE <annoying word>

Delete <annoying word> and its synonyms FROM the collection of annoying words. 

    QUIT 

Stop processing user commands.

 

OUTPUT:

 

1. Alphabetical listing of the collection of annoying words and their synonyms (to file NEWFILE).

 

2. Echo printed original text from TEXTFILE (to screen and file NEWFILE).

 

3. The corrected text after the substitutions of synonyms fro annoying words (to the screen and NEWFILE).

 

4. List of slight tendencies to use annoying words. Print a heading ("Slight Tendencies to Use Annoying Words"). followed by any annoying words that occurred 1 to 4 times in the input text. The list of words should be printed one word per line, alphabetized, to the screen and NEWFILE. 

 

5. A list of extreme tendencies to use annoying words. Print a heading ("Extreme Overuse of Annoying Words"). followed by a list of annoying words that occurred 5 or more times in the input text. The list of words should be printed one word per line, alphabetized to the screen and NEWFILE.

 

6. Issue prompts for commands to screen. Echo print commands issued by program user to NEWFILE.

 

7. After QUIT command, reprint the text form TEXTFILE, using the current collection of annoying words and synonyms to correct the text (to screen and NEWFILE).

 

PROCESSING:

 

The program begin by reading in the collection of annoying words from file BADWORDS. The annoying words should be stored in a binary search tree (BadTree). The list of synonyms associated with each annoying word should also be stored. To make things more interesting, note that when the program finds an annoying word in the text, it must replace every occurrence of the annoying word. The list of synonyms for each annoying word should be in a circular list, so that the program cycles through the synonyms for each occurrence of a particular word (see example).

 

After the BadTree has been built, print out the annoying words alphabetically, with their synonyms, to NEWFILE. THIS SHOULD BE DONE RECURSIVELY.

The program then processes the TEXTFILE, by reading the text and replacing any annoying words with the next synonym associated with it. The modified text is printed to both the screen and NEWFILE.

After the user notices which words the program has changed, the author may use the DELETE and ADD commands to modify the collection of annoying words and their synonyms. After all modifications have been made, the user issues the QUIT command. The program then reprocesses the TEXTFILE, by reading the text and replacing any words that are currently considered to be annoying wit their synonyms. The final text and the lists of slight and extreme tendencies are printed to the screen and NEWFILE.

 

SAMPLE INPUT

File BADWORDS:

           grungy dirty, soiled grimy, encrusted.

           awesome amazing, incredible.

           teeny small, tiny.

 

FILE TEXTFILE:

 

The apartment was so grungy it was totally awesome. The sofa was grungy, the floor was grungy, the fridge was grungy, and even the grass outside was grungy. When I think that could have been where I would live this year, all I could say was, "Totally awesome."

 

COMMANDS:

 

              ADD fridge refrigerator

              DELETE awesome

              QUIT

 

SAMPLE OUTPUT (FILE NEWFILE)

Annoying words and synonyms:

awesome                   amazing, incredible

grungy                       dirty, soiled, grimy, encrusted

teeny                         small, tiny

 

Text From TEXTFILE:

 

The apartment was so grungy it was totally awesome. The sofa was grungy, the floor was grungy, the fridge was grungy, and even the grass outside was grungy. When I think that could have been where I would live this year, all I could say was, "Totally awesome."

 

CORRECTED TEXT:

 

The apartment was dirty it was totally amazing. The sofa was soiled, the floor was grimy, the fridge was encrusted, and even the grass outside was dirty. When I think that could have been where I would live this year, all I could say was, "Totally incredible."

 

Slight Tendencies to Use Annoying Words:

awesome

 

Extreme Overuse of Annoying Words:

grungy

ADD fridge refrigerator

DELETE awesome

 

FINAL TEXT:

 

The apartment was so dirty it was totally awesome. The sofa was soiled, the floor was grimy, the refrigerator was encrusted, and even the grass outside was dirty. When I think that could have been where I would live this year, all I could say was, "Totally awesome."

 

Slight Tendencies to Use Annoying Words:

fridge

 

 

Extreme Overuse of Annoying Words:

TutorRating
pallavi

out of 1971 reviews
amosmm

out of 766 reviews
PhyzKyd

out of 1164 reviews
rajdeep77

out of 721 reviews
sctys

out of 1600 reviews
sharadgreen

out of 770 reviews
topnotcher

out of 766 reviews
XXXIAO

out of 680 reviews