-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
26 lines (20 loc) · 682 Bytes
/
Copy pathmain.py
File metadata and controls
26 lines (20 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import sys
from stats import addDict, count_words, get_book_text, count_char, sort_on
def main():
if len(sys.argv) == 2:
pass
else:
print("Usage: python3 main.py <path_to_book>")
sys.exit(1)
path = sys.argv[1]
text = get_book_text(path)
print("============ BOOKBOT ============")
print(f"Analyzing book found at {path}...")
print("----------- Word Count ----------")
count = count_words(text)
print(f"Found {count} total words")
print("--------- Character Count -------")
for d in addDict(count_char(text)):
print(f"{d['char']}: {d['num']}")
print("============= END ===============")
main()