FDSRashid commited on
Commit
8e1ef87
·
verified ·
1 Parent(s): 177f898

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -11
app.py CHANGED
@@ -58,11 +58,6 @@ narrator_bios['Generation'] = narrator_bios['Generation'].astype(int)
58
  edge_info = dataset.to_pandas()
59
 
60
 
61
-
62
- # def subsetEdges(fstyear, lstyear):
63
- # info = taraf_info[(taraf_info['Year'] >= fstyear)& (taraf_info['Year'] <= lstyear)]
64
- # narrators = edge_info[edge_info['Edge_ID'].isin(info['ID'].unique())]
65
- # return narrators
66
  def splitIsnad(dataframe):
67
  teacher_student =dataframe['Edge_Name'].str.split(' TO ')
68
  dataframe['Teacher'] = teacher_student.apply(lambda x: x[0])
@@ -71,18 +66,17 @@ def splitIsnad(dataframe):
71
 
72
 
73
  def network_narrator(narrator_id):
74
- # edges = subsetEdges(fst_year, lst_year)
75
- # edges_single = edges[(edges['Teacher_ID']==narrator_id) | (edges['Student_ID']==narrator_id)]
76
- # edges_prepped = splitIsnad(edges_single)
77
  edge_narrator = edge_info[(edge_info['Teacher_ID'] == narrator_id) | (edge_info['Student_ID'] == narrator_id)]
78
  edge_full = splitIsnad(edge_narrator[['Tarafs', 'Hadiths', 'Isnads', 'Edge_Name', 'Books']]).drop(['Edge_Name'], axis=1)
79
  return edge_full
80
 
81
  def narrator_retriever(name):
82
- 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)]
 
 
 
83
 
84
 
85
-
86
  with gr.Blocks() as demo:
87
  gr.Markdown("Search Narrators using this tool or Retrieve Transmissions involving Narrator")
88
  with gr.Tab("Search Narrator"):
@@ -91,7 +85,7 @@ with gr.Blocks() as demo:
91
  text_button = gr.Button("Search")
92
  text_button.click(narrator_retriever, inputs=text_input, outputs=text_output)
93
 
94
- with gr.Tab("Visualize Network"):
95
  image_input = gr.Number()
96
  image_button = gr.Button("Retrieve!")
97
  image_button.click(network_narrator, inputs=[image_input], outputs=[gr.DataFrame(wrap=True)])
 
58
  edge_info = dataset.to_pandas()
59
 
60
 
 
 
 
 
 
61
  def splitIsnad(dataframe):
62
  teacher_student =dataframe['Edge_Name'].str.split(' TO ')
63
  dataframe['Teacher'] = teacher_student.apply(lambda x: x[0])
 
66
 
67
 
68
  def network_narrator(narrator_id):
 
 
 
69
  edge_narrator = edge_info[(edge_info['Teacher_ID'] == narrator_id) | (edge_info['Student_ID'] == narrator_id)]
70
  edge_full = splitIsnad(edge_narrator[['Tarafs', 'Hadiths', 'Isnads', 'Edge_Name', 'Books']]).drop(['Edge_Name'], axis=1)
71
  return edge_full
72
 
73
  def narrator_retriever(name):
74
+ full_names = name.split(',')
75
+ full_names =[i.strip() for i in full_names]
76
+ return narrator_bios[(narrator_bios['Official Name'].apply(lambda x: araby.strip_diacritics(x)).isin([araby.strip_diacritics(n) for n in full_names])) | (narrator_bios['Famous Name'].apply(lambda x: araby.strip_diacritics(x)).isin([araby.strip_diacritics(n) for n in full_names])) | (narrator_bios['Rawi ID'].astype(str).isin([n for n in full_names])]
77
+ #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)]
78
 
79
 
 
80
  with gr.Blocks() as demo:
81
  gr.Markdown("Search Narrators using this tool or Retrieve Transmissions involving Narrator")
82
  with gr.Tab("Search Narrator"):
 
85
  text_button = gr.Button("Search")
86
  text_button.click(narrator_retriever, inputs=text_input, outputs=text_output)
87
 
88
+ with gr.Tab("View Network"):
89
  image_input = gr.Number()
90
  image_button = gr.Button("Retrieve!")
91
  image_button.click(network_narrator, inputs=[image_input], outputs=[gr.DataFrame(wrap=True)])