File tree 1 file changed +27
-1
lines changed
1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 1
1
import networkx as nx
2
2
from networkx .algorithms .approximation import clique
3
+ from networkx .algorithms .clique import find_cliques
3
4
import operator
4
5
from utils import *
5
6
@@ -78,4 +79,29 @@ def clique_weights(clique):
78
79
sum_i = sum (vec_clique [i ])
79
80
sum_all .append (sum_i )
80
81
81
- return sum (sum_all )
82
+ return sum (sum_all )
83
+
84
+
85
+ def find_maxlen_clique (text , i , raw ) -> list :
86
+ """find clique with max len"""
87
+ grph = text2graph (text , i , raw = raw )
88
+
89
+ list_cliques = list (find_cliques (grph ))
90
+ list_cliques_len = []
91
+ for i in range (len (list_cliques )):
92
+ len_elmnt = len (list_cliques [i ])
93
+ list_cliques_len .append (len_elmnt )
94
+ index , value = max (enumerate (list_cliques_len ), key = operator .itemgetter (1 ))
95
+ return list_cliques [index ]
96
+
97
+
98
+ def get_abstract (text ) -> set :
99
+ """return 'abstract' of text"""
100
+ list_dicts_enumerate = []
101
+
102
+ for i in np .arange (0.1 , 0.9 , 0.1 ):
103
+ clq = find_maxlen_clique (text , i , raw = True )
104
+ list_dicts_enumerate .append (clq )
105
+ z = set (list_dicts_enumerate [0 ]).intersection (set (list_dicts_enumerate [1 ]))
106
+
107
+ return z
You can’t perform that action at this time.
0 commit comments