コード例 #1
0
 def test_huffman(self):
     text = Helper.read_file("input.txt")
     huffman = Huffman()
     encoding_dictionary = huffman.get_encoding_dictionary(text)
     encoded_text = Helper.encoding(encoding_dictionary, text)
     decoded_text = Helper.decoding(encoding_dictionary, encoded_text)
     self.assertEqual(text, decoded_text)
コード例 #2
0
def __main__():

    text = Helper.read_file("input.txt")
    encoding_dictionary = Huffman().get_encoding_dictionary(text)

    encoded_text = Helper.encoding(encoding_dictionary, text)
    decoded_text = Helper.decoding(encoding_dictionary, encoded_text)

    print(f"\nEncoded text: {encoded_text}")
    print(f"\nDecoded text: {decoded_text}")

    run_tests()