"""Inspect either XArch JSONL schema without loading the whole split into RAM.""" import argparse import itertools import json from pathlib import Path def iter_records(dataset_dir, split='train', view='functions'): suffix = '.functions.jsonl' if view == 'functions' else '.jsonl' path = Path(dataset_dir) / (split + suffix) with path.open(encoding='utf-8') as stream: for line in stream: yield json.loads(line) def main(): p = argparse.ArgumentParser(description=__doc__) p.add_argument('--dataset-dir', required=True) p.add_argument('--view', choices=['functions', 'pairs'], default='functions') p.add_argument('--split', choices=['train', 'validation', 'test'], default='train') p.add_argument('--limit', type=int, default=2) args = p.parse_args() for record in itertools.islice(iter_records(args.dataset_dir, args.split, args.view), args.limit): example = dict(record) for name in ['text', 'query', 'positive']: if name in example: example[name] = example[name][:240] print(json.dumps(example, indent=2, ensure_ascii=False)) if __name__ == '__main__': main()