File size: 459 Bytes
e9a85fb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | """One text normalization used everywhere (ground truth, synthetic text, predictions).
Every model is scored after the same normalization, so changing this file
changes the benchmark: bump BENCHMARK_VERSION in eval.py if you edit it.
"""
import re
import unicodedata
_WS = re.compile(r"\s+")
def normalize(s: str) -> str:
s = unicodedata.normalize("NFC", s)
s = s.replace(" ", " ").replace("\t", " ")
s = _WS.sub(" ", s).strip()
return s
|