compression.lempel_ziv ====================== .. py:module:: compression.lempel_ziv .. autoapi-nested-parse:: One of the several implementations of Lempel-Ziv-Welch compression algorithm https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch Functions --------- .. autoapisummary:: compression.lempel_ziv.add_file_length compression.lempel_ziv.add_key_to_lexicon compression.lempel_ziv.compress compression.lempel_ziv.compress_data compression.lempel_ziv.read_file_binary compression.lempel_ziv.write_file_binary Module Contents --------------- .. py:function:: add_file_length(source_path: str, compressed: str) -> str Adds given file's length in front (using Elias gamma coding) of the compressed string .. py:function:: add_key_to_lexicon(lexicon: dict[str, str], curr_string: str, index: int, last_match_id: str) -> None Adds new strings (curr_string + "0", curr_string + "1") to the lexicon .. py:function:: compress(source_path: str, destination_path: str) -> None Reads source file, compresses it and writes the compressed result in destination file .. py:function:: compress_data(data_bits: str) -> str Compresses given data_bits using Lempel-Ziv-Welch compression algorithm and returns the result as a string .. py:function:: read_file_binary(file_path: str) -> str Reads given file as bytes and returns them as a long string .. py:function:: write_file_binary(file_path: str, to_write: str) -> None Writes given to_write string (should only consist of 0's and 1's) as bytes in the file