class_docstr: Entity position swap with paraphrase(employee related)
class_docstr_tok: ["Entity","position","swap","with","paraphrase","(","employee","related",")"]
docstr: Swap entity position through paraphrasing
  
  :param RESample sample: sample input
  :param int n: number of generated samples (no more than one)
  :return list: transformed sample list
docstr_tok: ["Swap","entity","position","through","paraphrasing",":","param","RESample","sample",":","sample","input",":","param","int","n",":","number","of","generated","samples","(","no","more","than","one",")",":","return","list",":","transformed","sample","list"]
code: def _transform(self, sample, n=5, **kwargs):
      r"""
      Swap entity position through paraphrasing
  
      :param RESample sample: sample input
      :param int n: number of generated samples (no more than one)
      :return list: transformed sample list
  
      """
      assert isinstance(sample, RESample), (
          f"the type of 'sample' should be RESample, "
          f"got {type(sample)} instead"
      )
      assert isinstance(n, int), (
          f"the type of 'n' should be int, " f"got {type(n)} instead"
      )
  
      tokens, relation = sample.get_sent()
      if "emplo" not in relation and "business" not in relation:
          return [sample]
      sh, st, oh, ot = sample.get_en()
      head_pos, tail_pos = [sh, st], [oh, ot]
      subj = [sh, st]
      obj = [oh, ot]
      _, heads = sample.get_dp()
      new_sample = {}
      new_sample["x"] = tokens
  
      if "emplo" or "business" in relation:
          ner = sample.stan_ner_transform()
          assert len(ner) == len(tokens)
          splited_sent = self.split_sent(head_pos, tail_pos, tokens)
          if splited_sent is not None:
              (
                  reverse,
                  left,
                  right,
                  middle_pos,
                  middle_words,
                  left_words,
                  right_words,
              ) = splited_sent
  
              is_attrib = self.assert_attributive(
                  left, right, tokens, heads, middle_words, middle_pos
              )
  
              middle_text = " ".join(middle_words)
              is_title = False
              title_pos = [0, 0]
              for title in self.titles_dict:
                  if title.lower() in middle_text.lower():
                      is_title = True
                      title_pos[0] = len(
                          (middle_text.split(title.lower())[0]).split(
                              " "
                          )
                      )
                      title_pos[1] = (
                          title_pos[0] + len(title.split(" ")) - 1
                      )
              if is_title and is_attrib:
                  new_sample["x"], subj, obj = self.generate_new_item(
                      reverse,
                      left,
                      right,
                      left_words,
                      right_words,
                      middle_words,
                      title_pos,
                  )
  
      new_sample["subj"], new_sample["obj"], new_sample["y"] = (
          subj,
          obj,
          relation,
      )
      trans_samples = sample.replace_sample_fields(new_sample)
  
      return [trans_samples]
  
file_path: textflint/textflint/generation/transformation/RE/swap_employee.py
imports: from ...transformation import Transformation
  from ....common.settings import TITLE
  from ....common.utils.install import download_if_needed
  from ....common.utils.load import json_loader
  from ....input.component.sample.re_sample import RESample
label_desc: Use image node_id 6 for calling the SwapEmployee obj's underlying member method code with example usage: obj._transform(sample, n) and returns: list, list