(windows_len, word_pair_count, word_window_freq, threshold)
| 61 | |
| 62 | |
| 63 | def 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 | |
| 76 | def get_pmi_edge(content_lst, window_size=20, threshold=0.): |
no test coverage detected