Develop a menu-driven application to invoke functions for text compression according to the problem specification and design constrains specified below.
Choose either the keyword, run-length, or Huffman encoding data compression technique. Then enter the text to use for that choice of technique. For keyword encoding access a table of words and symbols to use when replacing a text word with a single character, and for Huffman encoding access a table of characters and variable-length bitstrings to represent those characters.
Text for testing
a Keyword encoding:
“Speech encoding is an important category of audio data compression. The perceptual models used to estimate what a human ear can hear are generally somewhat different from those used for music. The range of frequencies needed to convey the sounds of a human voice are normally far narrower than that needed for music, and the sound is normally less complex.”
Plus a table of these words and symbols:
b Run-length encoding: “AAAALLLiiiiionnnnnn is king”
c Huffman encoding: “CLEATS”
plus a table of characters and bit strings to replace those characters
For keyword encoding, replace words found in the text with a single character (e.g the word “from” would become “$”).
For run-length encoding, replace a long series of a repeated characters with a “flag-character” followed by the repeated character. Followed by a single digit that indicates how many times the character si repeated: “AAAALLLiiiiionnnnnn is king” would become: A*4LLLi*5on*6 is king and for Huffman encoding use the table above to produce a variable-length bitstring for a character string such as “CLEATS”.
Output a descriptive program title. Have an input prompt for the compression technique to apply followed by the text to be compressed. Then, output the compressed text and the compression ratio.
Text compression technique:
Compression codes: k. keyword, r. run-length, h. Huffman
Code choice? R
Original text: AAAALLLiiiiionnnnnn is king
Compressed text: A*4LLLi*5on*6 is king
Compression ratio: 21/27 or 0.77
This assignment has been answered 4 times in private sessions.
© 2023 Codify Tutor. All rights reserved