This program reads a large text file "War and Peace" by Tolstoy and two text files with word lists, one for "war-terms" and one for "peace-terms". The program categorizes the chapters of the book as war-related or peace-related based on the density of war and peace terms in each chapter.
This program was created for a functional programming course at the FH Technikum Wien. The program was created using functional programming paradigms.
The program requires the following inputs:
- A large text file, e.g. "War and Peace" by Tolstoy
- Two text files with word lists, e.g. one for "war-terms" and one for "peace-terms"
The program outputs the categorization of the chapters of the book as war-related or peace-related based on the density of war and peace terms in each chapter.
The program categorizes the chapters as war-related or peace-related by counting the occurrences of war and peace terms in each chapter and calculating their relative density. If the density of war terms is higher than the peace density, the chapter is characterized as a war chapter.
To run the program, follow these steps:
- Install Python (version 3.9 or higher)
- Clone this repository to your local machine
- Navigate to the repository directory in your terminal or command prompt
- Install the required dependencies by running the following command:
pip install -r requirements.txt
- Run the following command:
python src/main.py
Note: The program assumes that the input files are located in the in
folder.
Pytest is used for testing. Run the tests by pytest tests.py