diff --git a/count_word.py b/count_word.py index e69de29..4327f48 100644 --- a/count_word.py +++ b/count_word.py @@ -0,0 +1,16 @@ + +def countWord(filepath,testWord): + #fp = open(filepath,"r") + wordDict = {} + #for line in fp.readlines(): + with open(filepath,"r") as file: + for line in file: + print line + for word in line.split(" "): + if word in wordDict: + wordDict[word] += 1 + else: + wordDict[word] = 1 + #print wordDict[testWord] + return wordDict[testWord] +countWord("files/testfile.txt","Lorem") diff --git a/count_word.pyc b/count_word.pyc new file mode 100644 index 0000000..b890db8 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..e5774bc 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..08c3426 Binary files /dev/null and b/tests/test_countWord.pyc differ