class_docstr: Transforms an input by Reverse gender or place names in sentences.
class_docstr_tok: ["Transforms","an","input","by","Reverse","gender","or","place","names","in","sentences","."]
docstr: :param str change_type: change type, only support ['Name', 'Loc']
  :param str prejudice_tendency: prejudice tendency, choose different
      tendency according to change_type
docstr_tok: [":","param","str","change_type",":","change","type",",","only","support","[","'Name","'",",","'Loc","'","]",":","param","str","prejudice_tendency",":","prejudice","tendency",",","choose","different","tendency","according","to","change_type"]
code: def __init__(
      self,
      change_type="Loc",
      prejudice_tendency=None,
      trans_min=1,
      trans_max=10,
      trans_p=0.1,
      stop_words=None,
      **kwargs,
  ):
      r"""
      :param str change_type: change type, only support ['Name', 'Loc']
      :param str prejudice_tendency: prejudice tendency, choose different
          tendency according to change_type
  
      """
      super().__init__(
          trans_min=trans_min,
          trans_max=trans_max,
          trans_p=trans_p,
          stop_words=stop_words,
      )
      if change_type == "Name":
          self.flag_type = True
          if not prejudice_tendency or prejudice_tendency == "woman":
              self.prejudice_tendency = "woman"
          elif prejudice_tendency == "man":
              self.prejudice_tendency = "man"
          else:
              raise ValueError(
                  "Prejudice tendency not support name type {0}, "
                  "please choose change type from woman and man".format(
                      change_type
                  )
              )
          self.type = self.prejudice_tendency
          name_path = download_if_needed(CN_NAME_PATH)
          name_dict = json_loader(name_path)
          self.man_name = name_dict["man_name"]
          self.woman_name = name_dict["woman_name"]
  
          self.word = {}
          prejudice_word_path = download_if_needed(
              CN_PREJUDICE_WORD_PATH
          )
          f = open(prejudice_word_path, encoding="utf-8")
          lines = f.readlines()
          for line in lines:
              line = line.strip().split()
              self.word[line[0]] = line[1]
  
      elif change_type == "Loc":
          self.flag_type = False
          if not prejudice_tendency:
              prejudice_tendency = ["America"]
          elif isinstance(prejudice_tendency, str):
              prejudice_tendency = [prejudice_tendency]
          assert isinstance(prejudice_tendency, list)
          for prejudice_type in prejudice_tendency:
              if prejudice_type not in PREJUDICE_LOC2IDX:
                  raise ValueError(
                      "Prejudice tendency not support name type {0}, please "
                      "choose change type from America, Europe,Africa,China,"
                      "Japan,India".format(prejudice_type)
                  )
          self.prejudice_tendency = [
              PREJUDICE_LOC2IDX[i] for i in prejudice_tendency
          ]
          self.max_len_loc = 0
  
          from collections import defaultdict
  
          self.loc2idx = {}
          self.idx2loc = defaultdict(list)
          loc2idx_path = download_if_needed(CN_LOC2IDX_PATH)
          f = open(loc2idx_path, encoding="utf-8")
          lines = f.readlines()
          for line in lines:
              line = line.strip().split("\t")
              city, idx = line[0], int(line[1])
              self.loc2idx[city] = idx
              self.idx2loc[idx].append(city)
          self.type = "".join([k[:2] for k in prejudice_tendency])
          self.prejudice_data = [
              j
              for i in self.prejudice_tendency
              for j in self.idx2loc[i]
          ]
  
      else:
          raise ValueError(
              "Prejudice not support name type {0}, please choose"
              " change type from Name and Loc".format(change_type)
          )
  
file_path: textflint/textflint/generation/transformation/UTCN/cn_prejudice.py
imports: import random
  from ..transformation import Transformation
  from ....common.utils.list_op import descartes
  from ....common.utils.load import json_loader
  from ....common.utils.install import download_if_needed
  from ....common.settings import PREJUDICE_LOC2IDX, CN_NAME_PATH, CN_PREJUDICE_WORD_PATH, CN_LOC2IDX_PATH
label_desc: Use image node_id 1 to create a new CnPrejudice object from inherited base classes: Transformation with example: obj = CnPrejudice(change_type, prejudice_tendency, trans_min, trans_max, trans_p, stop_words)