Research Article
n-Gram-Based Text Compression
Algorithm 4
Pseudocode of the decompression phase.
| input: The encoded stream | | output: The decoded stream | | () inputstring ← encodedstream | | () while length of inputstring > 0 do | | () firstbyte = read first byte from the inputstring | | () delete first byte of the the inputstring | | () dict = get value of three bits of firstbyte | | () if dict ≤ 5 then | | () number = getnumberbytereadmore(dict) | | () bytereadmore = read number byte more from the inputstring | | () delete number byte of the inputstring | | () indexstring = get last five bits of the firstbyte + the bytereadmore | | () indexvalue = get value of the the indexstring | | () output += decompress(indexvalue, dict) | | () end | | () else if dict = 6 then | | () output += newline | | () end | | () else | | () number = value of five last bits of the firstbyte | | () bytereadmore = read number byte more from the inputstring | | () output += decode for the bytereadmore | | () end | | () end |
|