Computers and Technology

Given a string variable string 's;', implement a tokenizer to identify the unique tokens contained in this string, identify all the unique tokens and their frequencies, and store such information into a vector. Tokens are sequences of contiguous characters separated by any of the specified delimiters (e. g., white spaces). In this lab, only white spaces will be considered as delimiters. For instance, the string "Hello, what's that thing? " contains four tokens: "Hello", "what's", "that" and "thing?". The frequency of a token is the number of times this token appears in this string. In this example, each token has a frequency of 1. Note that in this lab, these tokens are case insensitive. For example, "Hello" and "hello" are considered to be the same token.
Specifically, you are required to declare a struct TokenFreq that consists of two data members: (1) string token; and (2) int freq; Obviously, an object of this struct will be used to store a specific token and its frequency. For example, the following object word stores the token "dream" and its frequency 100:

TokenFreq word;
word. value="dream";
word. freq=100;

implement the following function, where istr is the input string, and tfVec will be used to store the list of unique and case insensitive tokens and their corresponding frequencies identified within istr. You might find it's very convenient to use stringstream objects to tokenize a string.

void getTokenFreqVec( const string& istr, vector & tfVec)
Assume that the value of istr is

And no, I'm not a walking C++ dictionary. I do not keep every technical detail in my head at all times. If I did that, I would be a much poorer programmer. I do keep the main points straight in my head most of the time, and I do know where to find the details when I need them. by Bjarne Stroustrup
After calling the above function, tfVec is expected to contain the following values (where order of appearances doesn't matter):

size=46 {
[0] = (token = "and", freq = 2)
[1] = (token = "no,", freq = 1)
[2] = (token = "i'm", freq = 1)
[3] = (token = "not", freq = 2)
[4] = (token = "a", freq = 2)
[5] = (token = "walking", freq = 1)
[6] = (token = "c++", freq = 1)
[7] = (token = "dictionary.", freq = 1)
[8] = (token = "i", freq = 6)
[9] = (token = "do", freq = 3)
[10] = (token = "keep", freq = 2)
[11] = (token = "every", freq = 1)
[12] = (token = "technical", freq = 1)
[13] = (token = "detail", freq = 1)
[14] = (token = "in", freq = 2)
[15] = (token = "my", freq = 2)
[16] = (token = "head", freq = 2)
[17] = (token = "at", freq = 1)
[18] = (token = "all", freq = 1)
[19] = (token = "times.", freq = 1)
[20] = (token = "if", freq = 1)
[21] = (token = "did", freq = 1)
[22] = (token = "that,", freq = 1)
[23] = (token = "would", freq = 1)
[24] = (token = "be", freq = 1)
[25] = (token = "much", freq = 1)
[26] = (token = "poorer", freq = 1)
[27] = (token = "programmer.", freq = 1)
[28] = (token = "the", freq = 3)
[29] = (token = "main", freq = 1)
[30] = (token = "points", freq = 1)
[31] = (token = "straight", freq = 1)
[32] = (token = "most", freq = 1)
[33] = (token = "of", freq = 1)
[34] = (token = "time,", freq = 1)
[35] = (token = "know", freq = 1)
[36] = (token = "where", freq = 1)
[37] = (token = "to", freq = 1)
[38] = (token = "find", freq = 1)
[39] = (token = "details", freq = 1)
[40] = (token = "when", freq = 1)
[41] = (token = "need", freq = 1)
[42] = (token = "them.", freq = 1)
[43] = (token = "by", freq = 1)
[44] = (token = "bjarne", freq = 1)
[45] = (token = "stroustrup", freq = 1)
Required:
Implement the selection sort algorithm to sort a vector in ascending order of token frequency. This function has the following prototype:

void selectionSort( vector & tokFreqVector );
//This function receives a vector of TokenFreq objects by reference and applies the selections sort algorithm to sort this vector in increasing order of token frequencies.
Implement the insertion sort algorithm to sort a vector in descending order of token frequency.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 21:40, DisneyGirl11
Which is a benefit of getting information from a government website? a. the information will be easy to understand. ob. the information will be the most current. oc. the information can be trusted.
Answers: 1
image
Computers and Technology, 22.06.2019 18:30, leannhb3162
Which of these options are the correct sequence of actions for content to be copied and pasted? select content, click the copy button, click the paste button, and move the insertion point to where the content needs to be inserted. click the copy button, select the content, move the insertion point to where the content needs to be inserted, and click the paste button. select the content, click the copy button, move the insertion point to where the content needs to be inserted, and click the paste button. select the content, move the insertion point to where the content needs to be inserted, click the copy button, and click the paste button.
Answers: 3
image
Computers and Technology, 22.06.2019 23:30, lexirandall19
Define a function printfeetinchshort, with int parameters numfeet and numinches, that prints using ' and " shorthand. ex: printfeetinchshort(5, 8) prints: 5' 8"
Answers: 1
image
Computers and Technology, 23.06.2019 01:00, lusciousl
Petrică, tânăr licean în clasa a ix-a, a primit în dar de la părinţii săi un cont bancar pentru micile sale cheltuieli curente. el este pasionat de internet banking şi îşi verifică cu grijă toate tranzacţiile efectuate. pentru creşterea securităţii tranzacţiilor online, banca îi furnizează lui petrică un număr pe care el va trebui să îl modifice, obţinând un număr tan – număr de autentificare a tranzacţiei (transaction authentication number). regula de obţinere a numărului tan este următoarea: se formează cel mai mic număr par din toate cifrele numărului furnizat de bancă. cerinţă cunoscând numărul n furnizat de bancă, să se determine numărul tan obţinut de petrică. date de intrare fişierul tan. in conţine pe prima linie numărul natural n cu semnificaţia din enunţ. date de ieşire fişierul de ieşire tan. out va conţine o singură linie pe care va fi scris numărul tan cerut. restricţii • 0 < n < 18*1018 • n are cel puţin o cifră pară • numărul tan obţinut nu poate conţine zerouri nesemnificative
Answers: 2
Do you know the correct answer?
Given a string variable string 's;', implement a tokenizer to identify the unique tokens contained i...

Questions in other subjects:

Konu
Mathematics, 24.09.2020 01:01