Delete tools/quran_search.py
Browse files- tools/quran_search.py +0 -43
tools/quran_search.py
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
# tools/quran_search.py
|
2 |
-
|
3 |
-
# --- Patch for huggingface_hub cached_download removal ---
|
4 |
-
import huggingface_hub
|
5 |
-
if not hasattr(huggingface_hub, "cached_download"):
|
6 |
-
try:
|
7 |
-
from huggingface_hub import hf_hub_download
|
8 |
-
huggingface_hub.cached_download = hf_hub_download
|
9 |
-
except ImportError:
|
10 |
-
raise ImportError(
|
11 |
-
"huggingface_hub version is incompatible and cannot be patched automatically."
|
12 |
-
)
|
13 |
-
# ---------------------------------------------------------
|
14 |
-
|
15 |
-
import requests
|
16 |
-
import logging
|
17 |
-
import numpy as np
|
18 |
-
from sentence_transformers import SentenceTransformer
|
19 |
-
from sklearn.metrics.pairwise import cosine_similarity
|
20 |
-
from config import MODEL_NAME, CHUNK_SIZE
|
21 |
-
import time
|
22 |
-
import sys
|
23 |
-
|
24 |
-
class QuranSearchEngine:
|
25 |
-
def __init__(self):
|
26 |
-
self.api_url = "https://quranapi.pages.dev/api/"
|
27 |
-
self.logger = logging.getLogger(__name__)
|
28 |
-
self.surahs = None
|
29 |
-
self.all_verses = [] # List of {'surah_id': int, 'verse_num': int, 'text': str}
|
30 |
-
self.verse_embeddings = None
|
31 |
-
self.model = None # Deferred loading
|
32 |
-
print("Starting QuranSearchEngine initialization at", time.ctime(), file=sys.stderr) # Debug
|
33 |
-
try:
|
34 |
-
self._load_full_quran()
|
35 |
-
print(f"Surahs loaded: {len(self.surahs) if self.surahs else 0}", file=sys.stderr) # Debug
|
36 |
-
self._load_all_verses_and_embeddings()
|
37 |
-
print(f"Verses loaded: {len(self.all_verses)}", file=sys.stderr) # Debug
|
38 |
-
except Exception as e:
|
39 |
-
self.logger.error(f"Initialization failed: {e}", exc_info=True)
|
40 |
-
print(f"Initialization error: {e}", file=sys.stderr)
|
41 |
-
self._load_fallback_data() # Ensure minimal startup
|
42 |
-
|
43 |
-
# ... rest of your class code unchanged ...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|