I want to find out the frequency of a specific word from a text file. Suppose in my document i have a line "this is me is is " if i input 'is' the output should 3 if my input is 'me' output should 1. i am trying this code
import re
doc1 = re.findall(r'\w+', open('E:\doc1.txt').read().lower())
words = raw_input("Input Number :: ")
docmtfrequency1 = words.count(words)
but it is not giving desired output
collections.Counter() has this covered if I understand your problem. The example from the docs would seem to match your problem.
From the example above you should be able to do:
naive approach to show one way.