QModel / scratch /verify_enhancements.py
aelgendy's picture
Sync codebase with local main (config, README, docker, gitignore updates)
15f1210 verified
Raw
History Blame Contribute Delete
1.21 kB
import sys
from app.arabic_nlp import is_root_match
from app.hadith_utils import highlight_narrators
from app.synonyms import expand_synonyms
def test_root_match():
# Root R-H-M (ุฑุญู…)
root = "ุฑุญู…"
assert is_root_match("ุงู„ุฑุญูŠู…", root) == True
assert is_root_match("ุงู„ุฑุญู…ู†", root) == True
assert is_root_match("ูŠุฑุญู…ูƒู…", root) == True
assert is_root_match("ุตุจุฑ", root) == False
print("โœ… Root match test passed")
def test_highlighting():
text = "ุญูŽุฏู‘ูŽุซูŽู†ูŽุง ุนูŽุจู’ุฏู ุงู„ู„ู‘ูŽู‡ู ุจู’ู†ู ู†ูู…ูŽูŠู’ุฑูุŒ ุนูŽู†ู’ ู‚ูŽูŠู’ุณู"
highlighted = highlight_narrators(text)
assert "**ุญูŽุฏู‘ูŽุซูŽู†ูŽุง**" in highlighted
assert "**ุนูŽู†ู’**" in highlighted
print("โœ… Highlighting test passed")
def test_synonyms():
keywords = ["patience"]
expanded = expand_synonyms(keywords)
assert "sabr" in expanded
assert "ุตุจุฑ" in expanded
print("โœ… Synonyms test passed")
if __name__ == "__main__":
try:
test_root_match()
test_highlighting()
test_synonyms()
print("All tests passed!")
except Exception as e:
print(f"โŒ Test failed: {e}")
sys.exit(1)