csensemakers / desci-sense

2 stars 2 forks source link

md_list is not always defined #107

Open ShaRefOh opened 7 months ago

ShaRefOh commented 7 months ago

Problem in multi_stage_parser.py, with the function process_ref_post: md_list could be initialized, e.g., md_list = [], as the function cannot return it if it is not defined. Otherwise, you can get the error:

File "/Users/shaharorielkagan/Documents/Python/desci-sense/desci_sense/evaluation/eval_benchmark_v0.py", line 187, in pred_labels(df) File "/Users/shaharorielkagan/Documents/Python/desci-sense/desci_sense/evaluation/eval_benchmark_v0.py", line 54, in pred_labels response = model.process_text(df['Text'][i]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/shaharorielkagan/Documents/Python/desci-sense/desci_sense/parsers/multi_stage_parser.py", line 354, in process_text result = self.process_ref_post(post) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/shaharorielkagan/Documents/Python/desci-sense/desci_sense/parsers/multi_stage_parser.py", line 340, in process_ref_post result = self.process_by_case(post, case, md_list) ^^^^^^^ UnboundLocalError: cannot access local variable 'md_list' where it is not associated with a value

ShaRefOh commented 7 months ago

I simply initialized md_list = [] in the beginning of the function locally. I can commit if @ronentk thinks it is a good solution.

ronentk commented 7 months ago

Thanks for the catch @ShaRefOh , yes that method is still under construction. I uploaded the default init so you can pull the new commit