class_docstr: Transforms an input to upper and lower case or capitalize case.
  A sentence can only be transformed into one sentence of each case at most.
docstr: Transform each sample case according field.
  
  :param ~Sample sample: input data, normally one data sample.
  :param str field: indicate which filed to transform
  :param int n: number of generated samples
  :param kwargs:
  :return list trans_samples: transformed sample list.
docstr_tok: ["Transform","each","sample","case","according","field",".",":","param","~Sample","sample",":","input","data",",","normally","one","data","sample",".",":","param","str","field",":","indicate","which","filed","to","transform",":","param","int","n",":","number","of","generated","samples",":","param","kwargs",":",":","return","list","trans_samples",":","transformed","sample","list","."]
code: def _transform(self, sample, field="x", n=1, **kwargs):
      r"""
      Transform each sample case according field.
  
      :param ~Sample sample: input data, normally one data sample.
      :param str field: indicate which filed to transform
      :param int n: number of generated samples
      :param kwargs:
      :return list trans_samples: transformed sample list.
  
      """
      field_value = sample.get_value(field)
  
      if self.case_type == "random":
          case_type = ["upper", "lower", "title"][random.randint(0, 2)]
      else:
          case_type = self.case_type
  
      if isinstance(field_value, list):
          transform_text = [
              self.case_trans(token, case_type) for token in field_value
          ]
      elif isinstance(field_value, str):
          transform_text = self.case_trans(field_value, case_type)
      else:
          raise ValueError(
              "Cant apply WordCase transformation to field {0}".format(
                  field
              )
          )
  
      return [sample.replace_field(field, transform_text)]
  
file_path: textflint/textflint/generation/transformation/UT/word_case.py
imports: import random
  from ..transformation import Transformation
label_desc: Use image node_id 3 for calling the WordCase obj's underlying member method code with example usage: obj._transform(sample, field, n) and returns: list