liugz18
2024-07-18 d80ac2fd2df4e7fb8a28acfa512bb11472b5cc99
runtime/python/utils/proce_text.py
@@ -1,4 +1,3 @@
import sys
import re
@@ -7,25 +6,25 @@
with open(in_f, "r", encoding="utf-8") as f:
  lines = f.readlines()
    lines = f.readlines()
with open(out_f, "w", encoding="utf-8") as f:
  for line in lines:
    outs = line.strip().split(" ", 1)
    if len(outs) == 2:
      idx, text = outs
      text = re.sub("</s>", "", text)
      text = re.sub("<s>", "", text)
      text = re.sub("@@", "", text)
      text = re.sub("@", "", text)
      text = re.sub("<unk>", "", text)
      text = re.sub(" ", "", text)
      text = text.lower()
    else:
      idx = outs[0]
      text = " "
    for line in lines:
        outs = line.strip().split(" ", 1)
        if len(outs) == 2:
            idx, text = outs
            text = re.sub("</s>", "", text)
            text = re.sub("<s>", "", text)
            text = re.sub("@@", "", text)
            text = re.sub("@", "", text)
            text = re.sub("<unk>", "", text)
            text = re.sub(" ", "", text)
            text = text.lower()
        else:
            idx = outs[0]
            text = " "
    text = [x for x in text]
    text = " ".join(text)
    out = "{} {}\n".format(idx, text)
    f.write(out)
        text = [x for x in text]
        text = " ".join(text)
        out = "{} {}\n".format(idx, text)
        f.write(out)