FDSRashid commited on
Commit
bb8f84b
ยท
verified ยท
1 Parent(s): 4a367b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -80,8 +80,8 @@ def visualize_isnad(taraf_num, yaxis):
80
  node = [int(n) for n, d in G.out_degree() if d == 0][0]
81
  gen_node = narrator_bios[narrator_bios['Rawi ID']==node]['Generation'].iloc[0]
82
  name_node = narrator_bios[narrator_bios['Rawi ID']==node]['Famous Name'].iloc[0]
83
- lst_hadith.append([taraf_matns[i], gen_node, name_node, taraf_book[i], taraf_author[i], taraf_hadith_number[i]])
84
- df = pd.DataFrame(lst_hadith, columns = ['Matn', 'Generation', 'Name', 'Book_Name', 'Author', 'Hadith Number'])
85
 
86
  #hadith_cleaned = isnad_info['Hadiths Cleaned'].apply(lambda x: any(i in x for i in taraf_hadith_split) )
87
  hadith_cleaned = isnad_info['Tarafs Cleaned'].apply(lambda x: taraf_num in x)
@@ -90,6 +90,8 @@ def visualize_isnad(taraf_num, yaxis):
90
  isnad_hadith['Student'] = isnad_hadith['Destination'].apply(lambda x: narrator_bios[narrator_bios['Rawi ID'].astype(int) == int(x)]['Famous Name'].to_list())
91
  isnad_hadith['Teacher'] = isnad_hadith['Teacher'].apply(lambda x: x[0] if len(x)==1 else 'ูู„ุงู†')
92
  isnad_hadith['Student'] = isnad_hadith['Student'].apply(lambda x: x[0] if len(x)==1 else 'ูู„ุงู†')
 
 
93
  net = Network(directed =True)
94
  for _, row in isnad_hadith.iterrows():
95
  source = row['Source']
@@ -133,7 +135,11 @@ def visualize_isnad(taraf_num, yaxis):
133
  net.add_node(source, font = {'size':50, 'color': 'Black'}, color = '#000000', label = f'{row["Teacher"]}')
134
  else:
135
  net.add_node(source, font = {'size':30, 'color': 'red'}, color = value_to_hex(teacher_narrations), label = f'{row["Teacher"]} \n {teacher_rank} \n ID: {row["Source"]} - Gen {teacher_gen}')
136
- net.add_node(target, font = {'size': 30, 'color': 'red'}, color = value_to_hex(student_narrations), label = f'{row["Student"]} \n{student_rank} \n ID: {row["Destination"]} - Gen {student_gen}')
 
 
 
 
137
  net.add_edge(source, target, color = value_to_hex(int(row[f'{yaxis} Count'])), label = f"{row[f'{yaxis} Count']}")
138
  net.barnes_hut(gravity=-5000, central_gravity=0.3, spring_length=200)
139
  html = net.generate_html()
 
80
  node = [int(n) for n, d in G.out_degree() if d == 0][0]
81
  gen_node = narrator_bios[narrator_bios['Rawi ID']==node]['Generation'].iloc[0]
82
  name_node = narrator_bios[narrator_bios['Rawi ID']==node]['Famous Name'].iloc[0]
83
+ lst_hadith.append([taraf_matns[i], gen_node, name_node, taraf_book[i], taraf_author[i], taraf_hadith_number[i], node, i])
84
+ df = pd.DataFrame(lst_hadith, columns = ['Matn', 'Generation', 'Name', 'Book_Name', 'Author', 'Book Hadith Number', 'End Transmitter ID', 'Hadith Number'])
85
 
86
  #hadith_cleaned = isnad_info['Hadiths Cleaned'].apply(lambda x: any(i in x for i in taraf_hadith_split) )
87
  hadith_cleaned = isnad_info['Tarafs Cleaned'].apply(lambda x: taraf_num in x)
 
90
  isnad_hadith['Student'] = isnad_hadith['Destination'].apply(lambda x: narrator_bios[narrator_bios['Rawi ID'].astype(int) == int(x)]['Famous Name'].to_list())
91
  isnad_hadith['Teacher'] = isnad_hadith['Teacher'].apply(lambda x: x[0] if len(x)==1 else 'ูู„ุงู†')
92
  isnad_hadith['Student'] = isnad_hadith['Student'].apply(lambda x: x[0] if len(x)==1 else 'ูู„ุงู†')
93
+
94
+ end_nodes = df['End Transmitter ID'].tolist()
95
  net = Network(directed =True)
96
  for _, row in isnad_hadith.iterrows():
97
  source = row['Source']
 
135
  net.add_node(source, font = {'size':50, 'color': 'Black'}, color = '#000000', label = f'{row["Teacher"]}')
136
  else:
137
  net.add_node(source, font = {'size':30, 'color': 'red'}, color = value_to_hex(teacher_narrations), label = f'{row["Teacher"]} \n {teacher_rank} \n ID: {row["Source"]} - Gen {teacher_gen}')
138
+ if target in end_nodes:
139
+ end_matn_info = df[df["End Transmitter ID"] == target]
140
+ net.add_node(target, font = {'size': 30, 'color': 'red'}, color = value_to_hex(student_narrations), label = f'{row["Student"]} \n{student_rank} \n ID: {row["Destination"]} - Gen {student_gen} \n Hadith {end_matn_info["Hadith Number"]}')
141
+ else:
142
+ net.add_node(target, font = {'size': 30, 'color': 'red'}, color = value_to_hex(student_narrations), label = f'{row["Student"]} \n{student_rank} \n ID: {row["Destination"]} - Gen {student_gen}')
143
  net.add_edge(source, target, color = value_to_hex(int(row[f'{yaxis} Count'])), label = f"{row[f'{yaxis} Count']}")
144
  net.barnes_hut(gravity=-5000, central_gravity=0.3, spring_length=200)
145
  html = net.generate_html()