using isnad info as opposed to edge info
Browse files
app.py
CHANGED
@@ -18,7 +18,7 @@ css = """
|
|
18 |
|
19 |
Secret_token = os.getenv('HF_Token')
|
20 |
|
21 |
-
|
22 |
|
23 |
lst = ['Rawi ID',
|
24 |
'Gender',
|
@@ -60,19 +60,38 @@ narrator_bios['Generation'] = narrator_bios['Generation'].replace([None], [-1])
|
|
60 |
narrator_bios['Generation'] = narrator_bios['Generation'].astype(int)
|
61 |
|
62 |
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
|
66 |
-
def splitIsnad(dataframe):
|
67 |
-
teacher_student =dataframe['Edge_Name'].str.split(' TO ')
|
68 |
-
dataframe['Teacher'] = teacher_student.apply(lambda x: x[0])
|
69 |
-
dataframe['Student'] = teacher_student.apply(lambda x: x[1])
|
70 |
-
return dataframe
|
71 |
|
72 |
|
73 |
def network_narrator(narrator_id):
|
74 |
-
edge_narrator = edge_info[(edge_info['Teacher_ID'] == narrator_id) | (edge_info['Student_ID'] == narrator_id)]
|
75 |
-
edge_full =
|
|
|
|
|
76 |
return edge_full
|
77 |
|
78 |
def narrator_retriever(name):
|
|
|
18 |
|
19 |
Secret_token = os.getenv('HF_Token')
|
20 |
|
21 |
+
edge_info = load_dataset('FDSRashid/hadith_info',token = Secret_token, data_files = 'isnad_info.csv', split = 'train').to_pandas()
|
22 |
|
23 |
lst = ['Rawi ID',
|
24 |
'Gender',
|
|
|
60 |
narrator_bios['Generation'] = narrator_bios['Generation'].astype(int)
|
61 |
|
62 |
|
63 |
+
def get_node_info(node):
|
64 |
+
node_info = narrator_bios[narrator_bios['Rawi ID'] == int(node)]
|
65 |
+
student_narrations = node_info['Number of Narrations'].to_list()
|
66 |
+
if len(student_narrations):
|
67 |
+
student_narrations = student_narrations[0]
|
68 |
+
else:
|
69 |
+
student_narrations = 1
|
70 |
+
student_gen = node_info['Generation'].to_list()
|
71 |
+
if len(student_gen):
|
72 |
+
student_gen = student_gen[0]
|
73 |
+
else:
|
74 |
+
student_gen = -1
|
75 |
+
student_rank = node_info["Narrator Rank"].to_list()
|
76 |
+
if len(student_rank):
|
77 |
+
student_rank = student_rank[0]
|
78 |
+
else:
|
79 |
+
student_rank = 'فلان'
|
80 |
+
node_name = node_info['Famous Name'].to_list()
|
81 |
+
if len(node_name):
|
82 |
+
node_name = node_name[0]
|
83 |
+
else:
|
84 |
+
node_name = 'فلان'
|
85 |
+
return node_info,student_narrations,student_gen, student_rank, node_name
|
86 |
|
87 |
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
|
90 |
def network_narrator(narrator_id):
|
91 |
+
edge_narrator = edge_info[(edge_info['Teacher_ID'] == str(narrator_id)) | (edge_info['Student_ID'] == str(narrator_id))]
|
92 |
+
edge_full = edge_narrator[['Taraf Count', 'Hadith Count', 'Isnad Count', 'Source', 'Book Count', 'Destination']]
|
93 |
+
edge_full['Teacher'] = edge_full['Source'].apply(lambda x: get_node_info(x)[-1] )
|
94 |
+
edge_full['Student'] = edge_full['Destination'].apply(lambda x: get_node_info(x)[-1] )
|
95 |
return edge_full
|
96 |
|
97 |
def narrator_retriever(name):
|