MCPcopy Create free account
hub / github.com/chengsen/PyTorch_TextGCN / count_pmi

Function count_pmi

build_graph.py:63–73  ·  view source on GitHub ↗
(windows_len, word_pair_count, word_window_freq, threshold)

Source from the content-addressed store, hash-verified

61
62
63def count_pmi(windows_len, word_pair_count, word_window_freq, threshold):
64 word_pmi_lst = list()
65 for word_pair, W_i_j in tqdm(word_pair_count.items(), desc="Calculate pmi between words"):
66 word_freq_1 = word_window_freq[word_pair[0]]
67 word_freq_2 = word_window_freq[word_pair[1]]
68
69 pmi = cal_pmi(W_i_j, windows_len, word_freq_1, word_freq_2)
70 if pmi <= threshold:
71 continue
72 word_pmi_lst.append([word_pair[0], word_pair[1], pmi])
73 return word_pmi_lst
74
75
76def get_pmi_edge(content_lst, window_size=20, threshold=0.):

Callers 1

get_pmi_edgeFunction · 0.85

Calls 1

cal_pmiFunction · 0.85

Tested by

no test coverage detected