def get_best_match(instance1, attribute1, relation1,<EOL>instance2, attribute2, relation2,<EOL>prefix1, prefix2, doinstance=True, doattribute=True, dorelation=True):
<EOL>(candidate_mappings, weight_dict) = compute_pool(instance1, attribute1, relation1,<EOL>instance2, attribute2, relation2,<EOL>prefix1, prefix2, doinstance=doinstance, doattribute=doattribute,<EOL>dorelation=dorelation)<EOL>if veryVerbose:<EOL><INDENT>print("<STR_LIT>", file=DEBUG_LOG)<EOL>print(candidate_mappings, file=DEBUG_LOG)<EOL>print("<STR_LIT>", file=DEBUG_LOG)<EOL>print(weight_dict, file=DEBUG_LOG)<EOL><DEDENT>best_match_num = <NUM_LIT:0><EOL>best_mapping = [-<NUM_LIT:1>] * len(instance1)<EOL>for i in range(iteration_num):<EOL><INDENT>if veryVerbose:<EOL><INDENT>print("<STR_LIT>", i, file=DEBUG_LOG)<EOL><DEDENT>if i == <NUM_LIT:0>:<EOL><INDENT>cur_mapping = smart_init_mapping(candidate_mappings, instance1, instance2)<EOL><DEDENT>else:<EOL><INDENT>cur_mapping = random_init_mapping(candidate_mappings)<EOL><DEDENT>match_num = compute_match(cur_mapping, weight_dict)<EOL>if veryVerbose:<EOL><INDENT>print("<STR_LIT>", cur_mapping, file=DEBUG_LOG)<EOL>print("<STR_LIT>", match_num, file=DEBUG_LOG)<EOL><DEDENT>while True:<EOL><INDENT>(gain, new_mapping) = get_best_gain(cur_mapping, candidate_mappings, weight_dict,<EOL>len(instance2), match_num)<EOL>if veryVerbose:<EOL><INDENT>print("<STR_LIT>", gain, file=DEBUG_LOG)<EOL><DEDENT>if gain <= <NUM_LIT:0>:<EOL><INDENT>break<EOL><DEDENT>match_num += gain<EOL>cur_mapping = new_mapping[:]<EOL>if veryVerbose:<EOL><INDENT>print("<STR_LIT>", match_num, file=DEBUG_LOG)<EOL>print("<STR_LIT>", cur_mapping, file=DEBUG_LOG)<EOL><DEDENT><DEDENT>if match_num > best_match_num:<EOL><INDENT>best_mapping = cur_mapping[:]<EOL>best_match_num = match_num<EOL><DEDENT><DEDENT>return best_mapping, best_match_num<EOL>
Get the highest triple match number between two sets of triples via hill-climbing.
Arguments:
    instance1: instance triples of AMR 1 ("instance", node name, node value)
    attribute1: attribute triples of AMR 1 (attribute name, node name, attribute value)
    relation1: relation triples of AMR 1 (relation name, node 1 name, node 2 name)
    instance2: instance triples of AMR 2 ("instance", node name, node value)
    attribute2: attribute triples of AMR 2 (attribute name, node name, attribute value)
    relation2: relation triples of AMR 2 (relation name, node 1 name, node 2 name)
    prefix1: prefix label for AMR 1
    prefix2: prefix label for AMR 2
Returns:
    best_match: the node mapping that results in the highest triple matching number
    best_match_num: the highest triple matching number