First 3 processed information that you need is given below
C++ Code
#include <iostream>
#include <bits/stdc++.h>
#include <fstream>
#include<string>
int printUniquedWords(char filename[]) ;
using namespace std;
int printUniquedWords(char filename[])
{
// Open a file stream
fstream fs(filename);
// Create a map to store count of all
words
map<string, int> mp;
// Keep reading words while there are words to
read
string word;
int uword=0,fourdigits=0;
while (fs >> word)
{
// If this is first
occurrence of word
if
(!mp.count(word))
mp.insert(make_pair(word, 1));
else
mp[word]++;
}
fs.close();
// Traverse map and print all words whose
count
//is 1
for (map<string, int> :: iterator p =
mp.begin();
p != mp.end();
p++)
{
if (p->second == 1)
{
uword++;
if((p->first).length()>4){
fourdigits++;
}
//
cout <<(p->first).length()<< endl;
}
}
cout<<"\nUniqueWords="<<uword<<"\n";
cout<<"\nmoreThan4digitUniqueWords="<<fourdigits<<"\n";
}
int main()
{
ifstream fin("rat.txt"); //opening text file
int word=1; //will not count first word so initial value is 1
char ch;
fin.seekg(0,ios::beg); //bring position of file pointer to
begining of file
while(fin)
{
fin.get(ch);
if(ch==' '||ch=='\n')
word++;
}
cout<<"\nTotalWords="<<word<<"\n";
printUniquedWords("rat.txt");
fin.close(); //closing file
return 0;
}
Output
TotalWords:
UniqueWord:
moreThan4digitUniqueWords:
please write it in c++ programming language this is the rat text file More what? what...
Programming language --> Matlab
The name of a text file Outputs: (cell) An Nx2 cell array listing words and their counts in sorted order Function Description: Have you ever seen those fancy word-clouds based on the frequency of word occurrences in some text? Well the first step of making a graphic like that is to figure out how often the words in some text occur, which is exactly what this function will do. You will count the number of occurrences...
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...
please
write a C++ code
Problem A: Word Shadow Source file: shadow.cpp f or java, or.cj Input file: shadow.in in reality, when we read an English word we normally do not read every single letter of that word but rather the word's "shadow" recalls its pronunciation and meaning from our brain. The word's shadow consists of the same number of letters that compose the actual word with first and last letters (of the word) in their original positions while the...
C Programming Language on Linux - Word Frequency Program Please write a Program in C that will accept a text file name as a command-line argument via a main program that will do the following: First, read the file (first pass) and create a linked list of words (in their order of occurrence), with the frequency of each word set to 0. Then, read the file (second pass) and for each word identified, search the linked list, and when found,...
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...
Program is in C++. Write a function named wordStatsPlus that accepts as its parameter a string holding a file name, opens that file and reads its contents as a sequence of words, and produces a particular group of statistics about the input. You should report: the total number of lines; total number of words; the number of unique letters used from A-Z, case-insensitively, and its percentage of the 26-letter alphabet; the average number of words per line (as an un-rounded...
Program is in C++. Write a function named wordStatsPlus that accepts as its parameter a string holding a file name, opens that file and reads its contents as a sequence of words, and produces a particular group of statistics about the input. You should report: the total number of lines; total number of words; the number of unique letters used from A-Z, case-insensitively, and its percentage of the 26-letter alphabet; the average number of words per line (as an un-rounded...
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...
Hi, need this question ansered in c++, has multiple levels will
post again if you can complete every level so keep an eye out for
that.
here is a sketch of the program from the screenshot
int main (int argc, char** argv) { enum { total, unique } mode =
total; for (int c; (c = getopt(argc, argv, "tu")) != -1;) {
switch(c) { case 't': mode = total; break; case 'u': mode = unique;
break; } } argc -=...
You're to write a C++ program that analyzes the contents of an external file called data.txt. (You can create this file yourself using nano, that produces a simple ASCII text file.) The program you write will open data.txt, look at its contents and determine the number of uppercase, lowercase, digit, punctuation and whitespace characters contained in the file so that the caller can report the results to stdout. Additionally, the function will return the total number of characters read to...