Created
August 13, 2017 04:58
-
-
Save malithjkmt/e9b89f3081d35231273be6588e4543d2 to your computer and use it in GitHub Desktop.
Total & unique word counter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
uniqu_words = {} | |
total_word_count = 0 | |
inFile = open(sys.argv[1],'r') | |
for line in inFile: | |
tokens = line.split() | |
for word in tokens: | |
uniqu_words[word] = 1 | |
total_word_count += len(tokens) | |
print('Total words: ', total_word_count) | |
print('Unique words: ', len(uniqu_words)) | |
inFile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment