Spaces:
Sleeping
Sleeping
Update get_hadiths.py
Browse files- get_hadiths.py +5 -1
get_hadiths.py
CHANGED
|
@@ -51,7 +51,11 @@ class HadithSearch:
|
|
| 51 |
self.data['similarities'] = self.data.embeding.apply(lambda x: self._cosine_similarity(x, embedding))
|
| 52 |
|
| 53 |
results = self.data.sort_values('similarities', ascending=False).head(int(num_hadiths))
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
return formatted_results
|
| 56 |
|
| 57 |
def _format_results(self, results):
|
|
|
|
| 51 |
self.data['similarities'] = self.data.embeding.apply(lambda x: self._cosine_similarity(x, embedding))
|
| 52 |
|
| 53 |
results = self.data.sort_values('similarities', ascending=False).head(int(num_hadiths))
|
| 54 |
+
try:
|
| 55 |
+
results.drop(columns=["id","hadith_id", "embeding"], inplace=True)
|
| 56 |
+
except:
|
| 57 |
+
pass
|
| 58 |
+
formatted_results = self._format_results(results.to_dict(orient="records"))
|
| 59 |
return formatted_results
|
| 60 |
|
| 61 |
def _format_results(self, results):
|