A code for obtaining word frequency | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

A code for obtaining word frequency

I want to count not only the number of words but also get each word's frequency in a 2100 page book i own. please how can i do that in C ++ or C even

24th May 2018, 9:48 PM
Denzel Richard
Denzel Richard - avatar
2 Answers
+ 1
Okay: 1. enter your whole Text as String 2. get the word you wanna know about as string 3. loop through the first string, and every time a letter matches the first one in your second one, look if the next one matches the second and so on, and if you got [length of word] matches in a row, increase counter. Also for every ' ' there is, increase a spaceCounter Then, divide the first counter by the spaceCounter and you got it. Could that help? Tell me, if you didn't get some part
24th May 2018, 11:42 PM
D B
D B - avatar
0
i am a newbie so I don't even understand what you are talking about.
24th May 2018, 10:00 PM
Denzel Richard
Denzel Richard - avatar