Devise programs requiring data manipulation with stl

Assignment Help C/C++ Programming
Reference no: EM131976803

Advanced Programming

Aim:

This assignment is to familiarise you with the use of STL container classes in your programs.
On completion you should know how to:
- Write C++ code using STL container class objects.
- Devise programs requiring data manipulation with STL containers.
- Gain experience writing and debugging complex C++ programs incrementally.

Requirements:
For this assignment you are to implement a C++ program that can read a text file and display any known words on the screen together with their frequency and position in the file. Below shows a snippet of what the output should look like:

Word Count Position(s)
a 7 22 65 87 96 130 148 165
all 1 50
and 9 19 70 125 134 138 157 177 247 261
are 1 74
as 2 169 214
automata 1 73
be 1 99
begin 1 106
between 1 132
cell 5 97 131 156 180 238
cellular 1 72
create 1 143
cursor 2 119 124
eight 1 171
every 2 155 237
first 2 20 110

A "known" word is a word that is in the English dictionary which is defined by the words listed in the file named "dictionary.txt". The word "Positions" are determined by all the places where each word occurs in the data file. For example, in the above screen output, the word "first" occurred twice, at the 20th and 110th word position in the test data file.

A partially completed "WordStat" class is provided in "wordstat.h" and "wordstat.cpp". A driver program is also provided in main.cpp. The file: "output.txt" shows the output your completed program should produce when run with redirected input from "input.txt". You should do this assignment incrementally by completing the following steps.

Step 1

Implement the ReadDictionary() and DisplayDictionary() public member function in the "wordstats" class in "wordstat.h & "wordstat.cpp". ReadDictionary should open "dictionary.txt" and read all the words (in lower case format) into the private "Dictionary" member:

set<string> Dictionary;

If you are unsure on using the STL set container, take a look at "08-set.cpp" in the examples folder. DisplayDictionary() should display the first 20 words in the Dictionary on the screen. The screenshot below shows an example output of reading and displaying the dictionary.

Step-1 Reading and displaying dictionary
25127 words read from dictionary.
Displaying the first 20 words in the dictionary...

aarhus
aaron
ababa
aback
abacus
...
abbot
abbott
abbreviate
abc
abdicate
abdomen

Step 2

Implement the ReadTextFile() public member function. This function should read the contents of the file named: "testdata.txt" into the "KnownWords" and "UnknownWords" data members of the "WordStats" class:

WordMap KnownWords; WordMap UnknownWords;

Please note that "WordMap" is typedefed in "wordstat.h" as:
typedef map<string, vector<int> > WordMap;

Only "known" words should be put in the "KnownWords" WordMap. A "known" word is any word that is found in the Dictionary class member. Before attempting to find a word in the Dictionary, you should first preprocess the word by converting all characters to lower case and remove any non-alphabetic characters except for the punctuation marks: hyphen (-) and apostrophe (‘). You can add additional private member functions to class WordStats if you wish. Your output from step-2 should look something like this:

Step-2 Reading known wrods from text file:
89 known words read.
49 unknown words read.
If you are unsure on working with map containers, an example is provided in "08-map.cpp" in the example folder.

Step 3
Implement the DisplayKnownWordStats(); public member function. This function should iterate the "KnownWords" WordMap and display the word stats on the screen as shown on page 1. If you are unsure on how to do this with a map look at "08-map.cpp" in the example folder.

Step 4
Implement the "DisplayUnknownWordStats()" public member function. This function should display the unknown words in the same format as step-3. Note: try to avoid duplicating code for this by declaring an additional private member function that is passed a WordMap by reference and called by both the display functions from step-3 and step-4.

Step 5
Implement the "DisplayMostFreqKnownWords()" public member function. This function should display the 10 most frequently occurring words in the "KnownWords" container. E.g.

Step-5 Displaying most frequent known words:
Word Count
the 21
live 10
of 9
and 9
or 7
in 7
a 7
to 6
is 6
cell 5

To do this declare a local multimap<int,string>; container. You will need to iterate the "KnownWords" container and insert the size of the vector (as the key) and the word into the local multimap. This multimap can then be iterated to display the 10 most frequent words on the screen.

Step 6
Implement the "DisplayMostFreqUnknownWords()" public member function to display the 10 most frequently occurring words in the "UnknownWords" container. Again, try to avoid duplicate code by adding another private member function called by the display functions from setp-5 and 6.

Step 7
Implement the "DisplayOriginalText()" public member function. To do this declare a local map<int,string>; container and do the same as you did with Step 6, except you should also iterate the vectors in the KnownWords and UnknownWords containers and add the <position, word> pair for all words and their positions. This will sort the words into their original text order based on the word position numbers. The screen output should look something like below.

the game of life written by ian sharpe the game of life was invented by the mathematician john conway and first reached a wide public when it was written up in scientific american in 1970 or thereabouts in those days it was mostly played on squared paper nowadays computers take all the hard work out of this fascinating invention to some it's nothing more than a toy to others it and related cellular automata are subjects for serious study in this implementation the screen is divided into a grid of cells 40 wide by 24 deep a cell may be live (red or dead (white) you begin by creating the first generation of live cells or seed . . .

Attachment:- files.zip

Reference no: EM131976803

Questions Cloud

Explain why the manager may have said it : My plant doesn't have that certainty; it's a world of uncertainty. So LP can't be used here." Do you think this statement has any merit?
What is the allowed depreciation charge for each of six year : A business has purchased an asset it expects to last 6 years. What is the allowed depreciation charge for each of the 6 years?
What should the molar concentrations of benzoic acid : What should the molar concentrations of benzoic acid and sodium benzoate be in a solution that is buffered at a pH of 5.00 and has a freezing point of -2.0?
Correct given project with conventional cash flows : Which one of these statements is correct given a project with conventional cash flows?
Devise programs requiring data manipulation with stl : CSCI251/851 - Advanced Programming - Write C++ code using STL container class objects. - Devise programs requiring data manipulation with STL containers. - Gain
Develop your own set of constraint equation and inequalities : Discuss the similarities and differences between minimization and maximization problems using the graphical solution approaches of LP.
What is effective rate of interest : What is the effective rate of interest? What would the effective rate be if Carey were required to make 12 equal monthly payments to retire the loan?
What is the highest acceptable manufacturing cost : Sid's skins makes a variety of covers for electronic. What is the highest acceptable manufacturing cost for which Sid's would be willing to produce the cover?
Discuss the catholic social teaching principle : Discuss the Catholic Social Teaching Principle. Discuss the company and relate how it is practicing the Catholic Social Teaching Principle.

Reviews

len1976803

5/9/2018 5:34:48 AM

Deductions will be made for untidy work or for failing to comply with the submission instructions. Requests for alternative submission arrangements will only be considered before the due date. An extension of time for the assignment submission may be granted in certain circumstances. Any request for an extension of the submission deadline must be made to the Subject Coordinator before the submission deadline. Supporting documentation must accompany the request for any extension. Late assignment submissions without granted extension will be marked but the marks awarded will be reduced by 1 mark for each day late. Assignments will not be accepted if more than four days late.

len1976803

5/9/2018 5:34:40 AM

Submit: Submit your files and the output produced when run (copy & paste screen) using the submit facility on UNIX as shown below: $ submit -u login -c CSCI251 –a3 main.cpp wordstats.h wordstats.cpp output.txt where 'login' is your UNIX login ID Note: CSCI851 should also submit to –c CSCI251. To receive 2 marks for your demo, you should demonstrate step-1 and explain (or show) step-2 of your program in your week 9 lab class. Failure to do the demo on time without granted extension will result in a 1 mark deduction for each week late.

Write a Review

C/C++ Programming Questions & Answers

  Write a program that mimics a calculator

Write a program that mimics a calculator. You should define the following functions: showMenu: it shows a menu of options to the user. Below is an example that shows the outputs of this function on the monitor.

  Definition of two queues

Write a code in C language for the definition of two queues, one to hold the process in ready state and one to hold the process in waiting state.

  Calculates the student * averages and quiz averages based

Calculates the student * averages and quiz averages based upon input from the user. Modify this program to read in the following grade text file, * with a maximum number of students set to 35 and having five quiz scores for each student. The output s..

  That reads ten numbers from input and prints

Write a C program that reads ten numbers from input and prints them in reverse order. We assume that the data consists of integers. The program should conform to the following format

  Define an array and why you would use one

Define an Array and why you would use one. Provide an example that is not from the text.

  What is the value of bsame

What is the value of bSame and why?

  Program to store lists of names and ages in parallel arrays

Write a C++ program that stores lists of names (the last name first) and ages in parallel arrays and sorts the names into alphabetical order keeping the ages with the correct names.

  Write a c++ program that displays a table showing the price

write a C++ program that displays a table showing the price of silver and gold.

  Generate a set of 75 random integers in the range -26 to + 4

Write a program that will generate a set of 75 random integers in the range -26 to + 42. The program

  One the same set of axes

One the same set of axes, plot the monopolist's demand and marginal revenue curves. Indicate where theprice elasticity of demand is elastic, inelastic and unit elastic.

  Create a file stack.cpp that will contain all the methods

Create a file Stack.cpp that will contain all the methods declared in Stack.h. Because this is a cpp file, do NOT use any inline methods in it.

  Write a program using the class as defined

Write a program using` the class as defined below. Put the class definition in a separate header file, and put all the functions' code in a separate Resource file.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd