FDSRashid commited on
Commit
261a8a2
·
1 Parent(s): a1af215

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -21,8 +21,8 @@ def value_to_hex(value):
21
  rgba_color = cmap(value)
22
  return "#{:02X}{:02X}{:02X}".format(int(rgba_color[0] * 255), int(rgba_color[1] * 255), int(rgba_color[2] * 255))
23
 
24
- def subsetEdges(city, year):
25
- info = taraf_info[(taraf_info['Year'] == year) & (taraf_info['City'] == city)]
26
  narrators = edge_info[edge_info['Edge_ID'].isin(info['ID'].unique())]
27
  return narrators
28
  def splitIsnad(dataframe):
@@ -32,8 +32,8 @@ def splitIsnad(dataframe):
32
  return dataframe
33
 
34
 
35
- def network_visualizer(yaxis, city, year, num_nodes):
36
- edges = splitIsnad(subsetEdges(city, year))[['Teacher', 'Student', yaxis]].reset_index()
37
  #.groupby(['Teacher', 'Student']).sum()
38
  if edges.shape[0] > num_nodes:
39
  edge_15 = edges.sample(num_nodes)
@@ -74,9 +74,10 @@ def network_visualizer(yaxis, city, year, num_nodes):
74
  with gr.Blocks() as demo:
75
  Yaxis = gr.Dropdown(choices = ['Tarafs', 'Hadiths', 'Isnads', 'Books'], value = 'Tarafs', label = 'Variable to Display', info = 'Choose the variable to visualize.')
76
  Places = gr.Dropdown(choices = cities, value = 'المدينه', label = 'Location')
77
- Last_Year = gr.Slider(min_year, max_year, value = 9, label = 'End', info = 'Choose the year to display Narrators')
 
78
  num_narrators = gr.Slider(0, 700, value = 400, label = 'Narrators', info = 'Choose the number of Narrators to display')
79
 
80
  btn = gr.Button('Submit')
81
- btn.click(fn = network_visualizer, inputs = [Yaxis, Places, Last_Year, num_narrators], outputs = gr.HTML())
82
  demo.launch()
 
21
  rgba_color = cmap(value)
22
  return "#{:02X}{:02X}{:02X}".format(int(rgba_color[0] * 255), int(rgba_color[1] * 255), int(rgba_color[2] * 255))
23
 
24
+ def subsetEdges(city, fstyear, lstyear):
25
+ info = taraf_info[(taraf_info['Year'] >= fstyear) & (taraf_info['City'] == city) & (taraf_info['Year'] <= lstyear)]
26
  narrators = edge_info[edge_info['Edge_ID'].isin(info['ID'].unique())]
27
  return narrators
28
  def splitIsnad(dataframe):
 
32
  return dataframe
33
 
34
 
35
+ def network_visualizer(yaxis, city, fstyear,lastyr, num_nodes):
36
+ edges = splitIsnad(subsetEdges(city, fstyear, lastyr))[['Teacher', 'Student', yaxis]].reset_index()
37
  #.groupby(['Teacher', 'Student']).sum()
38
  if edges.shape[0] > num_nodes:
39
  edge_15 = edges.sample(num_nodes)
 
74
  with gr.Blocks() as demo:
75
  Yaxis = gr.Dropdown(choices = ['Tarafs', 'Hadiths', 'Isnads', 'Books'], value = 'Tarafs', label = 'Variable to Display', info = 'Choose the variable to visualize.')
76
  Places = gr.Dropdown(choices = cities, value = 'المدينه', label = 'Location')
77
+ FirstYear = gr.Slider(min_year, max_year, value = -11, label = 'Begining', info = 'Choose the first year to display Narrators')
78
+ Last_Year = gr.Slider(min_year, max_year, value = 9, label = 'End', info = 'Choose the last year to display Narrators')
79
  num_narrators = gr.Slider(0, 700, value = 400, label = 'Narrators', info = 'Choose the number of Narrators to display')
80
 
81
  btn = gr.Button('Submit')
82
+ btn.click(fn = network_visualizer, inputs = [Yaxis, Places, FirstYear, Last_Year, num_narrators], outputs = gr.HTML())
83
  demo.launch()