def _compute_table_rank(self, contained):
logger.log(logging.DEBUG, "Computing tables relations")
tables_rank = [([], []) for _ in range(6)]
indices = [
set(l) for l in np.split(contained.indices, contained.indptr)[1:-1]
]
for root in self.dictionary.roots:
for t0, t1 in combinations(self.dictionary.roots[root], 2):
commons = [self.dictionary.index[i] for i in indices[t0.index] & indices[t1.index]]
rank = max(map(lambda t: t.rank, commons))
tables_rank[rank][0].extend((t0.index, t1.index))
tables_rank[rank][1].extend((t1.index, t0.index))
return [coo_matrix(([True]*len(i), (i, j)), shape=self.shape, dtype=np.bool) for i, j in tables_rank]
评论列表
文章目录