FDSRashid commited on
Commit
1063eae
·
1 Parent(s): 7095e8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -5
app.py CHANGED
@@ -4,6 +4,11 @@ import os
4
  import pandas as pd
5
  from datasets import load_dataset
6
 
 
 
 
 
 
7
  Secret_token = os.getenv('token')
8
 
9
  dataset = load_dataset('FDSRashid/hadith_info',data_files = 'Basic_Edge_Information.csv', token = Secret_token, split = 'train')
@@ -14,6 +19,16 @@ cities = taraf_info['City'].unique().tolist()
14
  min_year = int(taraf_info['Year'].min())
15
  max_year = int(taraf_info['Year'].max())
16
 
 
 
 
 
 
 
 
 
 
 
17
  def subset_city_year(city, year1, year2):
18
  edges = taraf_info[(taraf_info['Year'] >= year1) & (taraf_info['City'].isin(city)) & (taraf_info['Year'] <= year2)]
19
  return edges
@@ -32,12 +47,14 @@ def splitIsnad(dataframe):
32
 
33
  def get_narrators( city , year1, year2):
34
  try:
35
- df = subset_city_year(city, year1, year2)
36
- narrators = edge_info[edge_info['Edge_ID'].isin(df['ID'])]
37
- fixed = narrators['Edge_Name'].reset_index()
38
- return splitIsnad(fixed).reset_index().drop(['index','Edge_Name'], axis = 1)
 
 
39
  except Exception as e:
40
- return str(e)
41
 
42
 
43
 
 
4
  import pandas as pd
5
  from datasets import load_dataset
6
 
7
+ from datasets import load_dataset
8
+ from datasets import Features
9
+ from datasets import Value
10
+ from datasets import Dataset
11
+
12
  Secret_token = os.getenv('token')
13
 
14
  dataset = load_dataset('FDSRashid/hadith_info',data_files = 'Basic_Edge_Information.csv', token = Secret_token, split = 'train')
 
19
  min_year = int(taraf_info['Year'].min())
20
  max_year = int(taraf_info['Year'].max())
21
 
22
+
23
+ features = Features({'Rawi ID': Value('int32'), 'Famous Name': Value('string'), 'Narrator Rank': Value('string'), 'Number of Narrations': Value('string')})
24
+ narrator_bios = load_dataset("FDSRashid/hadith_info", data_files = 'Teacher_Bios.csv', token = HF_Token,features=features )
25
+ narrator_bios = narrator_bios['train'].to_pandas()
26
+ narrator_bios.loc[49845, 'Narrator Rank'] = 'رسول الله'
27
+ narrator_bios.loc[49845, 'Number of Narrations'] = 0
28
+ narrator_bios['Number of Narrations'] = narrator_bios['Number of Narrations'].astype(int)
29
+ narrator_bios.loc[49845, 'Number of Narrations'] = narrator_bios['Number of Narrations'].sum()
30
+
31
+
32
  def subset_city_year(city, year1, year2):
33
  edges = taraf_info[(taraf_info['Year'] >= year1) & (taraf_info['City'].isin(city)) & (taraf_info['Year'] <= year2)]
34
  return edges
 
47
 
48
  def get_narrators( city , year1, year2):
49
  try:
50
+ df = subset_city_year(city, year1, year2)
51
+ narrators = edge_info[edge_info['Edge_ID'].isin(df['ID'])]
52
+ fixed = splitIsnad(narrators)
53
+ fixed['Teacher Reports'] = narrator_bios[narrator_bios['Rawi ID'] == fixed['Teacher_ID']]
54
+ fixed['Teacher Reports'] = narrator_bios[narrator_bios['Rawi ID'] == fixed['Teacher_ID']]
55
+ return fixed[['Teacher', 'Student', 'Teacher Reports', 'Student Reports']]
56
  except Exception as e:
57
+ return str(e)
58
 
59
 
60