FDSRashid commited on
Commit
a91aa86
·
verified ·
1 Parent(s): 52446a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -16
app.py CHANGED
@@ -34,7 +34,7 @@ def subset_city_year(city, year1, year2):
34
  edges = taraf_info[(taraf_info['Year'] >= year1) & (taraf_info['Year'] <= year2)]
35
  else:
36
  edges = taraf_info[(taraf_info['Year'] >= year1) & (taraf_info['City'].isin(city)) & (taraf_info['Year'] <= year2)]
37
- return edges
38
 
39
  def subset_year(year = 50):
40
  edges = taraf_info[(taraf_info['Year'] == year)]
@@ -49,23 +49,23 @@ def splitIsnad(dataframe):
49
 
50
 
51
  def get_narrators( city , year1, year2):
52
- try:
53
- df = subset_city_year(city, year1, year2)
54
- narrators = edge_info[edge_info['Edge_ID'].isin(df['ID'])]
55
- fixed = splitIsnad(narrators)
56
- fixed['Teacher Reports'] = fixed['Teacher_ID'].apply(lambda x: narrator_bios[narrator_bios['Rawi ID']== x]['Number of Narrations'].to_list()[0])
57
- fixed['Student Reports'] = fixed['Student_ID'].apply(lambda x: narrator_bios[narrator_bios['Rawi ID']== x]['Number of Narrations'].to_list()[0])
58
- return fixed[['Teacher', 'Student', 'Teacher Reports', 'Student Reports', 'Isnads', 'Hadiths', 'Tarafs', 'Books']]
59
- except Exception as e:
60
- return str(e)
61
 
62
 
63
 
64
 
65
  with gr.Blocks() as demo:
66
- Places = gr.Dropdown(choices = cities + ['All'], value = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], multiselect=True, label = 'Location')
67
- First_Year = gr.Slider(min_year, max_year, value = 10, label = 'Begining', info = 'Choose the first year to display Narrators')
68
- Last_Year = gr.Slider(min_year, max_year, value = 50, label = 'End', info = 'Choose the Last year to display Narrators')
69
- btn = gr.Button('Submit')
70
- btn.click(fn = get_narrators, inputs = [Places, First_Year, Last_Year], outputs = gr.DataFrame())
71
- demo.launch()
 
34
  edges = taraf_info[(taraf_info['Year'] >= year1) & (taraf_info['Year'] <= year2)]
35
  else:
36
  edges = taraf_info[(taraf_info['Year'] >= year1) & (taraf_info['City'].isin(city)) & (taraf_info['Year'] <= year2)]
37
+ return edges
38
 
39
  def subset_year(year = 50):
40
  edges = taraf_info[(taraf_info['Year'] == year)]
 
49
 
50
 
51
  def get_narrators( city , year1, year2):
52
+ try:
53
+ df = subset_city_year(city, year1, year2)
54
+ narrators = edge_info[edge_info['Edge_ID'].isin(df['ID'])]
55
+ fixed = splitIsnad(narrators)
56
+ fixed['Teacher Reports'] = fixed['Teacher_ID'].apply(lambda x: narrator_bios[narrator_bios['Rawi ID']== x]['Number of Narrations'].to_list()[0])
57
+ fixed['Student Reports'] = fixed['Student_ID'].apply(lambda x: narrator_bios[narrator_bios['Rawi ID']== x]['Number of Narrations'].to_list()[0])
58
+ return fixed[['Teacher', 'Student', 'Teacher Reports', 'Student Reports', 'Isnads', 'Hadiths', 'Tarafs', 'Books']]
59
+ except Exception as e:
60
+ return str(e)
61
 
62
 
63
 
64
 
65
  with gr.Blocks() as demo:
66
+ Places = gr.Dropdown(choices = cities + ['All'], value = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], multiselect=True, label = 'Location')
67
+ First_Year = gr.Slider(min_year, max_year, value = 10, label = 'Begining', info = 'Choose the first year to display Narrators')
68
+ Last_Year = gr.Slider(min_year, max_year, value = 50, label = 'End', info = 'Choose the Last year to display Narrators')
69
+ btn = gr.Button('Submit')
70
+ btn.click(fn = get_narrators, inputs = [Places, First_Year, Last_Year], outputs = gr.DataFrame())
71
+ demo.launch()