Closed riturajkunwar closed 4 years ago
I cannot reproduce the error. Did you run python QG_data_loader.py
?
yes. I am working on Windows machine though. Will this repo work on windows machine ?
Thanks for you response mate !!
word2id
is defined here. Please check if your preprocess_single_example
function can access this instance.
I don't have a plan for Windows support, since I don't have any Windows machine.
Maybe your problem comes from the difference between Windows and Unix path ( '/' and '\'). Try remove './'
from these lines and run it again.
No, it cant access this instance. Is it because "word2id" is defined in "main" and has not been passed as argument to the function "preprocess_single_example" ??
I defined word2id
under __main__
to avoid unnecessary pickling during multiprocessing.
And instance defined under __main__
is accessible in a function using it. Try run this script. It runs smooth.
def print_word2id():
print(word2id)
if __name__ == '__main__':
word2id = 3
print_word2id()
Yes you are right. Therefore, "word2id" is accessible in function "preprocess_data" but not in function "preprocess_single_example"
Is it because function "preprocess_single_example" is not called directly called in "main"
It is still accessible. Run this script.
def preprocess_data():
preprocess_single_example()
def preprocess_single_example():
print(word2id)
if __name__ == '__main__':
word2id = 3
preprocess_data()
Its weird, as I could print "word2id" in function "preprocess_data" but not in function "preprocess_single_example" .....
I made a DIRTY fix though:
I added the following statement in function "preprocess_single_example":
word2id, id2word = vocab_read(data_dir.joinpath('vocab.txt'))
It generated all the required .pkl files.
\QG_data_loader.py", line 237, in preprocess_single_example if word in word2id: NameError: name 'word2id' is not defined
It would be nice if you could help resolve the issue !!