This is a command-line tool that analyzes text files and provides statistics about word count and character frequency.
- Word Count: Counts the total number of words in a text file
- Character Frequency: Analyzes and displays the frequency of each letter (case-insensitive)
- Sorted Results: Character counts are sorted from most to least frequent
- Python 3.x
No installation required! Just clone or download this repository:
git clone <your-repo-url>
cd bookbotRun BookBot by providing the path to a text file you want to analyze:
python3 main.py <path_to_book>python3 main.py books/frankenstein.txtBookBot will display:
- The path to the file being analyzed
- Total word count
- Character frequency for each letter, sorted by frequency
Example output:
============ BOOKBOT ============
Analyzing book found at books/frankenstein.txt...
----------- Word Count ----------
Found 75767 total words
--------- Character Count -------
e: 44538
t: 29493
a: 25894
o: 24494
i: 23927
n: 23643
s: 20360
r: 20079
h: 19176
d: 16318
l: 12306
m: 10206
u: 10111
c: 9011
f: 8451
y: 7756
w: 7450
p: 5952
g: 5795
b: 4868
v: 3737
k: 1661
x: 691
j: 497
q: 325
z: 235
æ: 28
â: 8
ê: 7
ë: 2
ô: 1
============= END ===============
main.py- Main entry point for the applicationstats.py- Core functions for text analysisget_book_text()- Reads text from a fileget_word_count()- Counts words in the textget_letter_counts()- Counts and sorts letter frequencies
Open source - feel free to use and modify as you like.