-1

**Decompression Function: load a file bin from compression function **

def lzwDecompressionText () :
loadCompressed = open ("CompreText.bin","rb")
compressed = pickle.load(loadCompressed)    
print("", compressed)
dictionary =defaultdict(dict)
lenDictionary = 256
decompressed_data = ""
string=""
for i in range(256):
    dictionary[i] = chr(i)
Traceback (most recent call last):
  File "c:/Users/anton/Documents/GitHub/Project-LZW/LZW-Project/test.py", line 21, in <module>
    lzwDecompressionText()
  File "c:\Users\anton\Documents\GitHub\Project-LZW\LZW-Project\textLzw.py", line 70, in lzwDecompressionText
    if not (code in dictionary):
TypeError: unhashable type: 'dict'
for code in compressed:
    if not (code in dictionary):
        dictionary[code] = string + (string[0])
decompressed_data += dictionary[code]
if not(len(string) == 0):
    dictionary[lenDictionary] = string + (dictionary[code][0])
    lenDictionary += 1
string = dictionary[code]
Klaus D.
  • 13,874
  • 5
  • 41
  • 48
giangri_93
  • 29
  • 3

1 Answers1

0

It seems that at least some of your code values in compressed (loaded from a pickled file) simply happen to be of type dict, contrary to your expectation of int.

See also: TypeError : Unhashable type.

Vytas
  • 754
  • 5
  • 14