FDSRashid commited on
Commit
c068b81
·
verified ·
1 Parent(s): 1f77093

included book information

Browse files
Files changed (1) hide show
  1. app.py +17 -1
app.py CHANGED
@@ -13,6 +13,22 @@ dataset = load_dataset("FDSRashid/embed_matn", token = Secret_token)
13
  df = dataset["train"].to_pandas()
14
  taraf_max = np.max(df['taraf_ID'].unique())
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  def plot_similarity_score(taraf_num):
17
  taraf_df = df[df['taraf_ID']== taraf_num]
18
  taraf_df['Number'] = np.arange(len(taraf_df))
@@ -25,7 +41,7 @@ def plot_similarity_score(taraf_num):
25
  lower_triangle = matr[mask]
26
  data = lower_triangle.flatten()
27
  fig_dis = px.histogram(x = data, title = f'Similarity Distribution for Taraf {taraf_num}', labels = {'x': 'Similarity Score'}, nbins = 20, template = 'ggplot2' )
28
- return fig, fig_dis, taraf_df[['matn', 'Number']]
29
 
30
  with gr.Blocks() as demo:
31
  taraf_number = gr.Slider(1,taraf_max , value=10000, label="Taraf", info="Choose the Taraf to Input", step = 1)
 
13
  df = dataset["train"].to_pandas()
14
  taraf_max = np.max(df['taraf_ID'].unique())
15
 
16
+ dataset = load_dataset("FDSRashid/hadith_info", data_files = 'All_Matns.csv',token = Secret_token, features = features)
17
+ matn_info = dataset['train'].to_pandas()
18
+ matn_info = matn_info.drop(97550)
19
+ matn_info = matn_info.drop(307206)
20
+ matn_info['taraf_ID'] = matn_info['taraf_ID'].replace('KeyAbsent', -1)
21
+
22
+ matn_info['Book'] = matn_info['bookid_hadithid'].apply(lambda x: books[books['Book_ID'] == int(x.split('_')[0])]['Book_Name'].to_list()[0])
23
+ matn_info['Author'] = matn_info['bookid_hadithid'].apply(lambda x: books[books['Book_ID'] == int(x.split('_')[0])]['Author'].to_list()[0])
24
+ matn_info['Hadith Number'] = matn_info['bookid_hadithid'].apply(lambda x: x.split('_')[1])
25
+
26
+
27
+
28
+ joined_df = matn_info.merge(df, left_index=True, right_on='__index_level_0__')
29
+ df = joined_df.copy()
30
+
31
+
32
  def plot_similarity_score(taraf_num):
33
  taraf_df = df[df['taraf_ID']== taraf_num]
34
  taraf_df['Number'] = np.arange(len(taraf_df))
 
41
  lower_triangle = matr[mask]
42
  data = lower_triangle.flatten()
43
  fig_dis = px.histogram(x = data, title = f'Similarity Distribution for Taraf {taraf_num}', labels = {'x': 'Similarity Score'}, nbins = 20, template = 'ggplot2' )
44
+ return fig, fig_dis, taraf_df[['matn', 'Number', 'Book', 'Author', 'Hadith Number']]
45
 
46
  with gr.Blocks() as demo:
47
  taraf_number = gr.Slider(1,taraf_max , value=10000, label="Taraf", info="Choose the Taraf to Input", step = 1)