Question
Please help For this program, you will read words from a given file into your program. Each word consists strictly of the letters A-Z and
Please help
For this program, you will read words from a given file into your program. Each word consists strictly of the letters A-Z and a-z. Any whitespace, punctuation, digit, etc. will separate words. An example would be this!is A&Word. This text would represent the 4 words this, is, A, and Word. Each word should be convertedtolowercasesothatonlylowercase letters remain.
Once you have read all of the words, you should output the total number of words read. Your next task is to determine how many distinct words appear in the file and output that value. You will then read a set of queries from a second input file given on the command line. For each word in the query file, you should report how many occurrences of the given word are in the file.
The words in the query file will only be lowercase letters, whitespace and the ? character. When a query word contains a ?, this special character represents the ability to match any character, but not the empty character. For example, colo?r matches "colour" but not "color". This query should report every word that matches.
Keep in mind that the ? character in the source input file is not a wildcard match. In the original source, it is just another non-letter character.
Requirements Please carefully read the following requirements:
You must supply a makefile that supports the commands "make" and" makeclean" and produces an executable named project1
You must use C++ streams for all I/O
You should store the distinct words as an array of strings. There will be no more than 5000 distinct words in the input.
You must format your output exactly as shown in the example below.
When more than one distinct word matches due to the wildcard, list the matches in
order that they first appear in the text. See last query in the example.
Example
Here is an example document sample.txt Cryptography is both the practice and study of the techniques used to communicate and/or store information or data privately and securely, without being intercepted by third parties. This can include processes such as encryption, hashing, and steganography. Until the modern era, cryptography almost exclusively referred to encryption, but now cryptography is a broad field with applications in many critical areas of our lives.
query.txt: ofisora?da?? You must be able to run the program as shown below and get the identical output
$ make g++ -Wall -std=c++11 main.c -o project1 $ ./project1 sample.txt query.txt The number of words found in the file was 64 The number of distinct words found in the file was 52
of : matches of 2 times or: matches or 2 times a?d : matches and 4 times
a?? : matches and 4 times
o? : matches of 2 times matches or 2 times
We highly recommend that you create your own tests to make sure you have covered all possibilities.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started