Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve word generation cyclic file reading (#54)
This pull request includes several improvements to the word_generator function in the bing_rewards/__init__.py file. The changes enhance error handling, ensure uniform random distribution, and improve code readability. Enhancements to word_generator function: - Type hints: specified the return type as Generator[str, None, None]. - Added yields and potential exceptions in the docstring. - Implemented error handling for FileNotFoundError and IOError, with appropriate error messages and re-raising of exceptions. - Ensured the function handles empty keyword files by raising a ValueError if the file size is zero. (Useful when implementing a feature to add your own .txt files for searches) - Improved the random starting position logic (to capture the whole txt file) and ensured clean line boundaries by discarding partial lines and skipping empty lines.
- Loading branch information