Download tests/test_query_builder.py from khiemdztv/civic-backup: direct link, hf CLI and curl.
- Browser
- Download file 2.25 kB
-
https://huggingface.co/khiemdztv/civic-backup/resolve/main/tests/test_query_builder.py
- Command line
-
hf download hf://khiemdztv/civic-backup/tests/test_query_builder.py
-
curl -L -o test_query_builder.py https://huggingface.co/khiemdztv/civic-backup/resolve/main/tests/test_query_builder.py
2.25 kB
| """Bộ dựng truy vấn tra cứu — chặn hồi quy đã đo thật trên index TTHC.""" | |
| from src.retrieval.query_builder import build_retrieval_query, strip_noise | |
| RAW = ("cho e xin phép được hỏi, e làm hồ sơ bảo hiểm thất nghiệp mã hồ sơ " | |
| "<MAHOSO_1> từ ngày 29/4/2026, tới nay vẫn cứ treo hoài vậy ạ?") | |
| def test_bo_the_pii_va_ngay_thang(): | |
| out = strip_noise(RAW) | |
| assert "<MAHOSO_1>" not in out | |
| assert "29/4/2026" not in out and "2026" not in out | |
| assert "bảo hiểm thất nghiệp" in out # từ khoá nghiệp vụ phải còn | |
| def test_bo_tu_dem_hoi_thoai(): | |
| out = strip_noise(RAW) | |
| for filler in (" xin ", " phép ", " vậy ", " hoài "): | |
| assert filler not in f" {out} " | |
| def test_bo_so_hieu_van_ban(): | |
| assert "000.00.19" not in strip_noise("mã hồ sơ 000.00.19.H29-250429-0123 của tôi") | |
| def test_giu_so_hieu_van_ban_phap_luat(): | |
| q = build_retrieval_query("Tôi có được hưởng theo nghị quyết 50 /2025/NQ-HĐND không?") | |
| assert "50/2025/NQ-HĐND" in q | |
| def test_chuan_hoa_cach_goi_dan_gian_cua_thu_tuc(): | |
| q = build_retrieval_query("Tôi muốn đổi tên trong giấy khai sinh") | |
| assert "cải chính" in q and "hộ tịch" in q | |
| def test_khong_them_tu_khoa_linh_vuc_khi_than_du_dai(): | |
| """Thêm từ khoá lĩnh vực vào truy vấn dài làm LOÃNG kết quả — đã đo thật.""" | |
| q = build_retrieval_query(RAW, domain="SOCIAL_INSURANCE") | |
| assert "bảo hiểm y tế" not in q # từ khoá chung của lĩnh vực | |
| assert "bảo hiểm thất nghiệp" in q # từ khoá đặc thù từ lời dân | |
| def test_them_tu_khoa_linh_vuc_khi_than_qua_ngan(): | |
| q = build_retrieval_query("ạ?", domain="JUSTICE") | |
| assert "hộ tịch" in q or "lý lịch tư pháp" in q | |
| def test_uu_tien_ten_thu_tuc(): | |
| q = build_retrieval_query(RAW, domain="SOCIAL_INSURANCE", | |
| procedure_name="hưởng trợ cấp thất nghiệp") | |
| assert q.startswith("hưởng trợ cấp thất nghiệp") | |
| def test_khong_bao_gio_tra_ve_rong(): | |
| assert build_retrieval_query("ạ ơi nhé").strip() | |
| assert build_retrieval_query("<SDT_1> 0912345678").strip() | |