class_docstr: Augmenter that replaces words based on a given mapping
class_docstr_tok: ["Augmenter","that","replaces","words","based","on","a","given","mapping"]
docstr: Returns a text where random words are replaced using the specified mapping
  
  @param text: 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","text",":","the","text","to","which","the","word","substitution","will","be","applied"]
code: def substitute_contractions(self, text: str) -> str:
      """
      Returns a text where random words are replaced using the specified mapping
  
      @param text: the text to which the word substitution will be applied
      """
      results = []
      tokens = tokenize(text)
  
      for c_len in range(2, self.max_contraction_length + 1):
          i = 0
          while i <= len(tokens) - c_len:
              result = tokens[i]
              if self.rng.rand() <= self.aug_p:
                  contraction = self.contraction_mapping.replace(
                      " ".join(tokens[i : i + c_len])
                  )
                  if contraction is not None:
                      result = contraction
                      i += c_len - 1
              results.append(result)
              i += 1
  
          results.extend(tokens[-c_len + 1 :])
  
      return detokenize(results)
  
file_path: AugLy/augly/text/augmenters/contraction.py
imports: import json
  from typing import Any, Dict, List, Optional, Union
  import numpy
  from augly.text.augmenters.utils import detokenize, tokenize
  from augly.utils import pathmgr
label_desc: Use image node_id 3 for calling the ContractionAugmenter obj's underlying member method code with example usage: obj.substitute_contractions(text) and returns: detokenize