GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — ArithmeticEncodingPython/example_binary.py at main · ahmedfgad/ArithmeticEncodingPython Expand file tree/ Copy pathexample_binary.pyMore file actions 33 lines (25 loc) · 1.44 KB / Copy pathexample_binary.pyFile metadata and controls33 lines (25 loc) · 1.44 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 import pyae # Example for encoding a simple text message using the PyAE module. # This example returns the floating-point value in addition to its binary code that encodes the message. frequency_table = {"a": 2, "b": 7, "c": 1} AE = pyae.ArithmeticEncoding(frequency_table=frequency_table, save_stages=True) original_msg = "abc" print("Original Message: {msg}".format(msg=original_msg)) # Encode the message encoded_msg, encoder , interval_min_value, interval_max_value = AE.encode(msg=original_msg, probability_table=AE.probability_table) print("Encoded Message: {msg}".format(msg=encoded_msg)) # Get the binary code out of the floating-point value binary_code, encoder_binary = AE.encode_binary(float_interval_min=interval_min_value, float_interval_max=interval_max_value) print("The binary code is: {binary_code}".format(binary_code=binary_code)) # Decode the message decoded_msg, decoder = AE.decode(encoded_msg=encoded_msg, msg_length=len(original_msg), probability_table=AE.probability_table) decoded_msg = "".join(decoded_msg) print("Decoded Message: {msg}".format(msg=decoded_msg)) print("Message Decoded Successfully? {result}".format(result=original_msg == decoded_msg)) |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |