Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, im trying to code a tokenizer in c++ and my function is this void getTokenFreqVec(string& istr, vector & tfVec) { string token; int stop;

Hi, im trying to code a tokenizer in c++ and my function is this

void getTokenFreqVec(string& istr, vector& tfVec) { string token; int stop; TokenFreq Freq; istringstream isStream(istr);

while (isStream >> token) { transform(token.begin(), token.end(), token.begin(), ::tolower);

stop = 1; for (int count = 0; /* breaking compiler to look at test units*/ count < tfVec.size(); count++) { if (tfVec[count].token == token) { tfVec[count].freq += 1; stop = 0; } }

if (stop) { Freq.token = token; tfVec.push_back(Freq); } } }

void selectionSort(vector& tokFreqVector) { int small; TokenFreq token;

for (int Seq = 0; Seq < tokFreqVector.size() - 1; Seq++) { small = Seq; for (int Seq1 = Seq + 1; Seq1 < tokFreqVector.size(); Seq1++) { if (tokFreqVector[Seq1].freq < tokFreqVector[small].freq) { small = Seq1; if (small != Seq) { token = tokFreqVector[Seq]; tokFreqVector[Seq] = tokFreqVector[small]; tokFreqVector[small] = token; } } } } }

When I call selection sort, to a label to the frequency on ascending order, it works for various input, but it doesn't work with this phrase

"No one wants to die. Even people who want to go to heaven dont want to die to get there. And yet death is the destination we all share. No one has ever escaped it. And that is as it should be, because Death is very likely the single best invention of Life. It is Lifes change agent. It clears out the old to make way for the new. Right now the new is you, but someday not too long from now, you will gradually become the old and be cleared away. Sorry to be so dramatic, but it is quite true. Your time is limited, so dont waste it living someone elses life. Dont be trapped by dogma which is living with the results of other peoples thinking. Dont let the noise of others opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition."

What am I doing wrong?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

Define and explain the nature of nonassociative learning.

Answered: 1 week ago