This is a C++ project that demonstrates the use of CMake, Google Test, and Doxygen to build a project that calculates the frequency of words in a text file and verifies that the frequency distribution follows Zipf's Law. The project contains two different implementations to process a book, get the distribution of its words, rank those words, count the hapax legomena, and to graph the Zipf's Law as a log-log plot.
The first implementation uses associative containers like std::map and std::multimap, while the second implementation relies solely on vector and algorithms from the STL (Standard Template Library).
Both matplot++ and python are used to generate the log-log plot of the Zipf's Law.
Install the dependencies:
conda env create -f environment.ymlThis will create a conda environment called cppdev which you can activate with:
conda activate cppdevTo build the project, create a build directory and run CMake from there:
mkdir build
cd build
cmake ..
cmake --build .You can now run the executable:
./bin/zipfOr, ru
You can now run the tests:
ctestIt might be called ctest.exe in Windows.
The documentation will also be generated in the build/docs/sphinx/index.html directory. Open the index.html file in a web browser to view it.
To clean the project, just remove the build directory:
rm -rf build