Question: Create a C + + program that analyzes the frequency of the occurrence of hashtags within two inputs files, a startHashtagFile and an endHashtagFile. The
Create a C program that analyzes the frequency of the occurrence of hashtags within two inputs files, a startHashtagFile and an endHashtagFile. The program will analyze the change in rank of specific hashtags from the startHashtagFile to the endHashtagFile, where the highest ranked hashtag ie hashtag with rank appears most frequently.
Your program will output
Hashtag with rank # in the end file with number of occurrences
Hashtag with Ranking increases the most with an increase value in ranking
Hashtag with Ranking decreases the most with a decrease value in ranking
New Hashtags first by ranking in the end file. Each one is printed with count rank
Note: A hashtag in the End file is considered "new" if it is not a hashtag in the Start file.
Input Hashtag
For this assignment, the input text file will consist of uppercase and lowercase characters a to zA to Z Each hashtag within the text file will be separated by one or more whitespace characters t
r When reading in each hashtag, change every character of the hashtag to lowercase.
The startHashtagFile and endHashtagFile files are named testfilexStart.txt and testfilexEnd.txt respectively. x is a number from to
Hashtag Class
The following Hashtag class definition must be used for the assignment. You may add data andor function members to the class but do not modify the existing ones. You may create your own classes to do other tasks.
class Hashtag
private:
string word; The hashtag itself
int Count; Number of occurrences in the file
int Rank; Rank
public:
Hashtagstring word;
Hashtagstring word, int Count;
string getWord const;
int getCount const;
int getRank const;
void setRankint rank;
void IncrementCount; to increment Count
Overloaded and operators for Hashtag objects
bool operatorconst Hashtag& rhs const; ;
Overloading the operator
You should overload the operator for the Hashtag class. The operator is used to sort the hashtags to determine the ranking and ordering of hashtags. The hashtag with the largest count should appear first rank To achieve this, a hashtag with a larger count will be considered less than a hashtag with a smaller count. The lefthand side hashtag is the object on which the operator function is called. The righthand side object is passed as a reference argument to the operator function.
The lefthand side lhs hashtag is less than the righthand rhs if all string comparisons are case insensitive:
If the rhs count is less than the lhs count
If the rhs count is equal to the lhs count, and the lhs word is less than rhs word alphabetically
Note: If you program uses a vector, by overloading the operator, you can use sort function to sort a vector of Hashtag objects, as shown below:
vector allTags;
sortallTagsbegin allTags.end;
Hashtag Counting
As each hashtag is read from the input text file, your program must keep track of hashtags and the number of times each hashtag is used. While the input file may contain both uppercase and lowercase characters, the identification of unique hashtags is case insensitive. For example, "Party", "party", and "PARty" are all considered the same hashtag.
Hashtag Ranking
After processing the startHashtagFile, your program must determine the start rank for each hashtag. Similarly, after processing the endHashtagFile, your program must determine the end rank for each hashtag. The rank of a hashtag is the position within a list of hashtags sorted by decreasing count with being the highest rank corresponding to the most hashtag with the highest count
Contents of testfileStart:
Party Byte party MEtal My PARty byte metal paRty BYTE my MY EEE BYTE
Contents of testfileEnd:
byte Party party MEtal eee PARty metal party paRty BYTE MeTAL my MY Metal Byte Metal METAL My EEE Party mY metal Party Test
Output using testfileStart.txt and testfileEnd.txt:
Hashtag with Rank in the End file: metal with counts.
Hashtag with Ranking increases the most: metal in ranking
Hashtag with Ranking decreases the most: byte in ranking
New Hashtags first by ranking in the End file:
eee
test
Include a main.cpp Hashtag.cpp and Hashtag.h files.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
