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

UnboundLocalError: local variable 'res' referenced before assignment #4

Open
TianxingWang0 opened this issue Dec 10, 2019 · 4 comments

Comments

@TianxingWang0
Copy link

Hello, I run the preprocessing command and this error occurred. I read the source code and found that the local variable 'res' is defined in 'if' part. Maybe the condition in line 72 is False so the 'res' has not been defined while referenced in line 136.

<E_3> father's garage had been destroyed, <C_1><E_1>Spike<C_1><E_1> investigated <C_1><E_1>the Autobots'<C_1><E_1> deserted base at Mount Saint Hillary, learning that <C_1><E_1><C_2><C_3><E_3>Buster<C_1><E_1><C_2><C_3><E_3> had been captured by <C_1><E_1>the Earth-based Decepticons<C_1><E_1>.
id test-16
text Indeed, <C_1><E_1><C_2><C_3><E_3> Buster <A...
pronoun his
pronoun_offset 490
a Buster
a_offset 33
a_coref False
b Maximus
b_offset 192
b_coref False
url http://en.wikipedia.org/wiki/Spike_Witwicky
label 2
pretrained [False, True, False, True, False, False, False...
Name: 0, dtype: object
Traceback (most recent call last):
File "run.py", line 245, in
main()
File "run.py", line 241, in main
force=args.force
File "run.py", line 136, in run
return res
UnboundLocalError: local variable 'res' referenced before assignment

@sattree
Copy link
Owner

sattree commented Dec 11, 2019

Yes, you are correct. The code assumes you would be running the model to train or evaluate along with preprocessing.

I'll push out a fix soon.

Meanwhile, even though the error occurred, the preprocessing should have completed fine if you didn't see any other errors. The script would have cached the preprocessed output in your experiment directory. The idea of running preprocessing in isolation is two-fold - either you want to just analyze the preprocessed output or you want to save preprocessing time by caching the output for further modeling experiments.

@TianxingWang0
Copy link
Author

Thanks, I did not see other errors, so I can continue to finish the train and the prediction?

@sattree
Copy link
Owner

sattree commented Dec 12, 2019

Judging by the output you had pasted above, it seems like you have the expected preprocessed output. So, you should be able to finish training and prediction.

@TianxingWang0
Copy link
Author

Thanks a lot, I'll try soon~

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

2 participants