When an author produces an index for his or her book, the first step in this process is to decide which words should go into the index; the second is to produce a list of the pages where each word occurs. Instead of trying to choose words out of our heads, we decided to let the computer produce a list of all the unique words used in the manuscript and their frequency of occurrence. We could then go over the list and choose which words to put into the index. The main object in this problem is a "word" with associated frequency. The tentative definition of "word" here is a string of alphanumeric characters between markers where markers are white space and all punctuation marks; anything non-alphanumeric stops the reading. If we skip all un-allowed characters before getting the string, we should have exactly what we want. Ignoring words of fewer than three letters will remove from consideration such as "a", "is", "to", "do", and "by" that do not belong in an index. In this project, you are asked to write a program to read any text file and then list all the "words" in alphabetic order with their frequency together appeared in the article. The "word" is defined above and has at least three letters. Your result should be printed to an output file named YourUserID.txt. You need to create a Binary Search Tree (BST) to store all the word object by writing an insertion or increment function. Finally, a proper traversal print function of the BST should be able to output the required results. The BST class in the text can not be used directly to solve this problem. It is also NOT a good idea to modify the BST class to solve this problem. Instead, the following codes are recommended to start your program. //Data stored in the node type struct WordCount { string word; int count; };   //Node type:  struct TreeNode { WordCount info; TreeNode * left; TreeNode * right; };   // Two function's prototype // Increments the frequency count if the string is in the tree // or inserts the string if it is not there. void Insert(TreeNode*&, string);   // Prints the words in the tree and their frequency counts. void PrintTree(TreeNode* , ofstream&);   //Start your main function and the definitions of above two functions. You only need to write these two functions. Do not add anymore functions besides the ones given her

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

When an author produces an index for his or her book, the first step in this process is to decide which words should go into the index; the second is to produce a list of the pages where each word occurs. Instead of trying to choose words out of our heads, we decided to let the computer produce a list of all the unique words used in the manuscript and their frequency of occurrence. We could then go over the list and choose which words to put into the index.

The main object in this problem is a "word" with associated frequency. The tentative definition of "word" here is a string of alphanumeric characters between markers where markers are white space and all punctuation marks; anything non-alphanumeric stops the reading. If we skip all un-allowed characters before getting the string, we should have exactly what we want. Ignoring words of fewer than three letters will remove from consideration such as "a", "is", "to", "do", and "by" that do not belong in an index.

In this project, you are asked to write a program to read any text file and then list all the "words" in alphabetic order with their frequency together appeared in the article. The "word" is defined above and has at least three letters.

  1. Your result should be printed to an output file named YourUserID.txt.
  2. You need to create a Binary Search Tree (BST) to store all the word object by writing an insertion or increment function. Finally, a proper traversal print function of the BST should be able to output the required results.
  3. The BST class in the text can not be used directly to solve this problem. It is also NOT a good idea to modify the BST class to solve this problem. Instead, the following codes are recommended to start your program.

//Data stored in the node type struct WordCount { string word; int count; };   //Node type:  struct TreeNode { WordCount info; TreeNode * left; TreeNode * right; };   // Two function's prototype // Increments the frequency count if the string is in the tree // or inserts the string if it is not there. void Insert(TreeNode*&, string);   // Prints the words in the tree and their frequency counts. void PrintTree(TreeNode* , ofstream&);   //Start your main function and the definitions of above two functions.

You only need to write these two functions. Do not add anymore functions besides the ones given here. 

index (1) - Notepad
File Edit Format
View
Help
1863 1
Address 1
But 1
Four 1
Gettysburg 2
God 1
Liberty 1
November 1
Now 1
Pennsylvania 1
The 3
above 1
add 1
advanced 1
ago 1
all 1
altogether 1
and 6
any 1
are 3
battle-field 1
before 1
birth 1
brave 1
brought 1
but 1
can 5
cause 1
civil 1
come 1
conceived 2
consecrate 1
consecrated 1
continent 1
created 1
dead 3
dedicate 2
dedicated 4
detract 1
devotion 2
did 1
died 1
earth 1
endure 1
engaged 1
equal 1
far 2
fathers 1
fleld 1
final 1
filling 1
for 5
forget 1
forth 1
fought 1
freedom 1
from 2
full 1
gave 2
governiment 1
Breat 3
ground 1
hallow 1
have 5
here 8
highly 1
honored 1
Increased 1
larger 1
last 1
little 1
live 1
1ives 1
living 2
long 2
measure 1
men 2
met 1
might 1
nation 5
never 1
new 2
nobly 1
nor 1
not 5
note 1
our 2
people 3
perish 1
place 1
poor 1
portion 1
Transcribed Image Text:index (1) - Notepad File Edit Format View Help 1863 1 Address 1 But 1 Four 1 Gettysburg 2 God 1 Liberty 1 November 1 Now 1 Pennsylvania 1 The 3 above 1 add 1 advanced 1 ago 1 all 1 altogether 1 and 6 any 1 are 3 battle-field 1 before 1 birth 1 brave 1 brought 1 but 1 can 5 cause 1 civil 1 come 1 conceived 2 consecrate 1 consecrated 1 continent 1 created 1 dead 3 dedicate 2 dedicated 4 detract 1 devotion 2 did 1 died 1 earth 1 endure 1 engaged 1 equal 1 far 2 fathers 1 fleld 1 final 1 filling 1 for 5 forget 1 forth 1 fought 1 freedom 1 from 2 full 1 gave 2 governiment 1 Breat 3 ground 1 hallow 1 have 5 here 8 highly 1 honored 1 Increased 1 larger 1 last 1 little 1 live 1 1ives 1 living 2 long 2 measure 1 men 2 met 1 might 1 nation 5 never 1 new 2 nobly 1 nor 1 not 5 note 1 our 2 people 3 perish 1 place 1 poor 1 portion 1
lincoln (1) - Notepad
File Edit Format View Help
The Gettysburg Address
Gettysburg, Pennsylvania
November 19, 1863
Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in
Liberty, and dedicated to the proposition that all men are created equal.
Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and
so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate
a portion of that field, as a final resting place for those who here gave their lives that that nation
might live. It is altogether fitting and proper that we should do this.
we can not hallow -- this ground.
But, in a larger sense, we can not dedicate -- we can not consecrate
The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add
or detract. The world will little note, nor long remember what we say here, but it can never forget what
they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they
who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great
task remaining before us -- that from these honored dead we take increased devotion to that cause for
which they gave the last full measure of devotion -- that we here highly resolve that these dead shall not
have died in vain -- that this nation, under God, shall have a new birth of freedom
of the people, by the people, for the people, shall not perish from the earth.
and that government
-
Transcribed Image Text:lincoln (1) - Notepad File Edit Format View Help The Gettysburg Address Gettysburg, Pennsylvania November 19, 1863 Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. we can not hallow -- this ground. But, in a larger sense, we can not dedicate -- we can not consecrate The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us -- that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion -- that we here highly resolve that these dead shall not have died in vain -- that this nation, under God, shall have a new birth of freedom of the people, by the people, for the people, shall not perish from the earth. and that government -
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY