class_docstr: Swap entities which shorter than threshold to longer ones.
class_docstr_tok: ["Swap","entities","which","shorter","than","threshold","to","longer","ones","."]
docstr: Transform data sample to a list of Sample.
  
  :param ~NERSample sample: Data sample for augmentation
  :param int n: Default is 1. MAx number of unique augmented output
  :param **kwargs:
  :return: Augmented data
docstr_tok: ["Transform","data","sample","to","a","list","of","Sample",".",":","param","~NERSample","sample",":","Data","sample","for","augmentation",":","param","int","n",":","Default","is","1",".","MAx","number","of","unique","augmented","output",":","param","*","*","kwargs",":",":","return",":","Augmented","data"]
code: def _transform(self, sample, n=1, **kwargs):
      r"""
      Transform data sample to a list of Sample.
  
      :param ~NERSample sample: Data sample for augmentation
      :param int n: Default is 1. MAx number of unique augmented output
      :param **kwargs:
      :return: Augmented data
      """
      rep_samples = []
      rep_entities = []
      entities = sample.entities
      candidates = []
  
      for entity in entities:
          assert entity["tag"] in [
              "PER",
              "LOC",
              "GPE",
              "ORG",
              "NS",
              "NT",
              "NR",
          ], "{0} is not supported".format(entity["tag"])
  
          if (
              self.swap_type == "SwapLonger"
              and entity["entity"] in self.res_dic
          ):
              rep_entities.append(entity)
              candidates.append(self.res_dic[entity["entity"]])
  
          elif self.swap_type == "OOV":
              trans_tag = LABEL_TRANS[entity["tag"]]
              rep_entities.append(entity)
              candidates.append(
                  random.sample(self.res_dic[trans_tag], n)[0]
              )
  
      for i in range(n):
          _candidates = [candidate for candidate in candidates]
          if not _candidates:
              return []
          rep_samples.append(
              sample.entities_replace(rep_entities, _candidates)
          )
  
      return rep_samples
  
file_path: textflint/textflint/generation/transformation/NERCN/swap_ent.py
imports: import random
  from ....common.settings import CN_LONG_ENTITIES
  from ....common.settings import CN_OOV_ENTITIES, LABEL_TRANS
  from ....common.utils.install import download_if_needed
  from ....common.utils.load import json_loader
  from ..transformation import Transformation
label_desc: Use image node_id 3 for calling the SwapEnt obj's underlying member method code with example usage: obj._transform(sample, n) and returns: rep_samples, list