Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'zip' object is not subscriptable #16

Open
asingh9530 opened this issue Sep 18, 2018 · 4 comments
Open

'zip' object is not subscriptable #16

asingh9530 opened this issue Sep 18, 2018 · 4 comments

Comments

@asingh9530
Copy link

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
Copy link

micooke commented Apr 4, 2019

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
Copy link

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
Copy link

al-yakubovich commented Jan 22, 2020

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
Copy link

heyudao commented Feb 2, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants