#!/usr/bin/env python3 """Copy 10 batches of EN/en-ES/en-EU JSON or JSONL into original_input/.""" from pathlib import Path import argparse, shutil, sys LANGUAGES = ('EN', 'en-ES', 'en-EU') def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('source', type=Path) parser.add_argument('--output', type=Path, default=Path('original_input')) parser.add_argument('--batches', type=int, default=10) parser.add_argument('--overwrite', action='store_true') args = parser.parse_args() if not args.source.is_dir(): parser.error(f'Not a directory: {args.source}') if args.batches < 1: parser.error('--batches must be at least 1') copied = skipped = 0 missing = [] errors = [] for n in range(1, args.batches + 1): bid = f'{n:03d}' folder = args.output / f'batch_{bid}' folder.mkdir(parents=True, exist_ok=True) for lang in LANGUAGES: stem = f'MT_arxiv_crx_batch_{bid}_{lang}' candidates = [args.source / f'{stem}.{ext}' for ext in ('json','jsonl')] found = [p for p in candidates if p.is_file()] if len(found) != 1: if not found: missing.append(stem) else: errors.append(f'Ambiguous extensions: {stem}') continue target = folder / found[0].name if target.exists() and not args.overwrite: skipped += 1 continue try: shutil.copy2(found[0], target) copied += 1 except OSError as exc: errors.append(f'{stem}: {exc}') print(f'Expected: {args.batches * 3}, copied: {copied}, skipped: {skipped}, missing: {len(missing)}, errors: {len(errors)}') for f in missing: print(f'MISSING {f}.json/.jsonl', file=sys.stderr) for e in errors: print(f'ERROR {e}', file=sys.stderr) return 1 if missing or errors else 0 if __name__ == '__main__': sys.exit(main())