# Makefile for Geotechnical Layer Extractor .PHONY: help setup single test-optimizer clean test info .DEFAULT_GOAL := help # Variables PYTHON := python3 VENV := venv VENV_BIN := $(VENV)/bin PIP := $(VENV_BIN)/pip PYTHON_VENV := $(VENV_BIN)/python # Optimizer variables EXAMPLES_DIR ?= examples EXPECTED_DIR ?= output_man help: @echo "๐Ÿชจ Geotechnical Layer Extractor" @echo "================================" @echo "" @echo "๐Ÿ“ฆ Setup:" @echo " make setup - Install all dependencies and create venv" @echo "" @echo "๐Ÿš€ Running:" @echo " make single PDF= - Extract layers from a single PDF" @echo " make test-optimizer - Run prompt optimization on test PDFs" @echo "" @echo "๐Ÿงน Maintenance:" @echo " make clean - Clean all generated files" @echo " make test - Test Azure connections" @echo " make info - Show system information" @echo "" @echo "Examples:" @echo " make single PDF=document.pdf" @echo " make single PDF=examples/sample.pdf" @echo " make test-optimizer" # Create virtual environment venv: @echo "๐Ÿ Creating virtual environment..." @$(PYTHON) -m venv $(VENV) @echo "โœ… Virtual environment created!" # Setup - Install all dependencies setup: venv @echo "๐Ÿ“ฆ Installing dependencies..." @$(PIP) install --upgrade pip @$(PIP) install -r requirements.txt @mkdir -p output @mkdir -p output_man @mkdir -p examples @echo "โœ… Setup complete!" @echo "" @echo "โš ๏ธ Don't forget to:" @echo "1. Add your Azure keys in the scripts" @echo "2. Add test PDFs in examples/ folder" @echo "3. Add expected results in output_man/ folder" # Extract layers from a single PDF single: @if [ -z "$(PDF)" ]; then \ echo "โŒ Please provide a PDF file: make single PDF=your_file.pdf"; \ exit 1; \ fi @if [ ! -f "$(PDF)" ]; then \ echo "โŒ File not found: $(PDF)"; \ exit 1; \ fi @if [ ! -f "extract_single.py" ]; then \ echo "โŒ extract_single.py not found!"; \ exit 1; \ fi @echo "๐Ÿš€ Extracting layers from: $(PDF)" @$(PYTHON_VENV) extract_single.py "$(PDF)" --pretty # Run prompt optimizer test-optimizer: @echo "๐Ÿ”ฌ Running Prompt Optimizer" @echo "==============================" @echo "๐Ÿ“ Examples directory: $(EXAMPLES_DIR)" @echo "๐Ÿ“ Expected results: $(EXPECTED_DIR)" @echo "" @if [ ! -f "prompt_optimizer.py" ]; then \ echo "โŒ prompt_optimizer.py not found!"; \ exit 1; \ fi @if [ ! -d "$(EXAMPLES_DIR)" ]; then \ echo "โŒ Examples directory not found: $(EXAMPLES_DIR)"; \ echo "๐Ÿ’ก Create it with: mkdir -p $(EXAMPLES_DIR)"; \ exit 1; \ fi @if [ ! -d "$(EXPECTED_DIR)" ]; then \ echo "โŒ Expected results directory not found: $(EXPECTED_DIR)"; \ echo "๐Ÿ’ก Create it with: mkdir -p $(EXPECTED_DIR)"; \ exit 1; \ fi @echo "๐Ÿš€ Starting optimization..." @$(PYTHON_VENV) prompt_optimizer.py \ --examples-dir $(EXAMPLES_DIR) \ --expected-dir $(EXPECTED_DIR) # Test Azure connections test: @echo "๐Ÿงช Testing Azure connections..." @$(PYTHON_VENV) -c "from azure.ai.formrecognizer import DocumentAnalysisClient; \ from azure.core.credentials import AzureKeyCredential; \ from openai import AzureOpenAI; \ print('โœ… Azure imports successful')" @echo "โœ… All imports working!" # Clean all generated files clean: @echo "๐Ÿงน Cleaning all files..." @rm -rf $(VENV) @rm -rf __pycache__ */__pycache__ @rm -rf .pytest_cache @rm -rf *.pyc */*.pyc @rm -rf output/*.json output/*.txt output/*.html @rm -rf *.log @rm -rf test_results.json @find . -type f -name ".DS_Store" -delete 2>/dev/null || true @echo "โœ… Clean complete!" # Show system information info: @echo "๐Ÿ“Š System Information:" @echo "======================" @echo "OS: $$(uname -s)" @echo "Python: $$($$(which $(PYTHON)) --version)" @if [ -d "$(VENV)" ]; then \ echo "Virtual env: โœ… $(VENV) exists"; \ echo "Pip version: $$($(PIP) --version 2>/dev/null || echo 'N/A')"; \ else \ echo "Virtual env: โŒ Not created (run 'make setup')"; \ fi @echo "" @echo "๐Ÿ“ Project structure:" @if [ -f "extract_single.py" ]; then \ echo "โœ… extract_single.py found"; \ else \ echo "โŒ extract_single.py missing"; \ fi @if [ -f "prompt_optimizer.py" ]; then \ echo "โœ… prompt_optimizer.py found"; \ else \ echo "โŒ prompt_optimizer.py missing"; \ fi @echo "" @echo "๐Ÿ“ Directories:" @if [ -d "output" ]; then \ echo "โœ… output/ exists ($$(ls -1 output/ 2>/dev/null | wc -l | tr -d ' ') files)"; \ else \ echo "โŒ output/ not found"; \ fi @if [ -d "$(EXAMPLES_DIR)" ]; then \ echo "โœ… $(EXAMPLES_DIR)/ exists ($$(ls -1 $(EXAMPLES_DIR)/*.pdf 2>/dev/null | wc -l | tr -d ' ') PDFs)"; \ else \ echo "โŒ $(EXAMPLES_DIR)/ not found"; \ fi @if [ -d "$(EXPECTED_DIR)" ]; then \ echo "โœ… $(EXPECTED_DIR)/ exists ($$(ls -1 $(EXPECTED_DIR)/*_layers.json 2>/dev/null | wc -l | tr -d ' ') JSON files)"; \ else \ echo "โŒ $(EXPECTED_DIR)/ not found"; \ fi