Spaces:
Sleeping
Sleeping
made isnad-narrator network only look at matns containing narrator
Browse files
app.py
CHANGED
|
@@ -322,11 +322,14 @@ def visualize_narrator_taraf(taraf_num, narrator, yaxis):
|
|
| 322 |
G = nx.from_pandas_edgelist(isnad_hadith, source = 'Source', target = 'Destination', create_using = nx.DiGraph())
|
| 323 |
if narrator not in G.nodes():
|
| 324 |
raise gr.Error('Narrator not in Isnad of Taraf!')
|
| 325 |
-
nodes = list(G.nodes)
|
| 326 |
-
nodes = [node for node in nodes if node not in list(nx.ancestors(G, narrator)) + list(nx.descendants(G, narrator)) and node !=narrator]
|
| 327 |
-
[G.remove_nodes_from(nodes)]
|
| 328 |
-
isnad_pos = nx.nx_agraph.graphviz_layout(G, prog='dot')
|
| 329 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
matns_with_narrator = []
|
| 331 |
end_node = {}
|
| 332 |
for i in range(len(taraf_hadith_split)):
|
|
@@ -340,9 +343,11 @@ def visualize_narrator_taraf(taraf_num, narrator, yaxis):
|
|
| 340 |
if n not in list(end_node.keys()):
|
| 341 |
end_node[n] = []
|
| 342 |
end_node[n].append(str(i))
|
| 343 |
-
|
| 344 |
|
| 345 |
-
|
|
|
|
|
|
|
|
|
|
| 346 |
|
| 347 |
narrator_matn_info = taraf[taraf['bookid_hadithid'].isin(matns_with_narrator)]
|
| 348 |
num_hadith = narrator_matn_info.shape[0]
|
|
|
|
| 322 |
G = nx.from_pandas_edgelist(isnad_hadith, source = 'Source', target = 'Destination', create_using = nx.DiGraph())
|
| 323 |
if narrator not in G.nodes():
|
| 324 |
raise gr.Error('Narrator not in Isnad of Taraf!')
|
| 325 |
+
# nodes = list(G.nodes)
|
| 326 |
+
# nodes = [node for node in nodes if node not in list(nx.ancestors(G, narrator)) + list(nx.descendants(G, narrator)) and node !=narrator]
|
| 327 |
+
# [G.remove_nodes_from(nodes)]
|
|
|
|
| 328 |
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
|
| 332 |
+
|
| 333 |
matns_with_narrator = []
|
| 334 |
end_node = {}
|
| 335 |
for i in range(len(taraf_hadith_split)):
|
|
|
|
| 343 |
if n not in list(end_node.keys()):
|
| 344 |
end_node[n] = []
|
| 345 |
end_node[n].append(str(i))
|
|
|
|
| 346 |
|
| 347 |
+
hadith_cleaned = isnad_hadith['Hadiths Cleaned'].apply(lambda x: any(i in x for i in matns_with_narrator))
|
| 348 |
+
isnad_hadith = isnad_hadith[hadith_cleaned]
|
| 349 |
+
G = nx.from_pandas_edgelist(isnad_hadith, source = 'Source', target = 'Destination', create_using = nx.DiGraph())
|
| 350 |
+
isnad_pos = nx.nx_agraph.graphviz_layout(G, prog='dot')
|
| 351 |
|
| 352 |
narrator_matn_info = taraf[taraf['bookid_hadithid'].isin(matns_with_narrator)]
|
| 353 |
num_hadith = narrator_matn_info.shape[0]
|