Blame view

NKJP/preProcessing/fixMissingDiv.py 309 Bytes
Jan Lupa authored
1
2
3
4
5
6
7
8
9
10
11
12
13
import re
import sys
from typing import Match

def fix(m: Match) -> str:
	n0 = int(m.group(1))
	n1 = n0 - 1 if n0 > 2 else n0
	return str(n1) + (m.group(2) or '') + m.group(3)

if __name__ == '__main__':
	with open(sys.argv[1]) as i:
		for l in i:
			print(re.sub(r'(\d+)(\.\d+)?(-div|-ab)', fix, l), end='')