class_docstr: Augmenter that replaces words with typos. You can specify a typo_type: charmix, which
  does a combination of character-level modifications (delete, insert, substitute, &
  swap); keyboard, which swaps characters which those close to each other on the QWERTY
  keyboard; misspelling, which replaces words with misspellings defined in a dictionary
  file; or all, which will apply a random combination of all 4
class_docstr_tok: ["Augmenter","that","replaces","words","with","typos",".","You","can","specify","a","typo_type",":","charmix",",","which","does","a","combination","of","character-level","modifications","(","delete",",","insert",",","substitute",",","&","swap",")",";","keyboard",",","which","swaps","characters","which","those","close","to","each","other","on","the","QWERTY","keyboard",";","misspelling",",","which","replaces","words","with","misspellings","defined","in","a","dictionary","file",";","or","all",",","which","will","apply","a","random","combination","of","all","4"]
docstr: Returns text where random words are typos
  
  @param data: the text where the word substitutions will occur
docstr_tok: ["Returns","text","where","random","words","are","typos","@","param","data",":","the","text","where","the","word","substitutions","will","occur"]
code: def substitute(self, data: str) -> str:
      """
      Returns text where random words are typos
  
      @param data: the text where the word substitutions will occur
      """
      results = []
      tokens = self.tokenizer(data)
      aug_word_cnt = self._generate_aug_cnt(
          len(tokens), self.aug_min, self.aug_max, self.aug_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 in range(1, self.max_typo_length + 1):
          i = 0
          while i <= len(tokens) - t_i:
              if i not in aug_word_idxes:
                  results.append(tokens[i])
                  i += 1
                  continue
  
              misspellings = (
                  self.model.replace(" ".join(tokens[i : i + t_i]))
                  if self.model
                  else None
              )
  
              if misspellings:
                  misspelling = self.sample(misspellings, 1)[0]
                  results.append(
                      self.align_capitalization(tokens[i], misspelling)
                  )
                  i += t_i - 1
              elif len(self.augmenters) > 0:
                  aug = self.sample(self.augmenters, 1)[0]
                  new_token = aug.augment(tokens[i])
                  results.append(
                      self.align_capitalization(tokens[i], new_token)
                  )
              else:
                  # If no misspelling is found in the dict & no other typo types are being
                  # used, don't change the token
                  results.append(tokens[i])
              i += 1
  
          if t_i > 1:
              results.extend(tokens[-t_i + 1 :])
  
      return detokenize(results)
  
file_path: AugLy/augly/text/augmenters/typo.py
imports: import json
  from typing import List, Optional
  from augly.text.augmenters.utils import detokenize, get_aug_idxes, tokenize, validate_augmenter_params
  from augly.utils import pathmgr
  from augly.utils.libsndfile import install_libsndfile
  from nlpaug.augmenter.char import KeyboardAug, RandomCharAug
  from nlpaug.augmenter.word import WordAugmenter
  from nlpaug.util import Action, Method
label_desc: Use image node_id 4 for calling the TypoAugmenter obj's underlying member method code with example usage: obj.substitute(data) and returns: detokenize