Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -25,9 +25,9 @@ matn_info = matn_info.drop(307206)
|
|
25 |
matn_info['taraf_ID'] = matn_info['taraf_ID'].replace('KeyAbsent', -1)
|
26 |
matn_info['taraf_ID'] = matn_info['taraf_ID'].astype(int)
|
27 |
|
28 |
-
matn_info['
|
29 |
matn_info['Hadith Number'] = matn_info['bookid_hadithid'].apply(lambda x: int(x.split('_')[1]))
|
30 |
-
matn_info =
|
31 |
cols_to_use = df.columns.difference(matn_info.columns)
|
32 |
|
33 |
joined_df = matn_info.merge(df[cols_to_use], left_index=True, right_on='__index_level_0__')
|
@@ -42,7 +42,7 @@ def find_most_similar_matn(text, n):
|
|
42 |
indices = np.argsort(cos_sim)[0][-n:]
|
43 |
matns = df.iloc[indices]
|
44 |
matns['Similarity'] = cos_sim[0][indices]
|
45 |
-
return matns[['Book_Name', 'matn', 'taraf_ID', '
|
46 |
|
47 |
with gr.Blocks() as demo:
|
48 |
text_input = gr.Textbox()
|
|
|
25 |
matn_info['taraf_ID'] = matn_info['taraf_ID'].replace('KeyAbsent', -1)
|
26 |
matn_info['taraf_ID'] = matn_info['taraf_ID'].astype(int)
|
27 |
|
28 |
+
matn_info['Book_ID'] = matn_info['bookid_hadithid'].apply(lambda x: int(x.split('_')[0]))
|
29 |
matn_info['Hadith Number'] = matn_info['bookid_hadithid'].apply(lambda x: int(x.split('_')[1]))
|
30 |
+
matn_info = pd.merge(matn_info, books, on='Book_ID')
|
31 |
cols_to_use = df.columns.difference(matn_info.columns)
|
32 |
|
33 |
joined_df = matn_info.merge(df[cols_to_use], left_index=True, right_on='__index_level_0__')
|
|
|
42 |
indices = np.argsort(cos_sim)[0][-n:]
|
43 |
matns = df.iloc[indices]
|
44 |
matns['Similarity'] = cos_sim[0][indices]
|
45 |
+
return matns[['Book_Name', 'matn', 'taraf_ID', 'Book_ID', 'Hadith Number', 'Author', 'Similarity']]
|
46 |
|
47 |
with gr.Blocks() as demo:
|
48 |
text_input = gr.Textbox()
|