"""Tests for dataset split hygiene and classifier artifact reloading.""" import json from scripts.verify_dataset import verify_all from src.classification.classifier import EncoderIntentClassifier, TfidfIntentClassifier from src.config import CLASSIFIER_COMPARISON_PATH, INTENT_LABELS def test_dataset_and_manifest_hygiene(): summary = verify_all() assert summary["num_sources"] >= 8 assert set(summary["formats"]) >= {"pdf", "csv"} assert summary["num_intent_examples"] >= 120 assert summary["family_overlap_count"] == 0 assert summary["heldout_text_overlap"] == 0 def test_baseline_and_encoder_reload_and_predict(): tfidf = TfidfIntentClassifier() enc = EncoderIntentClassifier() for query in [ "When is the bursary closing date?", "I fit still apply on 12 June?", "How much be late student ID replacement fee?", "Which paper I need carry for application?", ]: p_base = tfidf.predict(query) p_enc = enc.predict(query) assert p_base.label in INTENT_LABELS assert p_enc.label in INTENT_LABELS assert 0.0 <= p_enc.confidence <= 1.0 comp = json.loads(CLASSIFIER_COMPARISON_PATH.read_text(encoding="utf-8")) assert comp["fine_tuned_encoder"]["checkpoint_reloaded_verified"] is True assert set(comp["test_counts_per_intent"].keys()) == set(INTENT_LABELS)