setup of multi hadith isnad viewing with specific matn tracking
Browse files
app.py
CHANGED
@@ -61,13 +61,40 @@ def value_to_hex(value):
|
|
61 |
return "#{:02X}{:02X}{:02X}".format(int(rgba_color[0] * 255), int(rgba_color[1] * 255), int(rgba_color[2] * 255))
|
62 |
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
def visualize_isnad(taraf_num, yaxis):
|
65 |
-
|
66 |
-
|
|
|
67 |
taraf_hadith_split = [i.split('_') for i in taraf_hadith]
|
68 |
-
taraf_book =
|
69 |
-
taraf_author =
|
70 |
-
taraf_hadith_number =
|
71 |
lst_hadith = []
|
72 |
hadith_cleaned = isnad_info['Tarafs Cleaned'].apply(lambda x: taraf_num in x)
|
73 |
isnad_hadith = isnad_info[hadith_cleaned]
|
@@ -152,7 +179,7 @@ def taraf_booknum(taraf_num):
|
|
152 |
taraf = matn_info[matn_info['taraf_ID'] == taraf_num]
|
153 |
return taraf[['matn', 'Book_ID', 'Hadith Number', 'Book_Name', 'Author']]
|
154 |
|
155 |
-
def
|
156 |
df['bookid_hadithid'] = df['Book_ID'].astype(str) + '_' + df['Hadith Number'].astype(str)
|
157 |
hadith = matn_info[matn_info['bookid_hadithid'].isin(df['bookid_hadithid'])]
|
158 |
taraf_hadith_split = [i.split('_') for i in hadith['bookid_hadithid'].to_list()]
|
@@ -230,5 +257,5 @@ with gr.Blocks() as demo:
|
|
230 |
row_count=5,
|
231 |
col_count=(2, "fixed"))
|
232 |
btn_hadith = gr.Button('Visualize')
|
233 |
-
btn_hadith.click(fn=
|
234 |
demo.launch()
|
|
|
61 |
return "#{:02X}{:02X}{:02X}".format(int(rgba_color[0] * 255), int(rgba_color[1] * 255), int(rgba_color[2] * 255))
|
62 |
|
63 |
|
64 |
+
def visualize_subTaraf(taraf_num, hadith_str, yaxis):
|
65 |
+
hadith_list = hadith_str.split(',')
|
66 |
+
hadith_list = [hadith.strip() for hadith in hadith_list]
|
67 |
+
hadiths = np.array([], dtype=int)
|
68 |
+
for hadith in hadith_list:
|
69 |
+
if '-' in hadith:
|
70 |
+
if hadith.count('-') > 1:
|
71 |
+
#print('Please use only one Dash mark!')
|
72 |
+
raise gr.Error('Please use only one Dash mark!')
|
73 |
+
hadith_multi = hadith.strip().split('-')
|
74 |
+
if any([not had.isnumeric() for had in hadith_multi]):
|
75 |
+
#print('Invalid Begining')
|
76 |
+
raise gr.Error('Invalid Begining')
|
77 |
+
elif len(hadith_multi) != 2:
|
78 |
+
#print('Two numbers for a range of Hadith numbers please!')
|
79 |
+
raise gr.Error('Two numbers for a range of Hadith numbers please!')
|
80 |
+
hadith_multi = [int(had) for had in hadith_multi]
|
81 |
+
hadiths = np.append(hadiths, np.arange(hadith_multi[0], hadith_multi[1]))
|
82 |
+
elif hadith.isnumeric():
|
83 |
+
hadiths = np.append(hadiths, int(hadith))
|
84 |
+
else:
|
85 |
+
#print('Invalid Data format!')
|
86 |
+
raise gr.Error("Invalid Data format!")
|
87 |
+
return hadiths
|
88 |
+
|
89 |
+
|
90 |
def visualize_isnad(taraf_num, yaxis):
|
91 |
+
taraf = matn_info[matn_info['taraf_ID'] == taraf_num]
|
92 |
+
taraf_hadith = taraf['bookid_hadithid'].to_list()
|
93 |
+
taraf_matns = taraf['matn'].to_list()
|
94 |
taraf_hadith_split = [i.split('_') for i in taraf_hadith]
|
95 |
+
taraf_book = taraf['Book_Name'].to_list()
|
96 |
+
taraf_author = taraf['Author'].to_list()
|
97 |
+
taraf_hadith_number = taraf['Hadith Number'].to_list()
|
98 |
lst_hadith = []
|
99 |
hadith_cleaned = isnad_info['Tarafs Cleaned'].apply(lambda x: taraf_num in x)
|
100 |
isnad_hadith = isnad_info[hadith_cleaned]
|
|
|
179 |
taraf = matn_info[matn_info['taraf_ID'] == taraf_num]
|
180 |
return taraf[['matn', 'Book_ID', 'Hadith Number', 'Book_Name', 'Author']]
|
181 |
|
182 |
+
def visualize_hadith_isnad(df, yaxis):
|
183 |
df['bookid_hadithid'] = df['Book_ID'].astype(str) + '_' + df['Hadith Number'].astype(str)
|
184 |
hadith = matn_info[matn_info['bookid_hadithid'].isin(df['bookid_hadithid'])]
|
185 |
taraf_hadith_split = [i.split('_') for i in hadith['bookid_hadithid'].to_list()]
|
|
|
257 |
row_count=5,
|
258 |
col_count=(2, "fixed"))
|
259 |
btn_hadith = gr.Button('Visualize')
|
260 |
+
btn_hadith.click(fn=visualize_hadith_isnad, inputs=[hadith_selection, yyaxis], outputs=[gr.HTML()])
|
261 |
demo.launch()
|