Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -120,12 +120,12 @@ def search_hadith(query, top_k):
|
|
| 120 |
title_candidates = ["isnad_text", "hadith_title", "title", "main_subj"]
|
| 121 |
title_val = first_nonempty(row, title_candidates)
|
| 122 |
if not title_val:
|
| 123 |
-
# fallback to a short generated title from
|
| 124 |
-
title_val = short_preview(safe_get(row, "
|
| 125 |
|
| 126 |
-
#
|
| 127 |
-
|
| 128 |
-
|
| 129 |
|
| 130 |
topic = html.escape(safe_get(row, "main_subj"))
|
| 131 |
source_url = safe_get(row, "url")
|
|
@@ -139,7 +139,7 @@ def search_hadith(query, top_k):
|
|
| 139 |
except Exception:
|
| 140 |
score_display = ""
|
| 141 |
|
| 142 |
-
preview = short_preview(
|
| 143 |
preview_escaped = html.escape(preview).replace("\n", "<br>")
|
| 144 |
|
| 145 |
card_html = f"""
|
|
@@ -158,7 +158,7 @@ def search_hadith(query, top_k):
|
|
| 158 |
<div class="text-rtl">
|
| 159 |
<details>
|
| 160 |
<summary class="summary">{preview_escaped}</summary>
|
| 161 |
-
<div class="full-text">{
|
| 162 |
</details>
|
| 163 |
</div>
|
| 164 |
<div class="footer">
|
|
|
|
| 120 |
title_candidates = ["isnad_text", "hadith_title", "title", "main_subj"]
|
| 121 |
title_val = first_nonempty(row, title_candidates)
|
| 122 |
if not title_val:
|
| 123 |
+
# fallback to a short generated title from clean_text
|
| 124 |
+
title_val = short_preview(safe_get(row, "clean_text"), 60) or f"Hadith #{hadith_idx}"
|
| 125 |
|
| 126 |
+
# clean_text (main hadith body) - preserve Arabic text, escape HTML
|
| 127 |
+
clean_text = safe_get(row, "clean_text")
|
| 128 |
+
clean_text_escaped = html.escape(clean_text).replace("\n", "<br>")
|
| 129 |
|
| 130 |
topic = html.escape(safe_get(row, "main_subj"))
|
| 131 |
source_url = safe_get(row, "url")
|
|
|
|
| 139 |
except Exception:
|
| 140 |
score_display = ""
|
| 141 |
|
| 142 |
+
preview = short_preview(clean_text, length=360)
|
| 143 |
preview_escaped = html.escape(preview).replace("\n", "<br>")
|
| 144 |
|
| 145 |
card_html = f"""
|
|
|
|
| 158 |
<div class="text-rtl">
|
| 159 |
<details>
|
| 160 |
<summary class="summary">{preview_escaped}</summary>
|
| 161 |
+
<div class="full-text">{clean_text_escaped}</div>
|
| 162 |
</details>
|
| 163 |
</div>
|
| 164 |
<div class="footer">
|