cj2001 / nodes2021_kg_workshop

170 stars 116 forks source link

def get_word_vec_similarity() in notebooks/00-populate_basic_graph.ipynb #19

Open gtaaffeite opened 2 years ago

gtaaffeite commented 2 years ago

notebook In [21]: def get_word_vec_similarity(node1, node2, node_ls):
node1_vec = [tup[4] for tup in node_ls if tup[0] == node1] node2_vec = [tup[4] for tup in node_ls if tup[0] == node2] if node1_vec and node2_vec: return cosine_similarity(node1_vec, node2_vec) return 'one or both terms not found'