compression.lempel_ziv¶
One of the several implementations of Lempel-Ziv-Welch compression algorithm https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch
Functions¶
|
Adds given file's length in front (using Elias gamma coding) of the compressed |
|
Adds new strings (curr_string + "0", curr_string + "1") to the lexicon |
|
Reads source file, compresses it and writes the compressed result in destination |
|
Compresses given data_bits using Lempel-Ziv-Welch compression algorithm |
|
Reads given file as bytes and returns them as a long string |
|
Writes given to_write string (should only consist of 0's and 1's) as bytes in the |
Module Contents¶
- compression.lempel_ziv.add_file_length(source_path: str, compressed: str) str ¶
Adds given file’s length in front (using Elias gamma coding) of the compressed string
- compression.lempel_ziv.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
- compression.lempel_ziv.compress(source_path: str, destination_path: str) None ¶
Reads source file, compresses it and writes the compressed result in destination file
- compression.lempel_ziv.compress_data(data_bits: str) str ¶
Compresses given data_bits using Lempel-Ziv-Welch compression algorithm and returns the result as a string
- compression.lempel_ziv.read_file_binary(file_path: str) str ¶
Reads given file as bytes and returns them as a long string
- compression.lempel_ziv.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