-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_search.py
58 lines (47 loc) · 1.92 KB
/
test_search.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import sys
import logging
from searcher.search import search_index
# Set up logging
logging.basicConfig(level=logging.INFO,
format='%(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
def test_search():
"""Test the search functionality with sample questions."""
# Sample questions that should match our data
test_questions = [
"İslam'da dua etmenin önemi nedir",
"Ramazan'da neler yapılır",
"Abdestte su yutmak orucu bozar mı",
"Dua",
"Oruç",
"Ramazan"
]
successful_tests = 0
print("\n====================================================")
print("TESTING SEARCH FUNCTIONALITY")
print("====================================================\n")
for question in test_questions:
print(f"Testing question: '{question}'\n")
results = search_index(question)
if results:
successful_tests += 1
print(f"✓ SUCCESS: Found {len(results)} matches for '{question}'")
print("Matching documents:")
for i, result in enumerate(results, 1):
print(f" {i}. {result['title']} (Score: {result['score']:.2f})")
else:
print(f"✗ FAILED: No matches found for '{question}'")
print("\n" + "-" * 50 + "\n")
print("====================================================")
print(f"Test results: {successful_tests}/{len(test_questions)} successful searches")
if successful_tests == len(test_questions):
print("✓ All tests passed! The search system is working correctly.")
return True
else:
print(f"✗ {len(test_questions) - successful_tests} tests failed. The search system needs improvement.")
return False
if __name__ == "__main__":
print("Starting search system tests...")
success = test_search()
if not success:
sys.exit(1)