def smart_init_mapping(candidate_mapping, instance1, instance2):
random.seed()<EOL>matched_dict = {}<EOL>result = []<EOL>no_word_match = []<EOL>for i, candidates in enumerate(candidate_mapping):<EOL><INDENT>if not candidates:<EOL><INDENT>result.append(-<NUM_LIT:1>)<EOL>continue<EOL><DEDENT>value1 = instance1[i][<NUM_LIT:2>]<EOL>for node_index in candidates:<EOL><INDENT>value2 = instance2[node_index][<NUM_LIT:2>]<EOL>if value1 == value2:<EOL><INDENT>if node_index not in matched_dict:<EOL><INDENT>result.append(node_index)<EOL>matched_dict[node_index] = <NUM_LIT:1><EOL>break<EOL><DEDENT><DEDENT><DEDENT>if len(result) == i:<EOL><INDENT>no_word_match.append(i)<EOL>result.append(-<NUM_LIT:1>)<EOL><DEDENT><DEDENT>for i in no_word_match:<EOL><INDENT>candidates = list(candidate_mapping[i])<EOL>while candidates:<EOL><INDENT>rid = random.randint(<NUM_LIT:0>, len(candidates) - <NUM_LIT:1>)<EOL>candidate = candidates[rid]<EOL>if candidate in matched_dict:<EOL><INDENT>candidates.pop(rid)<EOL><DEDENT>else:<EOL><INDENT>matched_dict[candidate] = <NUM_LIT:1><EOL>result[i] = candidate<EOL>break<EOL><DEDENT><DEDENT><DEDENT>return result<EOL>
Initialize mapping based on the concept mapping (smart initialization)
Arguments:
    candidate_mapping: candidate node match list
    instance1: instance triples of AMR 1
    instance2: instance triples of AMR 2
Returns:
    initialized node mapping between two AMRs