atpaino / deep-text-corrector

Deep learning models trained to correct input errors in short, message-like text
Apache License 2.0
1.23k stars 266 forks source link

'zip' object is not subscriptable #16

Open asingh9530 opened 6 years ago

asingh9530 commented 6 years ago

When i tried running python correct_text.py --train_path /movie_dialog_train.txt \ --val_path /movie_dialog_val.txt \ --config DefaultMovieDialogConfig \ --data_reader_type MovieDialogReader \ --model_path /movie_dialog_model

it gives me error

File "correct_text.py", line 438, in tf.app.run() File "/home/abhinavsingh/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "correct_text.py", line 413, in main data_reader = MovieDialogReader(config, FLAGS.train_path) File "/home/abhinavsingh/deep-text-corrector-master/text_corrector_data_readers.py", line 82, in init dataset_copies=dataset_copies) File "/home/abhinavsingh/deep-text-corrector-master/data_reader.py", line 46, in init self.token_to_id = dict(full_token_and_id[:max_vocabulary_size]) TypeError: 'zip' object is not subscriptable

micooke commented 5 years ago

change line 46 to self.token_to_id = dict((k, self.full_token_to_id[k]) for k in list(self.full_token_to_id.keys())[:max_vocabulary_size])

maheshmaddi commented 5 years ago

change line 46 to self.token_to_id = dict((k, self.full_token_to_id[k]) for k in list(self.full_token_to_id.keys())[:max_vocabulary_size])

It worked.. Thank you..

al-yakubovich commented 4 years ago

change line 46 to self.token_to_id = dict((k, self.full_token_to_id[k]) for k in list(self.full_token_to_id.keys())[:max_vocabulary_size])

I changed line 46 but still got the error:

     44             full_token_and_id = zip(vocabulary, range(len(vocabulary)))
     45             self.full_token_to_id = dict(full_token_and_id)
---> 46             self.token_to_id = dict((k, self.full_token_to_id[k]) for k in list(self.full_token_to_id.keys())[:max_vocabulary_size])
     47 
     48         self.id_to_token = {v: k for k, v in self.token_to_id.items()}

TypeError: 'zip' object is not subscriptable
heyudao commented 3 years ago

after changing the line 46 best to restart kernel then shld work fine