def add_sentences(self, sentences):
"""
@type sentences: list[Sentence]
"""
counter = self.counter
G = self.G
for sent in sentences:
counter.update(ngrams(sent.tokens, self.N))
G.add_nodes_from(sent.tokens)
updated_edges = []
for v in counter.elements():
s = v[0]
t = v[1]
c = counter[v]
updated_edges.append((s, t, c))
G.add_weighted_edges_from(updated_edges)
feedback_graph.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录