code: def convert(example):
      cls, written, spoken = example
  
      written = convert_fraction(written)
      written = re.sub("é", "e", written)
      written = convert_superscript(written)
  
      if cls == "TIME":
          written = re.sub("([0-9]): ([0-9])", "\\1:\\2", written)
      if cls == "MEASURE":
          written = re.sub("([0-9])\s?''", '\\1"', written)
  
      spoken = process_url(spoken)
  
      if cls in [
          "TELEPHONE",
          "DIGIT",
          "MEASURE",
          "DECIMAL",
          "MONEY",
          "ADDRESS",
      ]:
          spoken = re.sub(" o ", " zero ", spoken)
          spoken = re.sub(" o ", " zero ", spoken)
          spoken = re.sub("^o ", "zero ", spoken)
          spoken = re.sub(" o$", " zero", spoken)
          spoken = re.sub("^sil ", "", spoken)
          spoken = re.sub(" sil ", " ", spoken)
          spoken = re.sub(" sil ", " ", spoken)
          spoken = re.sub(" sil$", "", spoken)
  
      if cls != "ELECTRONIC":
          written = add_space_around_dash(written)
  
      example[1] = written
      example[2] = spoken
  
      l = args.max_integer_length - 2
  
      # if written form does not fulfill this format return
      if not re.search("[0-9]{%s}[,\s]?[0-9]{3}" % l, written):
          if cls != "FRACTION":
              return
          idx = written.index("/")
          denominator = written[idx + 1 :].strip()
          if not re.search(
              r"[0-9]{%s}" % (args.max_denominator_length + 1),
              denominator,
          ):
              return
  
      # convert spoken forms for different classes
      if cls == "CARDINAL":
          if written[0] == "-":
              digits = "minus " + convert2digits(written[1:])[0]
          else:
              digits = convert2digits(written)[0]
          spoken = digits
      elif cls == "ADDRESS":
          idx = re.search("[0-9]", written).start()
          number = convert2digits(written[idx:].strip())[0]
          s_words = spoken.split()
          for i, x in enumerate(s_words):
              if x in number_verbalizations:
                  break
          spoken = " ".join(s_words[:i]) + " " + number
      elif cls == "DECIMAL":
          res = []
          for i, x in enumerate(written):
              if i == 0 and x == "-":
                  res.append("minus")
              elif x in digit:
                  res.append(
                      engine.number_to_words(str(x), zero="zero")
                      .replace("-", " ")
                      .replace(",", "")
                  )
              elif x == ".":
                  res.append("point")
          spoken = " ".join(res)
          m = re.search("([a-z]+)", written)
          if m:
              spoken += " " + m.group(1)
      elif cls == "FRACTION":
          res = []
          if written[0] == "-":
              res.append("minus")
              written = written[1:]
          idx = written.index("/")
          numerator = written[:idx].strip()
          denominator = written[idx + 1 :].strip()
          if len(numerator) > args.max_integer_length:
              numerator = convert2digits(numerator)[0]
          else:
              numerator = (
                  engine.number_to_words(str(numerator), zero="zero")
                  .replace("-", " ")
                  .replace(",", "")
              )
          if len(denominator) > args.max_denominator_length:
              denominator = convert2digits(denominator)[0]
          else:
              denominator = (
                  engine.number_to_words(str(denominator), zero="zero")
                  .replace("-", " ")
                  .replace(",", "")
              )
          spoken = numerator + " slash " + denominator
          if res:
              spoken = "minus " + spoken
      elif cls == "MEASURE":
          res = []
          if written[0] == "-":
              res.append("minus")
              written = written[1:]
          idx = re.search(
              "(?s:.*)([0-9]\s?[a-zA-Zµμ\/%Ω'])", written
          ).end()
          number, unit_idx = convert2digits(written[:idx].strip())
          s_words = spoken.split()
          for i, x in enumerate(s_words):
              if x not in number_verbalizations:
                  break
  
          spoken = number + " " + " ".join(s_words[i:])
          if res:
              spoken = "minus " + spoken
      elif cls == "MONEY":
          res = []
          if written[0] == "-":
              res.append("minus")
              written = written[1:]
          idx = re.search("[0-9]", written).start()
          m = re.search("\.", written[idx:])
          idx_end = len(written)
          if m:
              idx_end = m.start() + idx
          number, unit_idx = convert2digits(
              written[idx:idx_end].strip()
          )
          s_words = spoken.split()
          for i, x in enumerate(s_words):
              if x not in number_verbalizations:
                  break
          spoken = number + " " + " ".join(s_words[i:])
          if res:
              spoken = "minus " + spoken
      elif cls == "ORDINAL":
          res = []
          if written[0] == "-":
              res.append("minus")
              written = written[1:]
          if "th" in written.lower():
              idx = written.lower().index("th")
          elif "rd" in written.lower():
              idx = written.lower().index("rd")
          elif "nd" in written.lower():
              idx = written.lower().index("nd")
          elif "st" in written.lower():
              idx = written.lower().index("st")
          if re.search(r"[¿¡ºª]", written) is None:
              spoken = (
                  convert2digits(written[:idx].strip())[0]
                  + " "
                  + written[idx:].lower()
              )
          if res:
              spoken = "minus " + spoken
      example[2] = spoken
  
file_path: NeMo/examples/nlp/duplex_text_normalization/data/en/data_preprocessing.py
imports: import os
  from argparse import ArgumentParser
  import inflect
  import regex
  from tqdm import tqdm
  from nemo.collections.common.tokenizers.moses_tokenizers import MosesProcessor
  from nemo.collections.nlp.data.text_normalization.constants import EN_GREEK_TO_SPOKEN
  from nemo.collections.nlp.data.text_normalization.utils import add_space_around_dash, convert_fraction, convert_superscript
  from nemo.utils import logging
label_desc: Use image node_id 3 for calling a global function with example usage: convert(example) without return types