code: def get_replacement_vocab() -> None:
      """Loops through the files with alignment results in each semiotic class subfolder, counts frequencies of different
      replacement segments.
      """
  
      full_vocab = Counter()
      alignment_files = glob.glob(
          args.giza_dir + "/*/" + args.alignment_filename
      )
      for fn in alignment_files:
          fn_parts = fn.split("/")
          if len(fn_parts) < 2:
              raise ValueError("Bad filename: " + fn)
          semiotic_class = fn_parts[-2]
          class_vocab = Counter()
          with open(fn, "r", encoding="utf-8") as f:
              for line in f:
                  t = process_line(semiotic_class, line)
                  if t is None:
                      continue
                  src, dst, replacement, freq = t
                  inputs = src.split(" ")
                  replacements = replacement.split(" ")
                  if len(inputs) != len(replacements):
                      raise ValueError("Length mismatch in: " + line)
                  for inp, rep in zip(inputs, replacements):
                      if inp == rep:  # skip same words
                          continue
                      full_vocab[rep] += freq
                      class_vocab[rep] += freq
          with open(
              args.vocab_filename + "." + semiotic_class,
              "w",
              encoding="utf-8",
          ) as out:
              for k, v in class_vocab.most_common(1000000000):
                  out.write(k + "\t" + str(v) + "\n")
  
      with open(args.vocab_filename, "w", encoding="utf-8") as out:
          for k, v in full_vocab.most_common(1000000000):
              out.write(k + "\t" + str(v) + "\n")
  
file_path: NeMo/examples/nlp/text_normalization_as_tagging/dataset_preparation/prepare_corpora_after_alignment.py
imports: import glob
  import os
  from argparse import ArgumentParser
  from collections import Counter
  from typing import Dict, Optional, TextIO, Tuple
  from nemo.collections.nlp.data.text_normalization_as_tagging.utils import get_src_and_dst_for_alignment
  from nemo.utils import logging
label_desc: Use image node_id 3 for calling a global function with example usage: get_replacement_vocab() without return types