This project uses a custom hash table to count word frequencies in a book.
- Python 3.x
- Good knowledge of hash tables and their operations.
-
Clone the repository:
git clone git@github.com:Tim-Quattrochi/py-word-counter.git
-
Navigate to the project directory:
cd py-word-counter
I recommend using a virtual environment to run this program. To create a virtual environment, run the following command:
python -m venv venv
To activate the virtual environment, run the following command:
venv\Scripts\activate
Run the app.py
script to start the program:
python app.py
python3 -m venv venv
To activate the virtual environment, run the following command:
source venv/bin/activate
Run the app.py
script to start the program:
python3 app.py
The program implements a hash table with chaining and uses it to count word frequencies in a book. The hash table supports the following operations:
insert(key, value)
: Inserts a key-value pair into the hash table.lookup(key)
: Returns the value associated with the given key.delete(key)
: Removes the key-value pair associated with the given key from the hash table.__len__()
: Returns the number of key-value pairs in the hash table.resize(int)
: Resizes the hash table to the given size.items()
: Returns a list or generator of all key-value pairs in the hash table.
I am using the unittest
module to test the hash table implementation. To run the tests, use the following command:
python3 -m unittest test_hash_table.py
Book used as dataset:
Gray, J. (1920). The other Miller girl. New York: Chas. Scribners Sons. Link