pycl/Code/freq.py
def countWords(words, filename):
	"""Counts words in file and returns dictionary."""
	try:
		file = open(filename, "r")
		tokens = [ string.strip(i.lower()) for i in file.read().split() ]
		for i in tokens:
			words[i] = words.get(i, 0) + 1
		file.close()
	except IOError:
		print "Cannot read from file:", filename
	return words
Counts words in file and returns dictionary.
Counts words in file and returns dictionary.
Counts words in file and returns dictionary .
def countWords(words, filename):
	try:
		file = open(filename, "r")
		tokens = [ string.strip(i.lower()) for i in file.read().split() ]
		for i in tokens:
			words[i] = words.get(i, 0) + 1
		file.close()
	except IOError:
		print "Cannot read from file:", filename
	return words
def countWords ( words , filename ) : try : file = open ( filename , "r" ) tokens = [ string . strip ( i . lower ( ) ) for i in file . read ( ) . split ( ) ] for i in tokens : words [ i ] = words . get ( i , 0 ) + 1 file . close ( ) except IOError : print "Cannot read from file:" , filename return words
Counts words in file and returns dictionary.
Counts words in file and returns dictionary .
"""Counts words in file and returns dictionary."""
words
filename