snap-stanford/GreaseLM

About 2-hop node extraction function: According to code, I think it just extract 1hop nodes. Is there other code to change it?

Chienwang5 opened this issue · 1 comments

In these code

def concepts_to_adj_matrices_2hop_all_pair__use_LM__Part1(data):

It extract 2-hop nodes from KG, but it just extract 1-hop nodes from kg actually.

I think it is indeed a 2-hop path: cid_1 - extra_node - cid_2, where cid_1 and cid_2 may be question and answer nodes that come from the qa_nodes of a statement.

Recall that in the code, the extra_nodes are the intersection of the neighbouring nodes of the each qid and aid.

extra_nodes |= set(cpnet_simple[qid]) & set(cpnet_simple[aid])

So I think your conclusion

but it just extract 1-hop nodes from kg actually.

is correct, in the sense that the extra_nodes are just a 1-hop neighbour of qid and aid. However, by taking the intersection, the extra_nodes are the nodes that bridges qid and aid such that together they form a 2-hop path.

Please correct me if my interpretations were wrong:)