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

Method get_tfidf_edge

build_graph.py:123–137  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

121 print_graph_detail(self.g)
122
123 def get_tfidf_edge(self):
124 # 获得tfidf权重矩阵(sparse)和单词列表
125 tfidf_vec = self.get_tfidf_vec()
126
127 count_lst = list() # 统计每个句子的长度
128 for ind, row in tqdm(enumerate(tfidf_vec),
129 desc="generate tfidf edge"):
130 count = 0
131 for col_ind, value in zip(row.indices, row.data):
132 word_ind = self.node_num + col_ind
133 self.g.add_edge(ind, word_ind, weight=value)
134 count += 1
135 count_lst.append(count)
136
137 print_graph_detail(self.g)
138
139 def get_tfidf_vec(self):
140 """

Callers 1

__init__Method · 0.95

Calls 2

get_tfidf_vecMethod · 0.95
print_graph_detailFunction · 0.90

Tested by

no test coverage detected