-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_function.py
20 lines (17 loc) · 981 Bytes
/
test_function.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import sys
from huffman_encoding_and_decoding import huffman_encoding_func, huffman_decoding_func
sentences_file = open("data.txt", "r")
sentences = sentences_file.readlines()
for number, senctence in enumerate(sentences, 1):
print("This is test case number {}\n".format(str(number)))
print("Encoding process: ")
print("The size of the data is: {}".format(sys.getsizeof(senctence)))
print("The content of the data is: {}".format(senctence))
print("Decoding process: ")
tree, encoded_data = huffman_encoding_func(senctence)
print("The size of the encoded data is: {}".format(sys.getsizeof(int(encoded_data, base=2))))
print("The content of the encoded data is: {}".format(encoded_data))
decoded_data = huffman_decoding_func(encoded_data, tree)
print("The size of the decoded data is: {}".format(sys.getsizeof(decoded_data)))
print("The content of the encoded data is: {}".format(decoded_data))
sentences_file.close()