def tsv_to_jsonl(infile, outfile, split):
  """Converts TSV file to JSONL.

  Args:
    infile: Input TSV filename.
    outfile: Output JSONL filename.
    split: The split name (e.g., "train" or "dev"). Used in example IDs.
  """
  count = 0
  with tf.io.gfile.GFile(infile) as fin:
    with tf.io.gfile.GFile(outfile, "w") as fout:
      for i, line in enumerate(fin):
        fields = line.rstrip("\n").split("\t")
        ex = MTopEx(*fields)
        lang = ex.locale.split("_")[0]  # en_XX --> en
        unique_id = "{}-{}-{}".format(lang, split, i)
        entry = {
            "hashed_id": unique_id,
            "orig_query": ex.query,
            "input_str": " ".join(json.loads(ex.tokens)["tokens"]),
            "output_str": ex.output,
            "lang": lang,
            "domain": ex.domain,
        }
        print(json.dumps(entry), file=fout)
        count += 1
  logging.info("Converted %d examples to %s", count, outfile)
Converts TSV file to JSONL.

  Args:
    infile: Input TSV filename.
    outfile: Output JSONL filename.
    split: The split name (e.g., "train" or "dev"). Used in example IDs.
  
language/casper/utils/mtop_tsv_to_jsonl.py