forked from p46318075/CodePattern
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
821 B
25 lines
821 B
9 months ago
|
from cppy.cp_util import *
|
||
|
|
||
|
|
||
|
def extractWords(path_to_file):
|
||
8 months ago
|
assert(type(path_to_file) is str), "Must be a string"
|
||
|
assert(path_to_file), "Must be a non-empty string"
|
||
9 months ago
|
return extract_file_words(path_to_file)
|
||
|
|
||
|
def frequencies(word_list):
|
||
8 months ago
|
assert(type(word_list) is list), "Must be a list"
|
||
|
assert(word_list != []), "Must be a non-empty list"
|
||
9 months ago
|
return get_frequencies(word_list)
|
||
|
|
||
|
def sort(word_freqs):
|
||
8 months ago
|
assert(type(word_freqs) is dict), "Must be a dictionary"
|
||
|
assert(word_freqs != {}), "Must be a non-empty dictionary"
|
||
9 months ago
|
return sort_dict(word_freqs)
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
try:
|
||
|
word_freqs = sort(frequencies(extractWords( testfilepath )))
|
||
|
print_word_freqs(word_freqs)
|
||
|
except Exception as e:
|
||
|
print(" Something wrong: {0}".format(e) )
|