File size: 1,039 Bytes
24aaa76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""R5 DATA (optional helper): fixed 2,000-row random subsets of the three large Russian validation manifests (hkr_val, chd_val, school_val),
so that a validation pass over many checkpoints stays cheap. The full validation manifests stay as they are.
Draw: numpy.random.default_rng(20261121).choice(n, 2000, replace=False), rows kept in manifest order. Opens no image.
Usage: python -I r5_val_subsets.py
"""
import numpy as np
from pathlib import Path

MAN = Path("/path/to/TURKIC_OCR_DATA/data/processed/r5/manifests")
for name in ("hkr_val", "chd_val", "school_val"):
    lines = open(MAN / f"{name}.tsv", encoding="utf-8", newline="").read().split("\n")
    header, rows = lines[0], [l for l in lines[1:] if l]
    rng = np.random.default_rng(20261121)
    pick = np.sort(rng.choice(len(rows), size=2000, replace=False))
    with open(MAN / f"{name}_s2000.tsv", "w", encoding="utf-8", newline="") as f:
        f.write(header + "\n")
        for i in pick:
            f.write(rows[i] + "\n")
    print(name, len(rows), "->", len(pick))