class_docstr: Augmenter that replaces words based on a given mapping
docstr: Returns a text where random words are replaced using the specified mapping
  
  @param data: the text to which the word substitution will be applied
docstr_tok: ["Returns","a","text","where","random","words","are","replaced","using","the","specified","mapping","@","param","data",":","the","text","to","which","the","word","substitution","will","be","applied"]
code: def substitute(self, data: str) -> str:
      """
      Returns a text where random words are replaced using the specified mapping
  
      @param data: the text to which the word substitution will be applied
      """
      results = []
      tokens = tokenize(data)
      aug_word_cnt = self._generate_aug_cnt(
          len(tokens), self.aug_min, self.aug_max, self.aug_p
      )
      filtered_word_idxes = self.pre_skip_aug(tokens)
  
      if self.priority_words is None:
          self.priority_words = self.word_mapping.mapping.keys()
  
      aug_word_idxes = set(
          get_aug_idxes(
              self,
              tokens,
              filtered_word_idxes,
              aug_word_cnt,
              Method.WORD,
          )
      )
  
      if not aug_word_idxes:
          return data
  
      is_diff = False
      for t_i, token in enumerate(tokens):
          if t_i not in aug_word_idxes:
              results.append(token)
              continue
  
          new_token, has_changed = self.word_mapping.replace(token)
          is_diff = is_diff or has_changed
          results.append(new_token)
  
      return detokenize(results) if is_diff else data
  
file_path: AugLy/augly/text/augmenters/word_replacement.py
imports: import json
  from typing import Any, Dict, List, Optional, Tuple, Union
  from augly.text.augmenters.utils import detokenize, get_aug_idxes, tokenize
  from augly.utils import pathmgr
  from augly.utils.libsndfile import install_libsndfile
  from nlpaug.augmenter.word import WordAugmenter
  from nlpaug.util import Action, Method
label_desc: Use image node_id 3 for calling the WordReplacementAugmenter obj's underlying member method code with example usage: obj.substitute(data) and returns: unknown, data