Question: I need to code in python a way to count frequencies of words from mulitple strings. I want to keep it in memory and keep
I need to code in python a way to count frequencies of words from mulitple strings. I want to keep it in memory and keep apending to it. Once I read a string, count the frquency of words, then add it to the frequencies in memory (but if it is easier you can write to a file and then continue to append to it). So here is an example:
s = "I love you my love"
so frequency is
I 1
love 2
you 1
my 1
now I want a new string s = "I am friend"
it updates the totals to
I 2
love 2
you 1
my 1
am 1
friend 1
I want to keep updating this until I am done and then dump to a file called wordPos using pickle in pythyon.
How do I do this?
I was thinking of using "from collections import Counter" but I am not sure you can. I would need to keep pending to the list.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
