in c++ please. Write a program that reads the contents of a text file. The program should create a map in which the keys are the individual words found in the file and the values are the number of times each word appears. For example, if the word "the" appears 128 times, the map would contain an element with "the" as the key and 128 as the value. The program should either display the frequency of each word or create a second file containing a list of each word and its frequency.
//program ReadFreq.cpp
=============================================================
#include<fstream> //this is for read and write into file
#include<iostream> //this is for read and write from user
#include<string> //this is for string operation
#include<map> //using map stl library
#include<iterator> //using iterator
using namespace std;
//prototype of writeFreq function to write data to file
void writeFreq(string, ofstream &);
int main()
{
//read word by word from file into this word
string word;
//make an input file reader pointer
ifstream in;
//make an output file writer pointer
ofstream out;
//map to store freq of word
map<string,int> freq;
//open input file for reading
in.open("input.txt");
//open output file for writing
out.open("output.txt");
//using while loop read complete file word by word
while(in >> word){
//if word already in map just increase it value by 1
if(freq.count(word)>0){
freq.insert(pair<string,int>(word,freq[word]++));
}else{
//for new word make in value as 1
freq.insert(pair<string,int>(word,1));
}
}
//make an iterator for map
map<string,int>::iterator itr;
//using for loop on the map using iterator and print it to the screen and write to the file
for(itr = freq.begin(); itr != freq.end(); itr++){
string output = "";
output += itr->first + " : " ;
output += to_string(itr->second) + "\n";
writeFreq(output,out);
cout<<output;
}
//close both the files
in.close();
out.close();
return 0;
}
//This is the final method which write the freq and the word to the file
void writeFreq(string output, ofstream& out){
out<<output;
}
==========================================
input.txt
this is the demo file and this is for demo purpose only.
==============================================================
==============================================================
output

====================================
output.txt
in c++ please. Write a program that reads the contents of a text file. The program...
(Python 3) Write a program that reads the contents of a text file. The program should then create a dictionary in which the keys are individual words found in the file and the values are the number of times each word appears and a list that contains the line numbers in the file where the word (the key) is found. Then the program will create another text file. The file should contain an alphabetical listing of the words that are...
Homework IX-a Write a program that opens a text file, whose name you enter at the keyboard You will be using the file text.txt to test your program. Print out all of the individual, unique words contained in the file, in alphabetical order Print out the number of unique words appearing in text.txt. Call your program: YourName-HwrklXa.py Make sure that your name appears as a comment at the beginning of the program as well as on the output display showing...
Python 3.7 Coding assignment This Program should first tell users that this is a word analysis software. For any user-given text file, the program will read, analyze, and write each word with the line numbers where the word is found in an output file. A word may appear in multiple lines. A word shows more than once at a line, the line number will be only recorded one time. Ask a user to enter the name of a text file....
Pythong Program 4 should first tell users that this is a word analysis software. For any user-given text file, the program will read, analyze, and write each word with the line numbers where the word is found in an output file. A word may appear in multiple lines. A word shows more than once at a line, the line number will be only recorded one time. Ask a user to enter the name of a text file. Using try/except for...
Write a program that first reads in the name of an input file and then reads the file using the csv.reader() method. The file contains a list of words separated by commas. Your program should output the words and their frequencies (the number of times each word appears in the file) without any duplicates. Ex: If the input is: inputl.csv and the contents of input1.csv are: hello, cat, man, hey, dog, boy, Hello, man, cat, woman, dog, Cat, hey, boy the output is: hello 1 cat 2 man...
This is binary search tree problem. The program reads the text file, and creates a binary search tree based on the words in the file. I can create the tree but I also have to store 'the order of insertion' in each node. For example, if text includes "the" 3 times and it is the 1st, 5th, and 9th word in the file, in binary search tree, one node should have string value "the" and array list{1, 5, 9}. How...
C++ Lab 1. Read in the contents of a text file up to a maximum of 1024 words – you create your own input. When reading the file contents, you can discard words that are single characters to avoid symbols, special characters, etc. 2. Sort the words read in ascending order in an array (you are not allowed to use Vectors) using the Selection Sort algorithm implemented in its own function. 3. Search any item input by user in your...
C++.Write a program that opens two text files and reads their contents into two separate queues. The program should then determine whether the files are identical by comparing the characters in the queues. When two nonidentical characters are encountered, the program should display a message indicating that the files are not the same. If both queues contain the same set of characters, a message should be displayed indicating that the files are identical. Sample Run Suppose we have two files...
In C write a text analyzer program that reads any text file. The program displays a menu that gives the user the options of counting: • Lines • Words • Characters • Sentences (one or more word ending with a period) • or all of the above Provide a separate function for each option. At the end of the analysis, write an appropriate report.
Write a console program in Java that allows the user to specify a text file, opens the file, and prints a two-column table consisting of all the words in the file together with the number of times that each word appears. Words are space-delimited and case-sensitive. The table should list the words in alphabetical order. Proper code documentation should be included in the source code.