turkic-ocr-code / scripts /r5_ref /ref_smoke_blank_labels.py
treoa's picture
Release 1
24aaa76
Raw History Blame Contribute Delete
584 Bytes
"""R5 REF smoke test helper: copies a mix list and blanks the text of every 4th row (empty targets, as the clutter rows of mix_v1 have).
Usage: python ref_smoke_blank_labels.py <in.tsv> <out.tsv>"""
import sys
lines = open(sys.argv[1], encoding="utf-8").read().split("\n")
out = [lines[0]]
n = 0
for i, line in enumerate(lines[1:]):
if not line:
continue
f = line.split("\t")
if i % 4 == 0:
f[1] = ""
n += 1
out.append("\t".join(f))
open(sys.argv[2], "w", encoding="utf-8").write("\n".join(out) + "\n")
print("blanked", n, "of", len(out) - 1)