code: def test_SwapEnt(self):
      # test data with no entity
      swap_ins_oov = SwapEnt("OOV")
      data = NERSample(
          {
              "x": data_sample.get_words("text"),
              "y": ["O"] * len(data_sample.get_words("text")),
          }
      )
      change = swap_ins_oov.transform(data, n=5)
      self.assertEqual([], change)
  
      # test tolonger
      swap_ins_longer = SwapEnt("SwapLonger")
      change = swap_ins_longer.transform(data_sample, n=5)
      self.assertTrue(5 >= len(change))
      for item in change:
          trans_entities = item.find_entities_BIO(
              item.text.words, item.tags
          )
          ori_entities = item.find_entities_BIO(
              data_sample.text.words, data_sample.tags
          )
          for ori_ent, trans_ent in zip(ori_entities, trans_entities):
              if ori_ent["tag"] in ["PER", "LOC", "ORG"]:
                  self.assertTrue(
                      len(trans_ent["entity"].split(" ")) >= 3
                  )
  
      # test multientity
      swap_ins_cross = SwapEnt("CrossCategory")
      change = swap_ins_cross.transform(data_sample, n=5)
      self.assertTrue(5 >= len(change))
      for item in change:
          trans_entities = item.find_entities_BIO(
              item.text.words, item.tags
          )
          ori_entities = item.find_entities_BIO(
              data_sample.text.words, data_sample.tags
          )
          for ori_ent, trans_ent in zip(ori_entities, trans_entities):
              if ori_ent["tag"] in ["PER", "LOC", "ORG"]:
                  self.assertTrue(
                      trans_ent["entity"] != ori_ent["entity"]
                  )
  
      # test oov
      change = swap_ins_oov.transform(data_sample, n=5)
      self.assertTrue(5 >= len(change))
      for item in change:
          trans_entities = item.find_entities_BIO(
              item.text.words, item.tags
          )
          ori_entities = item.find_entities_BIO(
              data_sample.text.words, data_sample.tags
          )
          for ori_ent, trans_ent in zip(ori_entities, trans_entities):
              if ori_ent["tag"] in ["PER", "LOC", "ORG"]:
                  self.assertTrue(
                      trans_ent["entity"] != ori_ent["entity"]
                  )
  
imports: import unittest
  from textflint.input.component.sample.ner_sample import NERSample
  from textflint.generation.transformation.NER.swap_ent import SwapEnt
label_desc: Use image node_id 3 for calling the TestSpecialSwapEnt obj's underlying member method code with example usage: obj.test_SwapEnt() without return types