File size: 1,675 Bytes
9d170ee | 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 | # setup.py - Run this first to fix the import issue in neurolex_v4_dataset.py
# Usage: python setup.py
"""
This script fixes the missing import in neurolex_v4_dataset.py.
Run once after cloning the repo:
python setup.py
"""
def fix_dataset_import():
"""Add the missing CharTokenizer import to neurolex_v4_dataset.py"""
filepath = 'neurolex_v4_dataset.py'
with open(filepath, 'r') as f:
content = f.read()
# Check if fix is already applied
if 'from neurolex_v4_model import CharTokenizer' in content:
print("✅ Import already present - no fix needed")
return
# Add the import after 'import math'
old = "import math\n"
new = "import math\n\nfrom neurolex_v4_model import CharTokenizer\n"
if old in content:
content = content.replace(old, new, 1) # Replace only first occurrence
with open(filepath, 'w') as f:
f.write(content)
print("✅ Fixed: Added 'from neurolex_v4_model import CharTokenizer' to neurolex_v4_dataset.py")
else:
print("⚠️ Could not find insertion point. Please manually add:")
print(" from neurolex_v4_model import CharTokenizer")
print(" after the 'import math' line in neurolex_v4_dataset.py")
if __name__ == '__main__':
fix_dataset_import()
# Verify the fix works
print("\nVerifying imports...")
try:
from neurolex_v4_model import CharTokenizer, NeuroLexV4, create_model
from neurolex_v4_dataset import NeuroLexDataset, create_dataloaders
print("✅ All imports successful!")
except Exception as e:
print(f"❌ Import error: {e}")
|