File size: 3,647 Bytes
992eedb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env python3
"""
NFL Training Data Generator - Interactive Runner
"""

import subprocess
import sys
from pathlib import Path

def main():
    print("🏈 NFL Training Data Generator")
    print("=" * 50)
    print("Choose processing mode:")
    print("1. Test with 10 random rules (recommended for first run)")
    print("2. Process ALL rules in the file")
    print("3. Custom number of rules")
    print("4. Exit")
    
    while True:
        choice = input("\nEnter your choice (1-4): ").strip()
        
        if choice == "1":
            # 10 random rules
            cmd = [
                sys.executable,
                "generate_nfl_training_data.py",
                "sample_2024_nfl_rulebook.csv",
                "--sample", "10",
                "--output-dir", "output_10_random"
            ]
            print("🎯 Processing 10 random rules...")
            break
            
        elif choice == "2":
            # All rules
            cmd = [
                sys.executable,
                "generate_nfl_training_data.py", 
                "sample_2024_nfl_rulebook.csv",
                "--output-dir", "output_full"
            ]
            print("🎯 Processing ALL rules...")
            break
            
        elif choice == "3":
            # Custom number
            try:
                num_rules = int(input("Enter number of random rules to process: "))
                cmd = [
                    sys.executable,
                    "generate_nfl_training_data.py",
                    "sample_2024_nfl_rulebook.csv", 
                    "--sample", str(num_rules),
                    "--output-dir", f"output_{num_rules}_random"
                ]
                print(f"🎯 Processing {num_rules} random rules...")
                break
            except ValueError:
                print("❌ Please enter a valid number")
                continue
                
        elif choice == "4":
            print("πŸ‘‹ Goodbye!")
            return 0
            
        else:
            print("❌ Please enter 1, 2, 3, or 4")
            continue
    
    # Run the command
    try:
        print(f"\nπŸš€ Running command: {' '.join(cmd)}")
        print("-" * 50)
        
        result = subprocess.run(cmd, check=True)
        
        print("\nβœ… Generation completed successfully!")
        
        # Show generated files
        output_dir = Path(cmd[cmd.index("--output-dir") + 1])
        if output_dir.exists():
            files = list(output_dir.glob("*.jsonl"))
            if files:
                print(f"\nπŸ“ Generated files:")
                for file in files:
                    print(f"  - {file}")
                    
                    # Show file size and line count
                    with open(file, 'r') as f:
                        lines = f.readlines()
                        print(f"    πŸ“Š {len(lines)} training examples")
                        
                    # Show sample content
                    if lines:
                        print(f"    πŸ“ Sample content:")
                        sample_line = lines[0][:150] + "..." if len(lines[0]) > 150 else lines[0]
                        print(f"    {sample_line}")
        
        return 0
        
    except subprocess.CalledProcessError as e:
        print(f"\n❌ Generation failed with exit code {e.returncode}")
        return 1
    except KeyboardInterrupt:
        print(f"\n⚠️ Generation interrupted by user")
        return 1
    except Exception as e:
        print(f"\n❌ Unexpected error: {e}")
        return 1

if __name__ == "__main__":
    exit(main())