3
3
import networkx as nx
4
4
import matplotlib .pyplot as plt
5
5
6
- from textplot .matrix import TextMatrix
7
6
from abc import ABCMeta , abstractmethod
8
7
from clint .textui .progress import bar
9
8
@@ -70,7 +69,7 @@ def write_graphml(self, path):
70
69
class Skimmer (Graph ):
71
70
72
71
73
- def build (self , matrix , skim_depth = 10 , d_weights = False ):
72
+ def build (self , text , matrix , skim_depth = 10 , d_weights = False ):
74
73
75
74
"""
76
75
1. For each term in the passed matrix, score its KDE similarity with
@@ -80,14 +79,15 @@ def build(self, matrix, skim_depth=10, d_weights=False):
80
79
pairs and add them as edges.
81
80
82
81
Args:
83
- matrix (TextMatrix): An indexed term matrix.
82
+ text (Text): The source text instance.
83
+ matrix (Matrix): An indexed term matrix.
84
84
skim_depth (int): The number of siblings for each term.
85
85
d_weights (bool): If true, give "close" words low edge weights.
86
86
"""
87
87
88
88
for anchor in bar (matrix .keys ):
89
89
90
- n1 = matrix . text .unstem (anchor )
90
+ n1 = text .unstem (anchor )
91
91
92
92
# Heaviest pair scores:
93
93
pairs = matrix .anchored_pairs (anchor ).items ()
@@ -97,7 +97,7 @@ def build(self, matrix, skim_depth=10, d_weights=False):
97
97
# score, so that similar words are connected by "short" edges.
98
98
if d_weights : weight = 1 - weight
99
99
100
- n2 = matrix . text .unstem (term )
100
+ n2 = text .unstem (term )
101
101
102
102
# NetworkX does not handle numpy types when writing graphml,
103
103
# so we cast the weight to a regular float.
0 commit comments