class_docstr: Augmenter that replaces letters with similar mappings
docstr: Returns a text where random letters are replaced by the specified mapping
  
  @param data: the text where the letter substitution will be applied on
docstr_tok: ["Returns","a","text","where","random","letters","are","replaced","by","the","specified","mapping","@","param","data",":","the","text","where","the","letter","substitution","will","be","applied","on"]
code: def substitute(self, data: str) -> str:
      """
      Returns a text where random letters are replaced by the specified mapping
  
      @param data: the text where the letter substitution will be applied on
      """
      tokens, whitespaces = split_words_on_whitespace(data)
      aug_word_cnt = self._generate_aug_cnt(
          len(tokens),
          self.aug_word_min,
          self.aug_word_max,
          self.aug_word_p,
      )
      filtered_word_idxes = self.skip_aug(
          self.pre_skip_aug(tokens), tokens
      )
      aug_word_idxes = set(
          get_aug_idxes(
              self,
              tokens,
              filtered_word_idxes,
              aug_word_cnt,
              Method.WORD,
          )
      )
  
      for t_i, token in enumerate(tokens):
          if t_i not in aug_word_idxes:
              continue
  
          chars = list(token)
          aug_char_cnt = self._generate_aug_cnt(
              len(chars),
              self.aug_char_min,
              self.aug_char_max,
              self.aug_char_p,
          )
          aug_char_idxes = (
              None
              if len(chars) < self.min_char
              else set(
                  get_aug_idxes(
                      self,
                      chars,
                      list(range(len(chars))),
                      aug_char_cnt,
                      Method.CHAR,
                  )
              )
          )
  
          if not aug_char_idxes:
              continue
  
          for c_i, char in enumerate(chars):
              if c_i in aug_char_idxes:
                  chars[c_i] = self.sample(
                      self.letter_mapping.replace(char), 1
                  )[0]
  
          tokens[t_i] = "".join(chars)
  
      return rejoin_words_and_whitespace(tokens, whitespaces)
  
file_path: AugLy/augly/text/augmenters/letter_replacement.py
imports: import json
  from typing import List, Optional
  from augly.text.augmenters.utils import get_aug_idxes, LETTER_CHAR_MAPPING, rejoin_words_and_whitespace, split_words_on_whitespace, validate_augmenter_params
  from augly.utils import pathmgr
  from augly.utils.libsndfile import install_libsndfile
  from nlpaug.augmenter.char import CharAugmenter
  from nlpaug.util import Action, Method
label_desc: Use image node_id 3 for calling the LetterReplacementAugmenter obj's underlying member method code with example usage: obj.substitute(data) and returns: rejoin_words_and_whitespace