def compute_files(user1, user2, file_list, dir_pre, start_num):
match_total = <NUM_LIT:0><EOL>test_total = <NUM_LIT:0><EOL>gold_total = <NUM_LIT:0><EOL>for fi in file_list:<EOL><INDENT>file1 = dir_pre + user1 + "<STR_LIT:/>" + fi + "<STR_LIT>"<EOL>file2 = dir_pre + user2 + "<STR_LIT:/>" + fi + "<STR_LIT>"<EOL>if not os.path.exists(file1):<EOL><INDENT>print("<STR_LIT>", file1, "<STR_LIT>", file=ERROR_LOG)<EOL>return -<NUM_LIT><EOL><DEDENT>if not os.path.exists(file2):<EOL><INDENT>print("<STR_LIT>", file2, "<STR_LIT>", file=ERROR_LOG)<EOL>return -<NUM_LIT><EOL><DEDENT>try:<EOL><INDENT>file1_h = open(file1, "<STR_LIT:r>")<EOL>file2_h = open(file2, "<STR_LIT:r>")<EOL><DEDENT>except IOError:<EOL><INDENT>print("<STR_LIT>", file1, file2, file=ERROR_LOG)<EOL>break<EOL><DEDENT>cur_amr1 = smatch.get_amr_line(file1_h)<EOL>cur_amr2 = smatch.get_amr_line(file2_h)<EOL>if cur_amr1 == "<STR_LIT>":<EOL><INDENT>print("<STR_LIT>", file=ERROR_LOG)<EOL>continue<EOL><DEDENT>if cur_amr2 == "<STR_LIT>":<EOL><INDENT>print("<STR_LIT>", file=ERROR_LOG)<EOL>continue<EOL><DEDENT>amr1 = amr.AMR.parse_AMR_line(cur_amr1)<EOL>amr2 = amr.AMR.parse_AMR_line(cur_amr2)<EOL>test_label = "<STR_LIT:a>"<EOL>gold_label = "<STR_LIT:b>"<EOL>amr1.rename_node(test_label)<EOL>amr2.rename_node(gold_label)<EOL>(test_inst, test_rel1, test_rel2) = amr1.get_triples()<EOL>(gold_inst, gold_rel1, gold_rel2) = amr2.get_triples()<EOL>if verbose:<EOL><INDENT>print("<STR_LIT>", len(test_inst), file=DEBUG_LOG)<EOL>print(test_inst, file=DEBUG_LOG)<EOL>print("<STR_LIT>", len(test_rel1), file=DEBUG_LOG)<EOL>print(test_rel1, file=DEBUG_LOG)<EOL>print("<STR_LIT>", len(test_rel2), file=DEBUG_LOG)<EOL>print(test_rel2, file=DEBUG_LOG)<EOL>print("<STR_LIT>", len(gold_inst), file=DEBUG_LOG)<EOL>print(gold_inst, file=DEBUG_LOG)<EOL>print("<STR_LIT>", len(gold_rel1), file=DEBUG_LOG)<EOL>print(gold_rel1, file=DEBUG_LOG)<EOL>print("<STR_LIT>", len(gold_rel2), file=DEBUG_LOG)<EOL>print(gold_rel2, file=DEBUG_LOG)<EOL><DEDENT>(best_match, best_match_num) = smatch.get_best_match(test_inst, test_rel1, test_rel2,<EOL>gold_inst, gold_rel1, gold_rel2,<EOL>test_label, gold_label)<EOL>if verbose:<EOL><INDENT>print("<STR_LIT>", best_match_num, file=DEBUG_LOG)<EOL>print("<STR_LIT>", smatch.print_alignment(best_match, test_inst, gold_inst), file=DEBUG_LOG)<EOL><DEDENT>match_total += best_match_num<EOL>test_total += (len(test_inst) + len(test_rel1) + len(test_rel2))<EOL>gold_total += (len(gold_inst) + len(gold_rel1) + len(gold_rel2))<EOL>smatch.match_triple_dict.clear()<EOL><DEDENT>(precision, recall, f_score) = smatch.compute_f(match_total, test_total, gold_total)<EOL>return "<STR_LIT>" % f_score<EOL>
Compute the smatch scores for a file list between two users
Args:
user1: user 1 name
user2: user 2 name
file_list: file list
dir_pre: the file location prefix
start_num: the number of restarts in smatch
Returns:
smatch f score.