def compute_pool(instance1, attribute1, relation1,<EOL>instance2, attribute2, relation2,<EOL>prefix1, prefix2, doinstance=True, doattribute=True, dorelation=True):
candidate_mapping = []<EOL>weight_dict = {}<EOL>for instance1_item in instance1:<EOL><INDENT>candidate_mapping.append(set())<EOL>if doinstance:<EOL><INDENT>for instance2_item in instance2:<EOL><INDENT>if normalize(instance1_item[<NUM_LIT:0>]) == normalize(instance2_item[<NUM_LIT:0>]) andnormalize(instance1_item[<NUM_LIT:2>]) == normalize(instance2_item[<NUM_LIT:2>]):<EOL><INDENT>node1_index = int(instance1_item[<NUM_LIT:1>][len(prefix1):])<EOL>node2_index = int(instance2_item[<NUM_LIT:1>][len(prefix2):])<EOL>candidate_mapping[node1_index].add(node2_index)<EOL>node_pair = (node1_index, node2_index)<EOL>if node_pair in weight_dict:<EOL><INDENT>weight_dict[node_pair][-<NUM_LIT:1>] += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>weight_dict[node_pair] = {}<EOL>weight_dict[node_pair][-<NUM_LIT:1>] = <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>if doattribute:<EOL><INDENT>for attribute1_item in attribute1:<EOL><INDENT>for attribute2_item in attribute2:<EOL><INDENT>if normalize(attribute1_item[<NUM_LIT:0>]) == normalize(attribute2_item[<NUM_LIT:0>])and normalize(attribute1_item[<NUM_LIT:2>]) == normalize(attribute2_item[<NUM_LIT:2>]):<EOL><INDENT>node1_index = int(attribute1_item[<NUM_LIT:1>][len(prefix1):])<EOL>node2_index = int(attribute2_item[<NUM_LIT:1>][len(prefix2):])<EOL>candidate_mapping[node1_index].add(node2_index)<EOL>node_pair = (node1_index, node2_index)<EOL>if node_pair in weight_dict:<EOL><INDENT>weight_dict[node_pair][-<NUM_LIT:1>] += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>weight_dict[node_pair] = {}<EOL>weight_dict[node_pair][-<NUM_LIT:1>] = <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>if dorelation:<EOL><INDENT>for relation1_item in relation1:<EOL><INDENT>for relation2_item in relation2:<EOL><INDENT>if normalize(relation1_item[<NUM_LIT:0>]) == normalize(relation2_item[<NUM_LIT:0>]):<EOL><INDENT>node1_index_amr1 = int(relation1_item[<NUM_LIT:1>][len(prefix1):])<EOL>node1_index_amr2 = int(relation2_item[<NUM_LIT:1>][len(prefix2):])<EOL>node2_index_amr1 = int(relation1_item[<NUM_LIT:2>][len(prefix1):])<EOL>node2_index_amr2 = int(relation2_item[<NUM_LIT:2>][len(prefix2):])<EOL>candidate_mapping[node1_index_amr1].add(node1_index_amr2)<EOL>candidate_mapping[node2_index_amr1].add(node2_index_amr2)<EOL>node_pair1 = (node1_index_amr1, node1_index_amr2)<EOL>node_pair2 = (node2_index_amr1, node2_index_amr2)<EOL>if node_pair2 != node_pair1:<EOL><INDENT>if node1_index_amr1 > node2_index_amr1:<EOL><INDENT>node_pair1 = (node2_index_amr1, node2_index_amr2)<EOL>node_pair2 = (node1_index_amr1, node1_index_amr2)<EOL><DEDENT>if node_pair1 in weight_dict:<EOL><INDENT>if node_pair2 in weight_dict[node_pair1]:<EOL><INDENT>weight_dict[node_pair1][node_pair2] += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>weight_dict[node_pair1][node_pair2] = <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>weight_dict[node_pair1] = {-<NUM_LIT:1>: <NUM_LIT:0>, node_pair2: <NUM_LIT:1>}<EOL><DEDENT>if node_pair2 in weight_dict:<EOL><INDENT>if node_pair1 in weight_dict[node_pair2]:<EOL><INDENT>weight_dict[node_pair2][node_pair1] += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>weight_dict[node_pair2][node_pair1] = <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>weight_dict[node_pair2] = {-<NUM_LIT:1>: <NUM_LIT:0>, node_pair1: <NUM_LIT:1>}<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if node_pair1 in weight_dict:<EOL><INDENT>weight_dict[node_pair1][-<NUM_LIT:1>] += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>weight_dict[node_pair1] = {-<NUM_LIT:1>: <NUM_LIT:1>}<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>return candidate_mapping, weight_dict<EOL>
compute all possible node mapping candidates and their weights (the triple matching number gain resulting from
mapping one node in AMR 1 to another node in AMR2)

Arguments:
    instance1: instance triples of AMR 1
    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
    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:
  candidate_mapping: a list of candidate nodes.
                   The ith element contains the node indices (in AMR 2) the ith node (in AMR 1) can map to.
                   (resulting in non-zero triple match)
  weight_dict: a dictionary which contains the matching triple number for every pair of node mapping. The key
               is a node pair. The value is another dictionary. key {-1} is triple match resulting from this node
               pair alone (instance triples and attribute triples), and other keys are node pairs that can result
               in relation triple match together with the first node pair.