FDSRashid commited on
Commit
2f8e2f5
·
verified ·
1 Parent(s): bbeeedc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -74,11 +74,18 @@ def network_narrator(narrator_id, fst_year, lst_year, yaxis):
74
  html = net.generate_html()
75
  html = html.replace("'", "\"")
76
 
 
 
 
 
 
 
 
77
  return f"""<iframe style="width: 100%; height: 600px;margin:0 auto" name="result" allow="midi; geolocation; microphone; camera;
78
  display-capture; encrypted-media;" sandbox="allow-modals allow-forms
79
  allow-scripts allow-same-origin allow-popups
80
  allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
81
- allowpaymentrequest="" frameborder="0" srcdoc='{html}'></iframe>""", edges_prepped[['Teacher', 'Student', 'Tarafs', 'Hadiths', 'Isnads', 'Books']]
82
 
83
  def narrator_retriever(name):
84
  return narrator_bios[(narrator_bios['Official Name'].apply(lambda x: araby.strip_diacritics(x)).str.contains(araby.strip_diacritics(name))) | (narrator_bios['Famous Name'].apply(lambda x: araby.strip_diacritics(x)).str.contains(araby.strip_diacritics(name))) | (narrator_bios['Rawi ID'].astype(str) == name)][['Rawi ID', 'Title Name', 'Official Name', 'Famous Name', 'Number of Narrations', 'Narrator Rank', 'Generation' ]]
@@ -100,7 +107,7 @@ with gr.Blocks() as demo:
100
  Yaxis = gr.Dropdown(choices = ['Tarafs', 'Hadiths', 'Isnads', 'Books'], value = 'Tarafs', label = 'Variable to Display', info = 'Choose the variable to visualize.')
101
  image_output = gr.HTML()
102
  image_button = gr.Button("Visualize!")
103
- image_button.click(network_narrator, inputs=[image_input, FirstYear, Last_Year, Yaxis], outputs=[image_output, gr.DataFrame()])
104
 
105
 
106
 
 
74
  html = net.generate_html()
75
  html = html.replace("'", "\"")
76
 
77
+ edge_narrator = edge_info[(edge_info['Teacher_ID'] == narrator_id) | (edge_info['Student_ID'] == narrator_id)]
78
+ narrator_taraf = taraf_info[taraf_info['ID'].isin(edge_narrator['Edge_ID'].to_numpy())]
79
+ narrator_taraf = narrator_taraf[(narrator_taraf['Year'] >= fstyear)& (narrator_taraf['Year'] <= lstyear)]
80
+ merge_edge = narrator_taraf.merge(edges[['Edge_ID', 'Edge_Name']], left_on = 'ID', right_on = 'Edge_ID')
81
+ merge_edge_group = merge_edge.groupby('Edge_Name').sum().reset_index()[['Taraf', 'Hadith', 'Isnad', 'Edge_Name']]
82
+ merge_group_formatted = splitIsnad(merge_edge_group)
83
+
84
  return f"""<iframe style="width: 100%; height: 600px;margin:0 auto" name="result" allow="midi; geolocation; microphone; camera;
85
  display-capture; encrypted-media;" sandbox="allow-modals allow-forms
86
  allow-scripts allow-same-origin allow-popups
87
  allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
88
+ allowpaymentrequest="" frameborder="0" srcdoc='{html}'></iframe>""", edges_prepped[['Teacher', 'Student', 'Tarafs', 'Hadiths', 'Isnads', 'Books']], merge_group_formatted
89
 
90
  def narrator_retriever(name):
91
  return narrator_bios[(narrator_bios['Official Name'].apply(lambda x: araby.strip_diacritics(x)).str.contains(araby.strip_diacritics(name))) | (narrator_bios['Famous Name'].apply(lambda x: araby.strip_diacritics(x)).str.contains(araby.strip_diacritics(name))) | (narrator_bios['Rawi ID'].astype(str) == name)][['Rawi ID', 'Title Name', 'Official Name', 'Famous Name', 'Number of Narrations', 'Narrator Rank', 'Generation' ]]
 
107
  Yaxis = gr.Dropdown(choices = ['Tarafs', 'Hadiths', 'Isnads', 'Books'], value = 'Tarafs', label = 'Variable to Display', info = 'Choose the variable to visualize.')
108
  image_output = gr.HTML()
109
  image_button = gr.Button("Visualize!")
110
+ image_button.click(network_narrator, inputs=[image_input, FirstYear, Last_Year, Yaxis], outputs=[image_output, gr.DataFrame(), gr.DataFrame()])
111
 
112
 
113