#!/usr/bin/env bash
# Clean 10k test with all fixes applied
# Run this when ready: ./run_clean_10k.sh

set -e

echo "=========================================="
echo "CLEAN 10K TEST - Fixed Category System"
echo "=========================================="
echo ""
echo "Fixes applied:"
echo "  ✓ Removed hardcoded category pollution"
echo "  ✓ LLM-only category discovery"
echo "  ✓ Intelligent scaling (3% cal, 1% val)"
echo ""
echo "Expected results:"
echo "  - ~11 clean categories (not 29)"
echo "  - No duplicates (Work vs work)"
echo "  - Realistic confidence scores"
echo ""
echo "Starting at: $(date)"
echo ""

# Activate venv
if [ -z "$VIRTUAL_ENV" ]; then
    source venv/bin/activate
fi

# Clean start
rm -rf results_10k/
rm -f src/models/calibrated/classifier.pkl
rm -f src/models/category_cache.json

# Run with progress visible
python -m src.cli run \
    --source enron \
    --limit 10000 \
    --output results_10k/ \
    --verbose

echo ""
echo "=========================================="
echo "COMPLETE at: $(date)"
echo "=========================================="
echo ""
echo "Check results:"
echo "  - Categories: cat src/models/category_cache.json | python3 -m json.tool"
echo "  - Model: ls -lh src/models/calibrated/"
echo "  - Results: ls -lh results_10k/"
echo ""
