I am having a text..
text= ''' One of the best ways to make yourself happy in the present is to
recall happy times from the past memories '''
I want to match each word in the match list and count their occurrence.
match=['happy birthday to me' , 'john sent me the memo app' , 'self time' , 'call the rom']
Example- In first iteration i.e, happy birthday to me...
happy is counted 2 times , birthday is counted 0 times , to is counted 2 times , me is counted 1 time. ('me' in memories)
I want the result as-
happy(2) birthday(0) to(2) me(1)
john(0) sent(1) me(1) the(3) memo(1) app(2)
self(1) time(1)
call(1) the(3) rom(1)
I tried this...
for textmatch in match:
num=text.count(textmatch)
textmatch= textmatch +'(' + str(num) +')'
print(textmatch)
But this doesnt do the job.