Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This assignment is a warm-up exercise that will give you experience using the autograder and writing a simple C++ program using the Standard Template Library

This assignment is a warm-up exercise that will give you experience using the autograder and writing a simple C++ program using the Standard Template Library (STL). For this assignment, you will write a program in C++ that generates an "inverted index"of all the words in a list of text files. See Wikipedia for more details regarding inverted indexes. The goal of this assignment is to ensure that you are sufficiently Inverter Input Your inverter will take exactly one argument: a file that contains a list of filenames. Each filename will appear on a separate line. Each of the files described in the first file will contain text from which you will build your index. For example: inputs.txt ----- foo1.txt foo2.txt foo1.txt ----- this is a test. cool. foo2.txt ----- this is also a test. boring. Inverter Output Your inverter should print all of the words from all of the inputs, in "alphabetical" order, followed by the document numbers in which they appear, in order. For example (note: your program must produce exactly this output): a: 0 1 also: 1 boring: 1 cool: 0 is: 0 1 test: 0 1 this: 0 1 Alphabetical is defined as the order according to ASCII. So "The" and "the" are separate words, and "The" comes first. Only certain words should be indexed. Words are anything that is made up of only alpha characters, and not numbers, spaces, etc. "Th3e" is two words, "Th" and "e". Files are incrementally numbered, starting with 0. Only valid, "open-able" files should be included in the count. (is_open() comes in handy here.) Your program should absolutely not produce any other output. Extraneous output, or output formatted incorrectly (extra spaces, etc.) will make the autograder mark your solution as incorrect. In particular, the output should have one space between the colon and the first document number, one space between each subsequent document number, and no spaces at the end of any line. Please leave yourself extra days to work these problems out. Implementation Hints Implement the data structure using the C++ Standard Template Library (STL) as a map of sets, as in: map> invertedIndex; Use C++ strings and file streams. Sample Code: #include #include Make sure that your assignment uses an ifstream, not an fstream. Both ifstreams and fstreams are found in the fstream library. Remember, your program needs to be robust to errors in the input file. Files may be empty, the input may contain empty lines, there may be spaces before or after the filename on each line of the input file, etc. The only constraint is that each filename will appear on a separate line. Please handle all cases gracefully and with no extra output. The noskipws operator may be useful in parsing the input: input >> noskipws >> c; image text in transcribedimage text in transcribed

REMINDER: You must be on campus to submit to the autograder! This assignment is a warm-up exercise that will give you experience using the autograder and writing a simple C++ program using the Standard Template Library (STL). For this assignment, you will write a program in C++ that generates an "inverted index"of all the words in a list of text files. See Wikipedia for more details regarding inverted indexes. The goal of this assignment is to ensure that yc up to speed on C++. Inverter Input Your inverter will take exactly one argument: a file that contains a list of filenames. Each filename will appear on a separate line. Each of the files described in the first file will contain text from which you will build your index. For example: inputs.txt fool.txt food.txt fool.txt this is a test. cool. foo2.txt this is also a test. boring. a: 01 also: 1 boring: 1 cool: 0 is: 01 test: 01 this: 01 etc. "Th3e" is two words, "Th" and "e". Files are incrementally numbered, starting with 0. Only valid, "open-able" files should be included in the count. (is_open0 comes in handy here.) Implementation Hints Implement the data structure using the C++ Standard Template Library (STL) as a map of sets, as in: map > invertedlndex; Use C++ strings and file streams. Sample Code: \#include string > \#include Make sure that your assignment uses an ifstream, not an fstream. Both ifstreams and fstreams are found in the fstream library. filename will appear on a separate line. Please handle all cases gracefully and with no extra output. The noskipws operator may be useful in parsing the input: input >> noskipws >>c

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

Finding and scheduling appointments with new prospective clients.

Answered: 1 week ago