class_docstr: Transformation that simulate typos error to transform sentence.
  
      https://arxiv.org/pdf/1711.02173.pdf
class_docstr_tok: ["Transformation","that","simulate","typos","error","to","transform","sentence",".","https",":","\/\/arxiv.org\/pdf\/1711.02173.pdf"]
docstr: Transform data sample to a list of Sample.
  
  :param ~NERSample input_sample: Data sample for augmentation
  :param int n: Default is 5. MAx number of unique augmented output
  :return: list of NERSample
docstr_tok: ["Transform","data","sample","to","a","list","of","Sample",".",":","param","~NERSample","input_sample",":","Data","sample","for","augmentation",":","param","int","n",":","Default","is","5",".","MAx","number","of","unique","augmented","output",":","return",":","list","of","NERSample"]
code: def _transform(self, sample, n=1, **kwargs):
      r"""
      Transform data sample to a list of Sample.
  
      :param ~NERSample input_sample: Data sample for augmentation
      :param int n: Default is 5. MAx number of unique augmented output
      :return: list of NERSample
      """
      rep_samples = []
      entities = sample.entities[::-1]
      rep_entities = []
      candidates = []
  
      for entity in entities:
          cur_entity = entity["entity"]
          entity_tokens = cur_entity.split(" ")
          rep_idx = random.randint(0, len(entity_tokens) - 1)
          rep_tokens = self._get_replacement_words(
              entity_tokens[rep_idx], n=n
          )
  
          if rep_tokens:
              rep_entities.append(entity)
              candidates.append(
                  [
                      " ".join(
                          entity_tokens[:rep_idx]
                          + [rep_token]
                          + entity_tokens[rep_idx + 1 :]
                      )
                      for rep_token in rep_tokens
                  ]
              )
      candidates, rep_entities = trade_off_sub_words(
          candidates, rep_entities, n=n
      )
  
      if not candidates:
          return []
  
      for i in range(len(candidates)):
          _candidates = candidates[i]
          rep_samples.append(
              sample.entities_replace(rep_entities, _candidates)
          )
  
      return rep_samples
  
file_path: textflint/textflint/generation/transformation/NER/ent_typos.py
imports: from ....common.utils.word_op import *
  from ..transformation import Transformation
  from ....common.utils.list_op import trade_off_sub_words
label_desc: Use image node_id 3 for calling the EntTypos obj's underlying member method code with example usage: obj._transform(sample, n) and returns: rep_samples, list