#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"

# Full body-dependent rerun is optional because the copyrighted corpus is private.
# In the shared workspace, the frozen script reads ../work/. In a standalone
# extraction, place authorized inputs in private-input/ as documented in corpus-readme.md.
if [[ -f ../work/private-university-corpus-final.jsonl && -f ../work/authorized-university-index-dedup.json ]]; then
  python3 scripts/university_automated_analysis_frozen.py
  python3 scripts/build_public_automated_outputs.py
  python3 scripts/build_authorized_articles.py
elif [[ -f private-input/private-university-corpus-final.jsonl && -f private-input/authorized-university-index-dedup.json ]]; then
  python3 scripts/university_automated_analysis.py
fi

# These steps reproduce all public post-collection calculations.
python3 scripts/analyze_university_manual.py
python3 scripts/analyze_university_validation.py
python3 scripts/analyze_leadership_exploratory.py
python3 scripts/build_university_results.py
python3 scripts/check_package.py
