def run_all_components(puz_file, component_list_path, eval=True): comp_list=mod_component_list(component_list_path, '', '') concat_output='' N_comp, avg_MRAR, avg_Precision, avg_Attempt_ratio = 0,0,0,0 comps_eval={} for component_path in comp_list: comp_name=component_path.split('/') comp_name=comp_name[len(comp_name)-1] print "Try to solve", puz_file, "using", comp_name eval_result,output=component_test.run_test(puz_file, component_path) if eval_result != None: N_comp=N_comp+1.0 avg_MRAR, avg_Precision, avg_Attempt_ratio = avg_MRAR+eval_result['MRAR'], avg_Precision+eval_result['Precision'], avg_Attempt_ratio+eval_result['Attempt_ratio'] comps_eval[component_path]=eval_result for line in output[0].split('\n'): if line == "": continue concat_output=concat_output+line+'\t'+comp_name+'\n' print puz_file, eval_result else: print comp_name, ": No attempts to solve clues in",puz_file,"were made..." if N_comp != 0: avg_MRAR, avg_Precision, avg_Attempt_ratio = avg_MRAR/N_comp, avg_Precision/N_comp, avg_Attempt_ratio/N_comp avg_eval={'avg_MRAR':avg_MRAR, 'avg_Precision':avg_Precision, 'avg_Attempt_ratio':avg_Attempt_ratio} eval={'avg_eval':avg_eval, 'comps_eval':comps_eval} return concat_output, eval else: return concat_output, None
def run_all_components(puz_file, component_list_path, eval=True): comp_list = mod_component_list(component_list_path, "", "") concat_output = "" N_comp, avg_MRAR, avg_Precision, avg_Attempt_ratio = 0, 0, 0, 0 comps_eval = {} for component_path in comp_list: comp_name = component_path.split("/") comp_name = comp_name[len(comp_name) - 1] print "Try to solve", puz_file, "using", comp_name eval_result, output = component_test.run_test(puz_file, component_path) print "\n------------------------------------------------------------------------------" print " Evaluation of " + component_path.split("/")[-1] print "------------------------------------------------------------------------------" if eval_result != None: N_comp = N_comp + 1.0 avg_MRAR, avg_Precision, avg_Attempt_ratio = ( avg_MRAR + eval_result["MRAR"], avg_Precision + eval_result["Precision"], avg_Attempt_ratio + eval_result["Attempt_ratio"], ) comps_eval[component_path] = eval_result for line in output[0].split("\n"): if line == "": continue concat_output = concat_output + line + "\t" + comp_name + "\n" print puz_file, eval_result else: print comp_name, ": No attempts to solve clues in", puz_file, "were made..." if N_comp != 0: avg_MRAR, avg_Precision, avg_Attempt_ratio = ( avg_MRAR / N_comp, avg_Precision / N_comp, avg_Attempt_ratio / N_comp, ) avg_eval = {"avg_MRAR": avg_MRAR, "avg_Precision": avg_Precision, "avg_Attempt_ratio": avg_Attempt_ratio} eval = {"avg_eval": avg_eval, "comps_eval": comps_eval} return concat_output, eval else: return concat_output, None
def comp_compute(component_path, puz_file): eval_result,output=component_test.run_test(puz_file, component_path) return eval_result, output