diff --git a/count_word.py b/count_word.py index e69de29..1831191 100644 --- a/count_word.py +++ b/count_word.py @@ -0,0 +1,23 @@ +import sys +import os + +def countWord(filePath , keyWord): + count = 0 + wordCount = {} + file = open(filePath,"r+") + for word in file.read().split(): + if word not in wordCount: + wordCount[word] = 1 + else: + wordCount[word] += 1 + print wordCount + for key in wordCount.keys(): + #print ("%s %s " %(key , wordCount[key])) + if(key == keyWord): + print key + count = wordCount[key] + + file.close() + return count + +print countWord('./files/testfile.txt','the') diff --git a/count_word.pyc b/count_word.pyc new file mode 100644 index 0000000..92e21fc Binary files /dev/null and b/count_word.pyc differ diff --git a/tests/__init__.pyc b/tests/__init__.pyc new file mode 100644 index 0000000..df8b653 Binary files /dev/null and b/tests/__init__.pyc differ diff --git a/tests/test_countWord.pyc b/tests/test_countWord.pyc new file mode 100644 index 0000000..0631ca1 Binary files /dev/null and b/tests/test_countWord.pyc differ